DEV Community

Why Javascript of all languages?

Leonardo Teteo on September 03, 2018

Javascript has been the standard language in front-end development to make websites dynamic since ever and now with NodeJs it has been gaining popu...
Collapse
 
seraphicrav profile image
Ravaka Razafimanantsoa • Edited

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 !

Collapse
 
tux0r profile image
tux0r

For me, the main selling point of Javascript is simplicity and boot speed

In that case, you should literally prefer every language that's not Javascript. If only they ran in a browser!

Collapse
 
bgadrian profile image
Adrian B.G.

hate

Collapse
 
seraphicrav profile image
Ravaka Razafimanantsoa • Edited

Could you please elaborate ? I was only comparing Java with Javascript but I am interested in your thoughts.

Thread Thread
 
tux0r profile image
tux0r

Which is a comparison that does not make much sense in the first place.

Thread Thread
 
seraphicrav profile image
Ravaka Razafimanantsoa

Why are you so angry ?

Thread Thread
 
tux0r profile image
tux0r

??

Thread Thread
 
seraphicrav profile image
Ravaka Razafimanantsoa

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.

Thread Thread
 
tux0r profile image
tux0r

Because that's the case? Except Python, probably.

Thread Thread
 
seraphicrav profile image
Ravaka Razafimanantsoa

So if I say that the earth is flat, is it ?

I want arguments.

Thread Thread
 
tux0r profile image
tux0r

Please use benchmarks, they are the best arguments.

Thread Thread
 
seraphicrav profile image
Ravaka Razafimanantsoa • Edited

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.

Thread Thread
 
leoat12 profile image
Leonardo Teteo • Edited

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.

Collapse
 
adam_cyclones profile image
Adam Crockett ๐ŸŒ€ • Edited

WASM that'l run anything in a browser. ๐Ÿคซ

Collapse
 
leoat12 profile image
Leonardo Teteo

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!

Collapse
 
dmfay profile image
Dian Fay

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.

Collapse
 
leoat12 profile image
Leonardo Teteo

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.

Collapse
 
wwhurley profile image
William Hurley

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.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

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.

Collapse
 
leoat12 profile image
Leonardo Teteo

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.

Collapse
 
xngwng profile image
Xing Wang

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.).

Collapse
 
leoat12 profile image
Leonardo Teteo

Yes, this historic side is very important, it was a process that led to this.

Collapse
 
quii profile image
Chris James

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.

Other reason I've seen a lot is performance against languages such as Java and C#.

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.

Collapse
 
leoat12 profile image
Leonardo Teteo

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.

Collapse
 
revskill10 profile image
Truong Hoang Dung

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.

Collapse
 
bgadrian profile image
Adrian B.G.

With all this complexity, the tendency of projects to lead to chaos,
Yes because JS is not suited to build large scale apps. The devs usually don't learn or have a system designer/architect in their team to solve the issues and they will treat the project as a simple small website.

why Javascript has been gaining so much popularity of all languages?
For many reasons obvious, a few of them are the same reasons why Java got popular over C++ 20yrs ago: portability and lower complexity.

Another big one is the resistance to change, if you already know JS from the front end, why not use it for the back end, even if is not the best tool from a technical point of view, it make sense for the devs and from a business view.

Overall you do not need the best tool for the job, only good enough. Ignore the old "dogs" that are horse-blinded for performance reasons and hate nodeJS, the world is lead by money not by ms, and from a business and human perspective nodeJS can solve your company problems.

Collapse
 
adam_cyclones profile image
Adam Crockett ๐ŸŒ€

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.

Collapse
 
tux0r profile image
tux0r

What do you, principally more experienced NodeJS developers, think about this?

Just because you have a hammer (Javascript), not everything is a nail (dynamic website).

Collapse
 
vinceramces profile image
Vince Ramces Oliveros

Description of "One Language fits all" and it was a lie.

Collapse
 
meet_zaveri profile image
Meet Zaveri • Edited

As Eric Elliot says in his fluent 2013 talk, it is "Freedom" that makes JS apart(unique) from the other languages.

Collapse
 
leoat12 profile image
Leonardo Teteo • Edited

Freedom, meaning that you can do whatever you want and face the consequences of it? People must be prepared for that consequences. Like other people said here, for small companies it can be manageable, but for big enterprises the risks can be too big. Many of the "improvements" JavaScript is facing already are standard in many languages for years. JavaScript is not converging to only another language that way?

Collapse
 
thespiciestdev profile image
James Allen

Is assembly to C++ (or even C) as JavaScript is to TypeScript? You could write the former but you want to keep your sanity, right?