Why I love Node.js
medium.com
medium.com
I'm not simply preferring JS out of spite.
Eventually, I found my rhythm and I now really like node (it's been three years). It has a lot to do with picking packages that are stable, or at least have responsible leadership, and a modicum of documentation. You get used to minimizing arrow code, and you learn to pass errors until you run into that one obscure darned library that throws them (or leaks them) and you have to write a bunch of stuff to seal it up.
The deployment system runs great, and I really like writing tiny to medium sized worker applications, parsers, scrapers, and web services with node. I find running node in production to be a bit of a chore compared to Python, PHP, and Java- but like all things JS it's evolving and I'm still learning.
We developed some applications in Node, it is a headache to maintain an application that uses an SQL database (e.g: MySQL) because the code for executing a transaction involving several queries is unreadable afterwards. We use the module async to have some kind of readability but there are many implicits where small errors are natural to occur.
On the positive side, I found some specific modules in the cryptocurrency space that are not available in other programming languages. This is why we are playing right now with Trireme and Edge.js to use Node modules from Java or .NET.
Due to Node's evented architecture, you should be executing all the transaction code in ONE sql query -- otherwise the transaction can be interleaved with other queries!
Yes, that is an additional issue that I suppressed for my comment trying to narrow the criticism to executing several SQL queries in a readable and maintainable way.
I will not expand on how we solved that specific issue, just say that the transaction in question is fired by external events that can't be fired until a previous one finished.
But, following your suggestion about executing all the transactions in one SQL query, how do you do this without using a store procedure? Because we were thinking in using store procedures but we couldn't implement all the logic inside the transaction with a SP. This is where other languages solve the problem but I couldn't find a concrete solution in Node, so any suggestions will be very appreciated.
So that solved it for me!
(If you're just saying "other unrelated queries could happen between opening the transaction and closing it," well, yes, but that's true of any web application, whether it uses threads or events.)
See here: http://www.2ality.com/2016/01/ecmascript-2016.html
async helps, but when doing a series of operations with dependencies and shared data between steps it can lead to headaches. It took me quite a bit of time before I could think about these operations in a way that was a better fit for an event driven model, and once my mind set changed, things felt simpler.
i've had success recently moving complicated multiple step operations into their own functions. If you follow the callback/error conventions this can be much easier to debug, and you can add your own error handling at each step.
JS is a fine choice for some things. It wouldn't be my preference, but you don't have to make decisions based on my preferences.
...and I've read quite a few.
But as far as providing a nice nonblocking event loop, and a consistent ecosystem built around that event loop, it's pretty neat.
Can you explain what this has to do with node.js? I've done server-side DOM manipulation for years, in both .NET and Python.
We must live on different planets. Our eng team and CI tool needs to run npm install multiple times to coerce this lumbering beast into writing all of our requirements into a directory.
Every time it unreliably installs my dependencies as specified (after declaring exact versions required in my package.json) I scream into the void "you had one job!". It's a frequent cause of frustration for me despite providing access to a wonderfully colorful library of software.
Availability of packages on npm and in the larger JS ecosystem is at an all time high and yes, JS as a language seems to be doing well, but npm is, in my opinion, in dire need of some tlc.
Declaring exact versions in your package.json doesn't make installs consistent. An example:
A's package.json says A needs exactly B version 1.2.0
B's package.json says B needs C version 2 or newer
C can be any version.
shrinkwrap will help you with this. It's better in npm v3 (install updates shrinkwrap by default)Maybe npm is broken and everyone is either just apologizing for it or complaining instead of fixing it (myself included).
Recently I ran into issues with npm global, Jenkins, and Windows Server and I was ready to burn the building down. I give npm a share of the blame, but not all, but the major issue was where npm global installs tried to install when run in Jenkins as a service.
Mostly cause the enterprise love to support legacy software from 5 years ago (your nice webapp won't work that fast on IE8) and requires minimal support for the next 5 to 8 years.
Web Development future looks fragile IMHO.
Netflix has also blogged about similar experiences.
Walmart blogged about how they rewrote their site in Node.js and was able to handle traffic on Black Friday way better than with previous systems.
PayPal themselves wrote about rewriting the account dashboard in Node and how it improved things.
This isn't snake oil or a PR movement. These are real companies using Node.js to make their businesses better.
Uber talks about how their whole infrastructure is built on Node.js
IBM bought Strongloop, self proclaimed "The Node.js Company".
>how it improved things.
> how performance was improved and how much faster they can work.
Do a full rewrite of some ten years old software in any language and it's very likely to be faster. Architecture and software engineering made it faster, not Node. Had they used brainfuck and gotten better perfs, would you have praised brainfuck?
not negating the power of node.js, but if you google enough you can see success stories of migrating from any to any other language, including https://blog.twitter.com/2011/twitter-search-is-now-3x-faste...
When talking specifically about NodeJs, in at least one of the cases you mention, there is a lot of skepticism about their experience, and barring a few champions of the faith, high profile Node uses would be rewritten into something else.