Real-world scenarios
I'm closing this tutorial with a few examples which hopefully demonstrate that λanguage could be a better language than EcmaScript 5. I know, ES6 is just around the corner, but I don't think it's reasonable to expect widespread support in the next N years — for the time being, our choices are to either write a successful browser which provides an alternative to JavaScript (probability zero) or to compile a better language to JavaScript (success chance: 100%, if you're not a fast as hell monkey).
catDir(pathname) — a function that recursively walks a directory tree and prints the content of every file, except for files starting with a dot.
copyTreeSeq(srcdir, destdir) — a function that recursively copies a directory tree.
copyTree(srcdir, destdir) — the parallel version of the directory copy function. This is much faster because it copies multiple files at once.
In fairness to Node — where I'm writing a
parallelEach
abstraction and drop error handling in a (failed) attempt to make the plain NodeJS code look as good as possible.Exceptions — we show a simple exception system which works across asynchronous calls.