Slashdot Mirror


Ask Slashdot: Have You Migrated To Node.js?

A developer maintaining his company's "half-assed LAMP / WordPress stack pipeline for web and web application development" is considering something more scalable that could eventually be migrated into the cloud. Qbertino asks Slashdot: Have you moved from LAMP (PHP) to Node.js for custom product development and if so, what's your advice? What downsides of JS on the server and in Node.js have a real-world effect? Is callback hell really a thing? And what is the state of free and open-source Node products...? Is there any trend inside the Node.js camp on building a platform and CMS product that competes with the PHP camp whilst maintaining a sane architecture, or is it all just a ball of hype with a huge mess of its own growing in the background, Rails-style?
Condensing Qbertino's original submission: he wants to be able to quickly deliver "pretty, working, and half-way reliable products that make us money" -- and to build a durable pipeline. So leave your educated opinions in the comments. What did you experience moving to Node.js?

3 of 341 comments (clear)

  1. It's not that bad, just don't write PHP with JS. by Anonymous Coward · · Score: 5, Informative

    I come from a strong C++/Java background and was drug into the Node/JS world kicking and screaming. It's still not my platform of choice but at least I don't despise it anymore. A few things:

    1. Don't try to write PHP (or C++/Java/etc) with Javascript. You see a lot of people try to force Javascript into their way of programming and that's where a lot of the callback hell comes from. It's an event driven environment, just repeat that over and over.

    2. Take the time to familiarize yourself with ES6/Promises/Rx before you start. Promises vs. Rx is almost a religious discussion but when you get down to it, both do the job. This helps a lot with callback hell.

    3. After you've chanted it's an event driven environment often enough, start chanting everything is a stream.

    3. Use eslint religiously. This will find a lot of the mistakes new programmers make, especially ones coming from other languages.

  2. Re:Have you migrated to qbasic? by dgatwood · · Score: 5, Informative

    See, I don't get all the hate towards JavaScript. From what I've seen, it's a perfectly usable language except for the lack of true classes, and even that flaw can be fairly easily worked around if you're a C programmer who did OO back before it was cool (function pointers).

    What makes client-side JavaScript a nightmare is not the language, but rather the DOM, which is kind of a pain in any language. The biggest difference is that in other languages, most developers never have to deal with the DOM....

    --

    Check out my sci-fi/humor trilogy at PatriotsBooks.

  3. Re:Have you migrated to qbasic? by TheRaven64 · · Score: 5, Informative
    JavaScript has some nice features. It's a pure OO language, it has a simple prototype-based model with differential inheritance, but it also has a lot of ugly corner cases:
    • 'Semicolon insertion' - the semicolon is optional anywhere that the parser can determine that one should be needed. This means that some things are either code blocks or object literals depending on how you line wrap your code.
    • The only integer type is an IEEE double-precision floating point number. You can't represent a 64-bit integer without using a bignum library. Compare this with something like Smalltalk (an ancestor of JavaScript, with Self as the direct parent), where integers are either SmallInt or BigInt objects and are transparently promoted when they are no longer small enough to be hidden inside a pointer.
    • Javascript has operators that work on objects, but no operator overloading. object + string, string + number, number + array are all well-defined in JavaScript. They won't throw type exceptions, but they will produce really unexpected results.
    • The semantics of 'new' and 'this' binding are really weird. Any JavaScript function (which is actually a closure) can be either called directly or as an argument to the new operator. In the first case, the hidden 'this' parameter is the closure object. In the latter case, the 'this' argument is a new object whose prototype is set to a field in the function object. There are a few other subtleties.
    • JavaScript is a pure imperative language. The execution model is that code is run as soon as it is read, which makes quick startup difficult. V8 cheats and just does brace matching when it encounters a function and lazily parses the function when it's first called, but other languages that have a more explicit declarative structure get this for free and have cleaner entry points (there's no equivalent of 'main()' in JavaScript).

    That said, it's not significantly worse or better than most other mainstream programming languages.

    --
    I am TheRaven on Soylent News