"If two (people) on the same job agree all the time then one is useless. If they disagree all the time, then both are useless." | ||
--Darryl F. Zanuck |
A very common description of Node is this: Node.js allows JavaScript to run on the server. While true, this is also misleading. Node's creators organized and linked powerful C++ libraries in such a way that their efficiency could be harnessed without developers needing to comprehend their complexities. Node abstracts away the complexity of multiuser, simultaneous multithreaded I/O by wrapping that concurrency model into a single-threaded environment that is easy to understand and already well understood by millions of web developers.
When you are working with Node you are ultimately working with C++, a language whose suitability for enterprise-level software development no one would question.
Node's C++ foundation puts lie to claims that Node is not enterprise-ready. These claims confuse what JavaScript's role in the Node stack actually is. The bindings to Redis and other database drivers used regularly in Node programs are C bindings–fast, near the "metal". Node's process bindings (spawn
, exec
, and so on) facilitate a smooth integration of powerful system libraries (such as ImageMagick) with headless browsers and HTTP data streams. With Node, we are able to access the enormously powerful suite of native Unix programs through the ease and comfort of JavaScript. And of course, we can write our own C++ add-ons.
Paraphrasing Professor Keith Devlin's description in Calculus: One of the Most Successful Technologies (https://www.youtube.com/watch?v=8ZLC0egL6pc), these are some features of successful consumer technologies:
It should remove difficulty or drudgery from the process of completing a task.
It should be easy to learn and use.
It should be easier to learn and use than the popular method, if one exists.
Once learned, it can be used without constant expert guidance. A user remains able to remember and/or derive most or all of the rules governing interactions with the technology through time.
It should be possible to use it without knowing how it works.
Hopefully, as you think about the class of problems Node aims to solve, and the form of the solution it provides, the above five features are easily seen in the technology Node represents. Node is fun to learn and use, with a consistent and predictable interface. Importantly, "under the hood" Node runs enormously powerful tools that the developer only needs to understand in terms of their API.
Wonderfully, Node, V8, libuv, and the other libraries composing the Node stack are open sourced, a significant fact that further distinguishes Node from many competitors. Not only can one contribute directly to the core libraries but one can cut and paste code blocks and other routines to use in one's own work. You should see your growth into a better Node developer as a chance to simultaneously become a better C++ programmer.
This is not a primer on C++, leaving you to pursue this study on your own. Don't be intimidated! The C-family of languages is designed using forms and idioms not unlike what you are already used to with JavaScript. For example, if..then
constructs, for
loops, functions, and returning values from functions, even semicolon-terminated lines, are central to JavaScript and regularly used in C++ programming. As a JavaScript developer you should be able to understand the design and goals of the following examples with little effort, and can dip into C++ programming to resolve the meaning of the parts that aren't clear. Extending these examples iteratively is an excellent way to gently enter the world of C++ programming.