Introducing vibe.d!
F i L
witte2008 at gmail.com
Fri Apr 27 12:40:51 PDT 2012
Sönke Ludwig wrote:
> During the last few months, we have been working on a new
> framework for general I/O and especially for building
> extremely fast web apps. It combines asynchronous I/O with
> core.thread's great fibers to build a convenient, blocking
> API which can handle insane amounts of connections due to
> the low memory and computational overhead.
>
> Some of its key fatures are:
> ...
vibe.d looks great! Looking through the docs, it feels clean and
"hip" like node.js
However, there are a couple refactoring choices I think would
have made it even more "hip", consider the home page example:
import vibe.d;
void handleRequest(HttpServerRequest req,
HttpServerResponse res)
{
res.writeBody("Hello, World!", "text/plain");
}
static this()
{
auto settings = new HttpServerSettings;
settings.port = 8080;
listenHttp(settings, &handleRequest);
}
"vibe.d" as the project name is great, but why have module vibe.d
and not simply vibe? Or, why prefix all the types with
"HttpServer" when you could separate those objects into a new
module and drop the prefix. I think those simple changes would
make an already polished library shine a bit brighter:
import vibe.http;
void handleRequest(Request req, Response res) {
res.writeBody("Hellow, World!", "text/plain");
}
static this() {
auto settings = new Settings;
settings.port = 8080;
listen(settings, &handleRequest);
}
the echo server would look like:
import vibe.tcp;
static this()
{
listen(7, (conn){ conn.write(conn) });
}
Also, it's great to see MongoDB support built in :D, but isn't
there a way to trim down the query object from:
BSON({"name": BSON("Peter")})
to:
BSON({"name":"Peter"})
by writing a generic AssosiativeArrayToBSON function? That way
you could overload MongoDB's find/save/etc functions to accept
arbitrary AAs as queries, which would end up looking a lot
slicker in the docs I think. Plus, through CTFE it's possible
this conversion could happen at both compile-time and run-time:
auto db = new MongoDB;
auto col = db["test.collection"];
foreach (doc; col.ctFind!(["name":"Peter"])) {
...
}
Just some ideas in case you haven't thought of them already :)
Overall vibe.d looks like a fantastic library. Thank you and
Congrats!
More information about the Digitalmars-d-announce
mailing list