background preloader

Blog posts

Facebook Twitter

Javascript and Node.js last trends « Le Gelblog. Callbacks are polluting your code. I have been hacking on a project in Node.js/Express.js for some time now.

Callbacks are polluting your code

I am really impressed by how fast it is to code and prototype in Node, not much gets in your way. However, there is one thing I am still struggling with, the callback model of Node.js applications. It is not that it is conceptually hard to understand or use, but i feel that it keeps me from writing clean code. Let’s imagine that we are writing a small nonsense program. The program receives a post, create some variable x, if some condition is true we call an async method to get some result and assign it to x.result. App.post(‘/someurl’, function(req, res) {var x = {..}if (some contidion) { someOperation(function(err, result)) { x.result = result x.save(function(err, result) { if (err) next(err) res.redirect(url) }) })} else { x.save(function(err, result) { if (err) next(err) res.redirect(‘/’) }} (Edit: To clarify, both someOperation and save is doing some kind of I/O) So is this clean code? Why You Should Pay Attention to Node.Js. Meet the Next Big Programing Star - Node.js. The secrets of Node's success.

In the short time since its initial release in late 2009, Node.js has captured the interest of thousands of experienced developers, grown a package manager and a corpus of interesting modules and applications, and even spawned a number of startups.

The secrets of Node's success

What is it about this technology that makes it interesting to developers? And why has it succeeded while other server-side JavaScript implementations linger in obscurity or fail altogether? The key factors are performance, timing, and focusing on a real problem that wasn’t easily solved with other server-side dynamic languages. Browser wars and JavaScript performance In the early 2000s, AJAX web development was coming into its own and placing increasing demands on browsers’ JavaScript engines.

As JavaScript libraries and websites became more complex and users started to notice poor performance in their browsers, browser developers started to focus seriously on their JavaScript engines. Save 50% – JavaScript Ebooks and Videos Evented I/O. Node.js is Important. An Introduction - PavingWays. Once in a while you come across a new technology and are just blown away by it.

Node.js is Important. An Introduction - PavingWays

You feel that something like this should have been around much earlier and that it is (gonna be) a significant milestone, not just in your own live as a developer but in general. The last time this happened to me was when I dug a bit deeper into a project called node.js or just “node” as the binary is called. In case you have not heard about this don’t worry. However, if you are a developer, especially if you are working with JavaScript, then you should be concerned and maybe check your news sources, because it is a couple of months old already and it is drawing a lot of attention lately! If you’re not a developer this might get a bit techy from here, but maybe you get something out of it after all… What is node.js?

Node.js itself is a program that will have to be compiled and installed on your machine. What is Special about node.js? A Practical Example: The Web Server Each of these threads uses memory.