- Provide a simple scripting language "inspired on" Java to control embedded Java applets in web pages.
- A simple scripting language to control forms.
As you can see the initial motivation WAS NOT TO create a complete and powerful language to develop WEB CLIENT APPLICATIONS.
The monothread asynchronous programming is more performant than a thread based
But the real facts do not agree, take a look Paul Tyma experiments, my own insights or the famous Tech Empower benchmarks, take a look how the venerable raw Java servlet blocking threads in I/O is performing, and the position of async I/O Java alternatives, of course Node is even in a lower position.
The optional generics Java type system is not an evil invent to make the life of Java developers more sad, is a tool to make your code more robust, the verbosity cost is backed with a better code, any Java developer understands that "List<User> hello" is a list of User (readability) and only can contain User objects (robust) in spite of the stupid variable name, is it bad?
Can you make big web applications in Node? Yes of course, everything is possible with effort and discipline (in weak typed languages the discipline must be "military" even more strict than a explicitly typed one), but in the long term a dynamic weak typed language becomes a nightmare in projects with a lot of code, even in projects with a single developer (is my experience).
The problem of argumentation based on inferiority complex
This is an example of the art of converting the limitation on feature, in spite of I'm a Java guy for many years (and a C++ guy before), Java marketing was not honest.
A Node instance has only one working thread, no concurrency problems, on the other hand, end developers are forced to execute ALL business logic of ALL concurrent users in the same single thread. This introduce a severe limitation, the problem of "CPU bound applications", your logic business must be very simple and quick otherwise all users will be stalled.
Related to the previous limitation, do you know the anecdote "Why npm's progress bar slows down install time by ~20%". The explanation is simple, the progress bar updating is time consuming and is executed in the main thread instead of starting a new thread. I'm sure it will be fixed maybe executing the log operation in an extension coded in C/C++ in a different thread or similar. This makes me think, are we in 1970? Are we coding on Windows 3.1/95 (the later with a crappy not preemptive thread system)?
In practice any Node application is multithread because blocking I/O operations are executed through a thread pool, whether the thread context switching is time costly, Node has the SAME problem that a thread per request pool.
Is Java the best language OOP/functional of the world? Of course is NOT, in the OOP space I'm sure most people agree with me that Scala, Kotlin, Ceylon, typed Groovy or C# are SUPERIOR languages, no problem, and in no way is the best functional language.
"The language is not important, the developer is"
- A good surgeon is a good surgeon in a shelter tent and in a conventional operating room of a modern hospital. Try to ask him/her what is the best place for surgery...
- Can you do surgery with a kitchen knife? Yes you can but I'm sure you prefer a scalpel.
- Do you think a veterinary surgeon is appropriated to do surgery to humans?
The myth of complexity of concurrence management in "conventional" request-thread web apps
An explicit type system is not only to reduce the number of tests
Yes you know how useful is a good type system, if you do something wrong usually some other place is broken and the compiler advises you with no need of executing tests.
However an explicit type system provides more very important benefits:
- Readability: read the code of a Java class from a decent open source product, I'm sure you're going to understand the function of the class just reading the types.
- Robust code: MyClass obj only can reference MyClass objects or inherited from, List<MyClass> list is a list and only can contain objects of MyClass or inherited (a final class is also possible).
- Reliable code navigation: any decent Java IDE offers a "Find Usages" ("References" in Eclipse) feature, if you use this feature selecting "any" element of your code, the IDE is going to show with precision all uses of this element (an attribute, param, local variable, method, constructor, class name etc).
- Reliable code refactoring: any decent Java IDE offers many options for easy and secure refactoring for instance name changing (the simpler case, IDEs offer more complex refactoring options). Brutal refactorings can be performed with almost no risk.
Paradigms, paradigms, paradigms
In the end of the day the important characteristic of your preferred language is the paradigms supported, for instance, structured (ex. C), OOP, OOP+functional (Java, Scala...), pure functional (Lisp, Haskell, Closure...).
In Node/JS you can do OOP, but the approach is tedious and cumbersome.
I'm not kidding, take a look this C like code of Mozilla based products (for instance FireFox).
The myth of inheritance abuse
Some people say that "people" usually abuse using inheritance, one reason for bashing OOP (the typical all or nothing argument, bad argument in my opinion).
I don't agree, in the real world is the contrary, many people inherits ONLY when there is no other option (when the API being used provides an abstract class or interface to implement) but rarely you are seeing fully user defined inheritance trees not forced by the frameworks. Of course this is personal vision and isn't scientifically backed.
Many people ignore how to model a class system including inheritance, encapsulation and polymorphism when appropriated, others maybe because are following the mantra of some "gurus" saying "the inheritance is bad".
A long time ago was OOP became popular many people abuse of inheritance trying to fit too many things in the same class tree, for instance a class User inherited with visual code, persistent code, networking etc. Fortunately that time is gone, however some people today invites to back to this old crazy approach because they don't like the modern layering/services approaches (and usually is the same people saying the inheritance is bad).
Fortunately good OOP developers use the inheritance (the complete OOP features in general) when needed.
Are you able to figure out?
- A Big Data tool made in Node.js:
Hadoop, HBase, Spark, Storm, Kafka, Cassandra, Kubernetes, docker? Most of Big Data tools are made in Java or a similar JVM lang (docker and Kubernetes are Go).
- Replacing Java Android core on top of C++ by Node.js
- A desktop application in Node.js
Has Node.js a reasonable place in the World?
Yes course, Node is useful for conventional web sites with small and relatively simple business code.
Oh yes some important parts of PayPal are built with Node, almost the public web site, Right, OK, however PayPal is a relatively easy service, yes really, PayPal is far far away of the enormous complexity of the Google, Amazon or Apple ecosystems. I remember the article about the "competition" of the options, Java and Node, for replacing the old C++ based tech of PayPal, I'm sure you know Node won.
In my opinion is quicker to make a simple spaghetti than a solid Java version, and as far I remember the Java developers tried to include every Java framework invented in SpringSource and GitHub (the competition was to make a quick prototype of a service, not a production service) and imported also the kitchen sink. Yes Node is fine in the short term, the LONG term is different... remember the case of Twitter and Ruby, I respect Ruby, Twitter is as is thanks to the flexibility of Ruby in the beginning before becoming the current monster, by the way, today based mainly on Java.