On Thursday, 22 June 2017 at 00:48:25 UTC, Seb wrote:
Hi,
I am currently trying to modernize the D code example roulette
on the dlang.org front page [1]. Hence, I would love to hear
about your favorite feature(s) in D.
Ideas:
- favorite language construct
- favorite code sample
- "only possible in D"
Before you ask, yes - I want to add a couple of cool examples
to dlang.org (and yep the roulette rotation is currently broken
[2]).
[1]
https://github.com/dlang/dlang.org/pulls?q=is%3Apr+is%3Aopen+label%3A%22Frontpage+example%22
[2] https://github.com/dlang/dlang.org/pull/1757
A very simple vibe app could be added using dub's single-file
package format. Something like (I haven't tried this):
#!/usr/bin/env dub
/+ dub.sdl:
name "hello"
dependency "vibe-d" version="~>0.8.0-rc.1"
+/
import vibe.d;
shared static this()
{
auto settings = new HTTPServerSettings;
settings.port = 8080;
listenHTTP(settings, &handleRequest);
}
void handleRequest(HTTPServerRequest req,
HTTPServerResponse res)
{
if (req.path == "/")
res.writeBody("Hello, World!", "text/plain");
}
// Dependencies fetched, compiled, cached, built against, and
result executed
// in one command:
// $ ./hello.d