Javascript has been the standard language in front-end development to make websites dynamic since ever and now with NodeJs it has been gaining popularity also in back-end development, principally in the open source community. Many projects are come across are made in Javascript nowadays, be it a website written in Angular, React, Vue and other frameworks, applications that uses the power of Electron like the very famous Visual Studio Code and mobile applications that leverage Javascript capacity to be cross-platform. It appears to me that the community is trying to make Javascript an universal language in the development world.
Only in the previous paragraph I already listed at least one reason that Javascript may have become popular among developments: the capacity to be cross-platform between web and mobile. But even when cross-platform is not the goal Javascript it taking space, web servers and APIs using Express, CLIs and other use cases. Other reason I've seen a lot is performance against languages such as Java and C#.
I've been working with web development using Java for almost a year now so I can say with more knowledge that projects can become very complex in some weeks after the start of the development. At least in Java you have many classes, many controllers, many services and a pile of other classes to take care of database communication. With object oriented programming it becomes easy to organize all the business logic in a meaningful way even for someone who is not a programmer, just by taking a look at the name of the classes you can have a idea of the project goals, that's why many project design tools such as UML uses object oriented concepts to connect all the business logic and its entities.
Javascript has been improving, I've seen news that even classes are possible to use in the recent versions, but it is still not something people are using in a daily basis as far as I know. With all this complexity, the tendency of projects to lead to chaos, why Javascript has been gaining so much popularity of all languages? To be frank, Javascript looks crude to me as language, it doesn't give the safety of statically typed languages, Typescript was created because this gap is real. Why build around unsteady basis like this?
Please, don't see this post as rant towards Javascript. I've been learning NodeJS recently and also TypeScript and it is a honest doubt I have since taking all pros and cons the popularity of Javascript in all sectors of development right now the result doesn't add up for me. What do you, principally more experienced NodeJS developers, think about this?
Top comments (32)
Have been a Java developper for 8 years, have been using TypeScript for one year now.
For me, the main selling point of Javascript is simplicity and boot speed. Everything you learned in Object Oriented programming is applicable in Javascript, objects are actually widely used too in Javascript (prototype is a part of Javascript and in 2015 they added class syntactic sugar).
Do not limit yourself, embrace novelty !
It seems I have a lot to learn regarding JavaScript then. Don't worry, I will continue to learn JavaScript, NodeJS and Typescript, which attracts me a lot. It was just to speak out a doubt I had. Thank you for the answer!
It's not crude, it's different. Java's classic object orientation with static types makes up just one way of thinking about a problem space. It has its advantages: well-defined API contracts, clear separation of strata, operational consistency. The other side of that coin is that you have to do more up-front architectural planning, sacrifice flexibility especially on the micro scale, and just plain write a lot of code. For larger organizations with many teams working on the same code base, it's often worth it. For others, it just as often isn't.
JavaScript is a dynamically typed functional/object-oriented hybrid language with a prototypal model of inheritance. This makes it extremely flexible, and allows developers to express complex processes in much smaller volumes of code. However, it's much less formal than something like Java and therefore large projects easily get messy. Again, it works well in some contexts and poorly in others.
TypeScript and so forth are effectively a gamble: if static type checking is taken for granted, can a hybrid language with a prototypal inheritance model compete with classical object-oriented languages on their own turf? It's no accident TS came out of a huge organization like Microsoft rather than a ten-person startup.
Yes, like many things in the development world it depends on the use case, but it seems like Javascript is taking every aspect, there are some projects I've seen on Github that it is astonishing to me how they can keep everything in order with such complexity, one I've seen and I use a lot is Habitica, which is made 56% of Javascript. I even have to take a deeper look in some of these projects to learn how it is structured.
Ok cool. Let us stop there.
For those interested, here is a benchmark comparing the cold boot of serverless functions in different languages. It says, among many things, that Python starts faster than NodeJS which starts faster than Java.
My interest in serverless is one of the reasons I'm learning NodeJS, the cold start is incredibly smaller than Java. I think I read the article you linked or a similar one. Java ecosystem is too large to boot fast, I even think they are making a good job to boot as fast as it is booting right now. The hope right now is Java 9 modules.
I just don't understand you point of view and your answer does not give me more insight.
"Which is a comparison that does not make much sense in the first place" does not explain me anything. What I want to know is why, you think that any language other than Javascript is simpler and boots faster.
Why is JavaScript popular on the server? Because it's capable enough for many (most?) web applications, it's excellent for real-time and I/O bound workloads, it has an enormous community and pool of talent to draw from and several large organizations are engaged in an ongoing competitive effort to make it better.
Javascript is required knowledge for web dev. Even if you use server-side tech like Rails, Django, ASP.NET MVC, etc, you still have to write some Javascript glue sometimes. If you go fully client-side apps, then Javascript plays a large part in your life.
It is easy to get started with JS. You literally just put a script tag in an HTML page and start typing JS in it. But it quickly becomes more complex. React, Vue, Angular, ... ? ES2015 transpile? inline CSS? It grows into a massive knowledge requirement as your app grows.
If you are a fresh team with no other experience, it does not make a lot of sense to want to invest that same level of effort into learning another stack. Especially considering what you had to go through with JS. I see this as the primary motivation for wanting to use JS for everything. And from a business perspective, it might be a savings to avoid investments in other platforms until you absolutely have to.
Also, JS is a standard and its surrounding ecosystem is almost totally open source. Free tools. Modify your own tools. There is no disincentive to try to put JS in every possible place you can think of, even just for fun, regardless of whether it makes any kind of sense. Some people will find these kinds of uses amusing/useful enough to join in with you.
At this point JS is almost a cultural expression among developers rather than a work tool.
You are right, I think my vision is biased because I've seen a lot of open source projects recently and they do use javascript a lot in everything, but when it comes to companies and large scale enterprise applications surveys show that Java is still the way to go. For small projects, Javascript is very easy to start and use, but when it starts to grow, more structured languages may be necessary. That's the conclusion I reach from your post and the comments here. I makes totally sense.
Javascript is wonderful for prototyping ideas, Ruby was very popular for this reason too a while ago. You can quickly make a client-rich web app in just the one language with lots of libraries and tooling (for better or worse) to aid you. Prototyping ideas is a very important trait.
Generally as a product idea matures and stability is required people may tend to refactor parts of systems into more "mature" languages; but not always.
There are plenty of stories of the likes of twitter, soundcloud etc taking this path.
I think it would be nice if performance wasn't talked about so simply :)
A lot of all this stuff is "it depends", performance has nuance. Node is not very good at CPU bound operations; I worked at a place where we re-wrote a service from node to Go for this reason. The performance increase was huge. But we never discounted the fact that Node's simplicity (and the availability of skilled engineers with it) meant we could create the service in the first place very quickly.
Sorry for the simplicity regarding performance, it was my intention to make a quick overview of the reasons I've seen to use Javascript and gather more opinions about it. One of the reasons was indeed performance, principally start time in serverless, which is something I've studied. True, in other use cases NodeJS may not be the best answer, I will probably find out which ones while I progress in the NodeJs world.
NodeJS is nothing without community and its ecosystem. The bad and ugliness of JS will be fixed eventually, but it's impossible without community and ecosystem.
Let me show some love to the JS community.
I think it is all matter of timing and luck, more than the pro and cons of the design of the language itself.
It was the scripting language chose for the web browser, by basically the first popular browser (Mosaic/Netscape).
Rising tide floats all boats.
Once Javascript established as the foothold in the first browser, many websites add it to their website, now all future browser has to support it. As more websites needs Javascript, job market will ask for people who know Javascript. As more people learn Javascript, they want to leverage what they know to build more thing.
The original decision makers for Netscape/Mosaic considered Scheme or TCL also, if they had chose that, we might be asking the same of TCL or Scheme. (ironically, they called the language Javascript to associate themselves with Java, which was becoming the hot language at the the time.).
Yes, this historic side is very important, it was a process that led to this.
Java is verbose as hell, JavaScript is broken and Typescript is one attempt to fix of many. Kotlin and Dart to name a few. It all comes down to companies and what people want to write. If a single language can span both sides of the same coin, even better.