Skip to content

Instantly share code, notes, and snippets.

@psobot
Forked from wolever/so-you-want-to-use-node.rst
Created February 27, 2013 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psobot/5049928 to your computer and use it in GitHub Desktop.
Save psobot/5049928 to your computer and use it in GitHub Desktop.

So you want to use Node.js…

Current status: incomplete draft.

Speed

  • Computation: V8 very fast; significantly faster than most interpreted languages. The one very big exception is PyPy, which is in the same ballpark [citation needed]. Additionally, tools like Cython can be used to write Python-esque code that is compiled to C.
  • HTTP: Node.js is very good at large numbers of low-latency HTTP requests. Python + gevent + uWSGI can match and even exceed the throughput, response time, and error rate of Node.js.

"Non-blocking"

  • When discussing the "non-blocking" nature of JavaScript, there are two important things to remember:

    1. JavaScript is not unique in supporting non-blocking operations — they can be done in every modern language. JavaScript is unique because its standard library makes it easy to write non-blocking code (as opposed to most languages, where writing blocking code is easier).
    2. Non-blocking code does not necessarily need to use callbacks. For example, this Python code will perform a non-blocking HTTP request (assuming gevent is being used):

      slow_page = requets.get("http://httpbin.org/delay/10")
      print "page content:", slow_page.read()

Language

  • Note: the points here are somewhat subjective, and reasonable people could sensibly disagree with the conclusions I draw. But I believe the points are important to consider, regardless of where or not my conclusions are "correct".
  • JavaScript was designed in 10 days, and has had very little opportunity to evolve since then, as historically changes to the language would require multiple vendors to update their browsers, then push those updates to their users. It would be hard to argue that it is a "better" language overall than other languages, who's creators were afforded the time to develop a cohesive design, and who's implementations have had more opportunity to evolve over time.

  • Node.js is young. I'm constantly impressed by the quality of Node.js as a software package: the documentation is good, the various components are well and sensibly designed, and in general it "feels" like a very high-quality piece of software. However, in my opinion, there is absolutely no substitute for "experience", and node.js has only been around since 2009 [citation needed].
  • The libraries available are also young.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment