by andrewvc · 16y ago · 0 comments
I like async, and I like node. However, for plain jane dynamic web apps, with no real time needs, I see it as being more of pain than using Ruby (or Python, or whatever).
Why? JS syntax kinda sucks for dealing with day to day business logic. Ruby is just more clear and easier to work with.
I think using node.js by default is bad design. It should be isolated to the cases where you need it.
As a JavaScript developer working with node.js (and client side scripts too, of course), I’d like to recommend a couple of related things:
Joose3 — an object system for JavaScript which allows truly classful programming; use it to implement all sorts of meta-programming magic with ease: http://joose.it/ http://openjsan.org/doc/s/sa/samuraijack/Joose/3.011/lib/Joo...
JooseX.CPS — a continuation-passing-style "trait" for Joose classes which helps prevent your asynchronous code from turning into "callback spaghetti": http://joose.it/blog/2010/08/02/asynchronous-aka-non-blockin... http://openjsan.org/doc/s/sa/samuraijack/JooseX/CPS/0.11/lib...
Joose is open source, works with both node.js and in browsers, and there are various ways to install and leverage its libraries, e.g. npm: http://github.com/isaacs/npm
This isn’t an advertisement. I started exploring node.js in early 2010, and my "discovering" Joose was a real boon as I was looking to do some complicated things that seemed daunting when trying to express the concepts in terms of prototypal inheritance.
Not everyone finds it attractive, but I’m always happy to spread the word in hopes that Joose can make someone else’s life and programming projects a little less stressful, which is what it's done for me.
task :default => [:test]
task :test do
ruby "test/unittest.rb"
end
Let's see what that could look like in CoffeeScript, assuming a similar library: task default: ['test']
task 'test', ->
ruby 'test/unittest.rb'
Pretty nice. Running that through the CoffeeScript compiler produces this JavaScript: task({
"default": ['test']
});
task('test', function() {
return ruby('test/unittest.rb');
});