News Roundup: Fab, RequireJS, and Node, Node, Node
Exciting stuff this week—a lot of it Node.js-related. Node is reaching a critical mass, and now is a great time to get on board. With that, here’s the news:
RequireJS 0.11.0
It’s no secret that I’m a big fan of RequireJS, the non-blocking, asynchronous dependency manager/build tool for Javascript. Well, with the brand new 0.11.0 release, it’s even better. It’s now totally Caja compliant, so the security should be airtight, and you can now even name a JSON-P source as a dependency (I’m in love with this feature). There are more new goodies, so take a look a the release notes if you’re interested.
Probably the most notable aspect of the new release though, is that the the tool’s creator, James Burke, now feels Require meets the requirements that John Resig outlined for a .require() method in jQuery. Burke is making a strong case for integrating Require with jQuery.
Require was already a great tool, and it keeps getting better with every release. If you haven’t yet looked into it, now is the time to do so.
Understanding Node.js
There’s a growing consensus that Node.js is going to be huge (if it isn’t already). Unfortunately, some of the concepts on which Node is built aren’t the most straightforward (at least not at first glance). If you want to write great Node apps, you really have to get its conceptual underpinnings straight in your head. Fortunately, the Debuggable blog has an excellent post on understanding Node. The post takes a very high level look at what Node does and explains its fundamental concepts (evented programming, queues, etc.) in an extremely accessible fashion. If you’re an old hand at Node, it probably comes off as basic. But if you’ve been struggling to wrap you brain around Node, or just haven’t yet had time to dive in, I highly recommend giving this piece a read-through.
Speaking of Node, Heroku just announced experimental support for Node deployments on their servers. I haven’t looked into this yet, but if it’s as awesome as their Rails & Sinatra hosting, it’s going to be a tremendous resource.
Also, while we’re on the subject of learning Node, the YUI blog just posted the video of Node creator Ryan Dahl’s talk at the most recent Bayjax.
Fab
Okay, more Node stuff. Sue me. Fab is a new web framework for Node, but it’s wholly unlike any of the others that are currently available. Just take a look at Fab’s “Hello, world”:
with ( require( "fab" ) )
( fab )
( listen, 0xFAB )
( /^\/hello/ )
( tmpl )
( "Hello, <%= this %>!" )
( /^\/(\w+)$/ )
( capture.at, 0 )
( "world" )
( 404 );
The first thing everyone notices is all of the parentheses. Still, there’s nothing especially Lisp-y about Fab (at least no more than there is with vanilla Javascript). This example just listens on port 4011 (0xFAB). The regex (( /^\/(\w+)$/ )) is the catch-all route for the application.
There’s a heck of a lot you can learn about functional programming in Javascript by studying how fab works. Check out the slides from Fab’s creator Jed Schmidt’s talk at this year’s JSConf for a thorough introduction to the concepts Fab employs.












