DEV Community

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

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.