Asynchronous I/O that doesn’t get in your way, written in D
vibed.org
vibed.org
I'd like to hear an unbiased opinion of whether D, assuming the proper docs were available, could replace the C++ code in V8, and if not, what exactly is holding it back?
the size and the complexity of V8 codebase.
> It seems like C++ programmers openly admit that D is better than C++ in many ways.
Anecdotally, I've not seen this. The vibe I've picked up on over the years seems to be that D is and was always seen as a cleaner, but slightly less powerful, C++ with a lot of potential... but now C++ standardisation has accelerated, there's just much more comfort amongst C++ devs that the language looking forward is good. C++ is almost as old as C and evolving faster than ever. If anything though, Rust seems to be the serious topic of choice atm.
There are also two other recent languages designed to replace niches of C++: Go in latency-sensitive, real time systems, and Rust in systems programming. Rust is quite interesting though, since it introduces many data-safety concepts from function programming into an imperative language.
Here's one of the projects written for Facebook by Walter Bright: https://github.com/facebook/warp
https://www.sociomantic.com/dunnhumby-acquires-sociomantic/
that uses 100% D to drive its trading software:
So that's what this is.
They definetly help writing async code.
One day one will never have to write callbacks or promises ever again.
ES6 comes with a lot of new features which will make JS a very different language (classes,guards,annotations...).Things are starting to get very interesting in js land.
There was a talk on dconf 2013 about vibe: http://dconf.org/2013/talks/panteleev.html Notice the slides and video links. It focuses on web development, but you'll get some insight into vibe.d that's valid for TCP too.
http://vibed.org/features#fibers
It still doesn't go into full detail, though, and a dedicated article would probably be worthwhile to write.
When using poll or select kernel functions, your thread "yields" and allows other processes to do some work while your process waits for i/o data. Fibers work the same way but the waiting happens within your process.
Basically, when all fibers are waiting, there's going to be events in the kernel (using epoll or iocp) with the associated fiber pointer to wake it up when something comes up. The fiber (aka task) is called with Fiber.call() when there's news and automatically restores its stack and context, but maybe it has more data in the circular buffer or the manual event you were waiting for was triggered, so the routine can go forward (otherwise, Fiber.yield() is called again and waits for an event from the kernel).
This allows the code to stay linear somewhat. Low-level buffers are all meant to yield when data is not available. Every time a new connection happens, a new fiber is created, same goes when you call runTask.