DEV Community

Walker Harrison
Walker Harrison

Posted on

Javascript's Persistent Popularity: No one seems to particularly enjoy the language, but everyone is using it

Stack Overflow released the results of their annual developer survey last week, and for the fifth consecutive year Javascript checked in as the most popular language. This year, 62.5% of developers reported using Javascript, significantly more than the next non-query language, Java (39.7%).

Javascript is not only popular, but increasingly so, up from 54% in 2015. Its five-year trend, as well as those of other prominent languages can be seen in this graph:

There are a few straightforward reasons for JavaScript's popularity. The language is simple enough to pick up quickly, flexible enough to be used on the client and server side, and comes built into your web browser. As Jeff Atwood, Stack Overflow's cofounder, wrote about a decade ago in the blog that would become his website: "any application that can be written in JavaScript, will eventually be written in JavaScript."

We shouldn't rush to crown JavaScript the greatest language to grace our hard drives though. The survey's respondents are overwhelmingly web developers, making their preference for JavaScript somewhat of a foregone conclusion. Plus, being the most prevalent language doesn't map directly to being the most enjoyable or profitable.

In fact, 40% of Javascript users didn't report the desire to keep working in the language, compared to just 27% of Rust users and 33% of those who use Smalltalk (a niche language that you most likely won't find in a bootcamp curriculum). And while Clojure developers report average salaries of nearly $80,000, JavaScript devs are much closer to the middle of the pack at about $55,000.

None of this comes as much of a surprise. Economics 101 tells us that JavaScript's ubiquity makes it a skill unlikely to demand top-level wages, and the language's warts have long been comedic fodder in the dev community:

1 + 2
👉 3

1 + "2"
👉 "12"

1 - "2"
👉 -1

1 + 2 + "3"
👉 "33"

"1" + 2 - "3"
👉 9

1 - 2 + "3"
👉 "-13"

1 - 2 - "3"
👉 -4

JavaScript

— The Practical Dev (@thepracticaldev ) March 20, 2017

Of course, the very code that I used to embed that tweet relies on Javascript. So while we may poke fun at the language, the majority of us will probably still be using it by this time next year, when Stack Overflow releases its 2018 results.

Top comments (20)

Collapse
 
jvanbruegge profile image
Jan van Brügge

Im one of the people that cant understand the javascript hype. It's an inheritly weak language with major problems. I come from C++ and javascript is a massive downstep from that. No compiler helping you catch your errors (no, unit test are not an alternative, a type system can prevent whole categories of errors plus semantic completion). Currently I enjoy writing my backend code in Haskell. For the frontend I use typescript which fixes a lot of javascripts flaws but still suffers from leaky abstractions
Same goes for nodejs. Why would you trust you business logic to a slow and unsafe environment? An yes even with V8 JS is slow. You dont want to write your backend in C because of null pointers, then why do you use a glorified text file to run it?

Collapse
 
dubyabrian profile image
W. Brian Gourlie

I have a theory:

When people start learning to program, they develop a strong favorable bias toward whatever language they've learned. I think javascript just-so-happens to be the first (only?) language a lot of people learn, so naturally they favor it.

I have a feeling if you sampled a large group of polyglot programmers, javascript would not fare nearly as well.

Collapse
 
justgage profile image
Gage

I would say this is true for me. JavaScript was effectively my second language and I thought first class functions were the coolest thing ever, along with object literal notation. It got me into functional programming which I'll be internally indebted. However the number of issues caused by it are unparalleled (except maybe by our Ruby on Rails project).

Naturally as I learned more and more languages I started to realize that while I liked the way I wrote JavaScript I hated everyone else's for the most part. I also hated my own after about 3 months generally.

Elm is like heaven sent for me. You compile it and it works. That just doesn't happen in js land. More like push it to production and have everyone find the errors. Plus the helpful compiler messages, autocompletion, Auto formatting, and enforced SemVer make it just so plesent to work in.

Collapse
 
spion profile image
Gorgi Kosev

The reason is flexibility. It has a wide range of utility, from prototyping quick and dirty tiny programs to writing sensibly performant, fairly strictly typechecked production code. Nobody seems to mention the real flaws though: lack of threading (debateable) and large ints.

It's an inheritly weak language with major problems. I come from C++ and javascript is a massive downstep from that.

The language is complex, riddled with undefined behaviour and it takes years of expertise to be able to comfortably work with any non-trivial code base. And it didn't even have lambdas until recently. JavaScript? You can write a function that returns a class. Hows that for flexibility? You can also write a function that automatically adds promise-based methods from a class/module containing callback based methods: bluebirdjs.com/docs/api/promise.pr... and have THAT be optimised by the JIT and run fast. How's that for power?

No compiler helping you catch your errors

Try two compilers: Flowtype and TypeScript. With advanced features such as union/intersection types, flow analysis, non-nullable types, mapped types, etc - both supporting a huge subset of the mind-bending flexibility.

An yes even with V8 JS is slow

Not even close to slow. Certainly blows almost every other dynamic language away (except maybe sbcl and clojure+jvm). With C and C++, null pointers are the least of your worries.

Seriously, I would take a backend written in node than one in C++ any day.

