9 responses

  1. PositOrange
    March 31, 2012

    I think that some of the extreme hype regarding Node.js as some sort of magic bullet for scalability is unfortunate because it detracts from the other benefits such as the ability to use one language throughout a project and using the same coding style throughout and the great community around the project. With Coffeescript gaining in popularity and improving some of the rougher and annoying parts of JS, I think more people will be looking at Node.js. That being said, picking and choosing the right tech for the job is important and I wouldn’t automatically pick Node.js for a project without considering if its really needed. But its becoming viable pretty quickly.

  2. maxpert
    March 31, 2012

    You would miss the ease, syntactic sugar, and gems (although ruby is slow). But best of luck!

  3. Tommy Bergeron
    March 31, 2012

    I know that feel! Did exactly the same thing and honestly: I never regretted it!

    Node, once well understood is a total blast I would never go back. Good job on the text by the way hehe

  4. cstivers78
    March 31, 2012

    Try using Coffee-Script in Node (and Browser). Much more elegant language. I posted a gist with a coffee-script based solution:


  5. Frank Luma
    March 31, 2012


  6. guest
    March 31, 2012

    Newbie question:

    How is this “Node” rather than just plain Javascript?

    • Grant Muller
      April 1, 2012

      Actually that’s the beauty of it. Other than the #! interpreter mark at the top, and a few node specific calls to process.argv and process.exit, this is just plain ol’ javascript. From a process standpoint this allows me to write a bunch of simple logic in chrome, firebug or wherever, then when I’m ready move it over to a full-fledged shell script using node.js as my command line intepreter. neat. 

  7. Pete
    April 2, 2012

    Syntax is the most apparent and least interesting part of any given language.  I don’t think this is in particular a problem that shows much about Javascript; the solution given could be transliterated almost line for line into Ruby, Python, Lua, etc.

    I am not quite sure how to phrase it so that I don’t sound like a jerk because I’m genuinely wondering, but is it really syntax and your solution to Project Euler #3 that make you want to put a language you already know in the toolshed?  Personally, I’m trying to increase the number of languages I use on a daily basis.  The strain you get from switching between languages is like muscle cramps after a hard workout:  as your strength and flexibility increase, they go away.  The broader your working toolset of languages is, the easier it is to come up with a different approach to a problem.  A couple of very different takes on the problem, as an illustration:


    If I had to solve this problem at work, I’d go for the short solution.

    factor $1 | sed ‘s/.* //’

    !/usr/bin/awk -f

    Lest the other one get me accused of cheating.

    BEGIN { p = a = ARGV[1]; for(i = 2; a > 1; i++) { while(!(a%i)) { p = i; a /= i } } print p }

    • Grant Muller
      April 3, 2012

      Although I think the act of learning a new syntax and all is a nice workout for your mind, it kind of misses the point. I chose a simple Project Euler problem as a proof-of-concept in writing little shell scripts in javascript, which was probably a bad example, since I intend to use this as a general purpose shell-scripting replacement. 

      I don’t write shell scripts that often. When I do, I would usually turn to ruby. Because I don’t write shell scripts that often, I don’t remember the syntax as well as I might like. If I’ve got ten minutes to write a one-off shell script because I’m on a tight deadline or I’m trying to repair some catastrophe in the real world, I probably don’t want to choose a syntax that requires me to continuously RTFM, wasting valuable time. Since I know javascript, and since node can interpret that for me, it made sense for me to give that a shot and have that in the toolshed for those kinds of scenarios.

      Haskell, Scala, Ruby, Lisp, etc are fun and I like to poke around with them. They’re tools but right now its the difference between a hammer and scratch awl. I can do a helluva lot with the hammer, so I’ll wield it a lot. I don’t get a lot of practice with that scratch awl, so though I might break it out every now and then, I’ll probably focus on bettering my skills with the hammer. 

Leave a Reply




Back to top