(I'm still waiting for a language to match TypeScript's flexibility when it comes to native record types. Maybe PureScript one day. Or if Haskellers get their act together and add proper row-polymorphic records, Or OCaml/ReasonML objects)

Collapse
 
jvanbruegge profile image
Jan van Brügge

I was talking about Javascript, not Typescript. Those are different languages. I write all my fronzend code in Typescript too, because it has a very nice type system. But it has other flaws. E.g. always infering tuples as sum typed array.
I also would not write a Backend in C++ but I would like it more than a Javascript backend.
And yes JS is the fastest of the scripting languages, but if you achieve 10x speedup with something that was 100x slower, it is still slow.
Also is Javascript horrible on a multi core CPU as it cant use it fully.

Thread Thread
 
spion profile image
Gorgi Kosev

10x is the worst case - you would typically get around 2x-3x worse performance compared with most compiled languages. See for example benchmarksgame.alioth.debian.org/u... - and thats with 4 cores vs 1 core for most of the programs. When limited to single core the difference is even smaller.

Collapse
 
justgage profile image
Gage

Oh man you should try Elm if you have a Haskell backed. Typescript might be nice for the stuff that's not supported in Elm yet though. The type system makes a world of difference, it's crazy.

Collapse
 
jvanbruegge profile image
Jan van Brügge

Elm is not a good language. You are at the mercy of it's creators because they decide how your code should work. Elm is simply not a general purpose language.
I want to try Purescript one day though. I looks like Haskell for the Browser

Thread Thread
 
justgage profile image
Gage

Elm only runs in the browser and is only really made for front end development. However just replacing most of your JavaScript is still very useful to me. I feel that it's restrictions are mostly caused by it's purity. It can't actually do any side effects so it has to have many pure logic functions that the runtime calls. All language creators decide how your code should work.

At it's current state it can't save you 100% from JavaScript but it can do about 95% (for the typical web app). If I can say that 95% of my code is beautiful and runtime error free I feel like that's a pretty awesome deal.

PureScript could be a good option if you already know Haskell. You do miss out on the enforced SemVer and perhaps more developed libraries but those are probably just a matter of time. It might be a better fit for you.

Thread Thread
 
jvanbruegge profile image
Jan van Brügge

What I mean is that Elm is too limiting. You are forced to TEA, which is a lot of boilerplate and you cannot try your own ideas

Collapse
 
geoff profile image
Geoff Davis

I would hesitate to say "no one" enjoys Javascript. I personally love it, but perhaps I'm biased because I too am a web developer, and aside from a 100-level C++ course in college, Javascript was my first and remains best programming language that I use.

Collapse
 
lluismf profile image
Lluís Josep Martínez • Edited

A short example of why I hate JS so much.
Recently I concatenated two strings in Java with the || operator (I write SQL often and got confused) and I got a compiler error immediately.

The same in JS, even at runtime it doesn't throw an error, it simply converts the second string to an empty string. WTF??????

Try it: alert("Hello" || " World")

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
lluismf profile image
Lluís Josep Martínez

As I said "I write SQL often and got confused" and JS instead of complaining simply does "something". Event if it doesn't make any sense like in this case.

Collapse
 
pak_lebah profile image
Mr Bee

The one and only reason why Javascript is so popular is simply because there's no other alternative languages that's allowed to run in a browser. We have no other options. So, like it or not, if we want to write front-end web applications, we HAVE TO learn and use Javascript. Period. That's the context of Jeff Atwood's quote above.

It's not relevant whether we like it or hate it, whether it is ugly or beautiful, whether it is fast or slow, etc… all of them are irrelevant. Even this Stack Overflow's survey is irrelevant. We still have to use it, as is, no matter what. That's why the planned web assembly is very important. We all should support it. It will enable other languages to be used for front-end web development.

After other languages are allowed to be used in a browser, then we're talking. Before that, there's no point defending or attacking Javascript. It's useless. :)

Collapse
 
remojansen profile image
Remo H. Jansen

I learned (in order) C, C++, Java, C#. I liked C# and I used it for many years but then I started to work with JavaScript, it was painful but there was something about it that made it extremely interesting for me. I missed things like the type safety but I also found myself enjoying working with JavaScript a lot.

I started to wonder why it is so popular. My own personal conclusion is that it is so popular because it is an extremely flexible programming language. The JavaScript flexibility is also its weakest point because it can be used for great good or great evil. The best advice I can give to a JS developer is: "With great power comes great responsibility".

Collapse
 
v_vindemiatrix profile image
Vega Vindemiatrix

I like JavaScript. It has it's warts which are easily avoided. I am a long time developer and I've worked in languages that were better designed. I am actually new to JavaScript. With Node on the backend, I've never been more productive.

Collapse
 
damcosset profile image
Damien Cosset

Whenever I read about something about languages in programming, I always remember this quote from Bjarne Stroustrup :

There are only two kinds of languages: the ones people complain about and the ones nobody uses.

Collapse
 
diegofu profile image
Diego Fuentes

What are you talking about? Most of people i know working with JS they are really happy with JS

Collapse
 
oscarolar profile image
Oscar Alcala

I don't hate JavaScript, I don't love it either, but that feeling when you move a feature you had written in JS to backend it just feels gooooooood....