JavaScript it's a cancer of modern software development industry
💥 DISCLAMER
1. This article is about JavaScript - the language happen to become a runtime for many types of applications.
2. TypeScript, CoffeeScript, *Script have nothing to do with JS, this post is not about it.
3. As many of you I'm also a JavaScript developer. I'm not addressing to anyone personally, the post below is just my opinion about technology
4. If you're happy with any technology and it helps to archive the business goals - I can be only happy for that!
Big claim, isn't it? Well, I'm sure I have a right to say that. I've been using suffering from JavaScript in last 10+ years. Really, I can't remember anything good about this shit language since I started to make money on programming being freelancer. I'm not mean, I just had enough. And please, don't take this article personally, you're not a programming language you use.
I'm a normal developer.
It means I'm not genius and I can't and wouldn't keep whole program code and it's complicated flow and branching in my head. I'd rather delegate this boring work to computer and focus on business logic as much as I can. I'm certain, there are about 2.5 really good developers who can write good code in javascript. But probably they don't as they are busy talking on conferences ¯_(ツ)_/¯
You cannot avoid JS
Yes, you can try but you won't be able to. As a cancer it's being integrated in everything - web, backend, databases, mobile and embedded systems.
On frontend we don't really have any option - js ended up as the only tool for programming in your browser(I don't count dart, it's dead as virtual machine). It's far from perfection and that's why ecosystem created hundreds of different languages on top of it - coffeescript, typescript, etc.. They are actually transpiling to javascript. Even new versions of JS - ECMA6 still needs to be transpiled
Again, due historical reasons browsers don't have other options, suck it up, bite your tongue and write frontend. I know it's a hard work, thanks to people who doing that.
JS is cool on backend too
:facepalm:
I hear that all the time, especially from newbie developers. They're claiming that JS is so simple to use so even backend can benifit.
There are dozens of tools have been created for backend - JVM/Java, RubyOnRails, Python and, I'm sorry, PHP.
So why do they think we deserve one more creature in our crowded backend zoo?
I'd like to go through most popular answers I've heard
JS is fast!
Sorry, comparing to what? How do you measure? I'm not surprised anymore when mature JS developers have never heard of costs of context switching, for example. Or maybe one heard about new mutlithreading in javascript? Oh c'mon you serious?
JS is modern language
Oh well. I want to share pain with you.
I'm sure you have heard about JS6, along with cool systax stuff they finally brought in classic datatypes - Map & Set. I hope dear reader know these are very basic data structures known to any developers(even to JS ones, I hope). I was really happy that finally I could use innovations dated back to 1970
But here is a catch. Being so-so developer I expect collections to be iteratable same as Arrays in javascript, not a bit deal, isn't?
You easily can do [1, 2, 3, 4].map(i => i*10)
because it's so normal nowadays, and, of course, JS clamed to be functional. But, apparently JS "architectors" don't think so. Althogh Set
has forEach method but doesn't have map
, filter
, reduce
, etc...
I mean, WHY?! What held developers from doing that?
Same with Map
- it's simply not possible to map via key
or entries
even forEach
works fine. But JS community doesn't care, it's okay to write another leftpad or money-patch global objects(or classes? Or functions?). It's even interesting! Writing more code it's always fun, isn't it? You can find more amusing things in "javascript vs logic" post.
Type system
I was told that types slow down development. And I'm absolutely agree, if you write Hello World every day JS is hell faster to use. But sorry, I'm writing production code for medium and big sized applications, which are business critical.
They funny thing is while application is growing it increases amount of errors and tests for JS, while for staticly-typed languages(hello JVM) code maintance complexity stays about the same. It takes time and experience for JS guys to understand that, and when they finally open eyes shit started to happen. They are pulling TypeScript and flowjs to make code SAFER, basically trying to make remove script part from JavaScript. It always amuses me
Tests
One claims that JS is safe if you write tests. It's true, but why whould you write tests if compiller can prevent developer from obvilius mistakes? I mean, why? Why do you need to check input arguments for type(say, MongoId as object or string) if you expect only one type?
I'm sure it's easier to write id: MongoId
in the contract rather that cover that scenario in the dozens of tests(and still it will leak some usecases)
I love reckless approach of some JS developers - we have tests covered that - they say. Often I don't have tests I don't need - compiller won't allow me to run something which doesn't work
Again, I see zero reasons why you would run broken code, you should not be able to!!
JS is envolving all the time
Actully it's other way around. Because of the low learning curve we're having a lot of shit code outthere(same as PHP). Honestly it looks like there is a rally of producing another shit-framework.
While JS devs are bragging about production deployment of all-shinny-new library released yesterday world is shocking observing that. Why so? It might sound a bit conservative but production code supposed to work.
It's very easy to write code in JS
Yes, it's always easy to write code, but don't you write Programms and Applications? It's not that simple, and, if tool doesn't put constrains on you it's very difficult to keep consistency.
Think about writing code on the sheet of paper? It's very simple but never easy
So what?
If you're frontend developer - accept it, suffer and do your job. It's hard but very important.
If you're JS backend developer - stop bragging about that. It's not fine. Open your eyes as look around, world of programming is beatuful and got different tools, don't reinvent the wheel. I know you can do better.
Dude, do you use JS?
Of couse I do.
I'm just minimizing usage to keep mine nerve system for more pleasant experience.
Yes, I do write frontend (and do it well) when I have to, and yes, I do write prototypes on nodejs(but it never ever goes outside of prototype stage)
Why so angry?
Coz I'm sick of observing how JS is holding back whole software development ecosystem. As part of it I have my word.
The goal of this article is to doubt your (most likely) blind love to JavaScript and look around in the Bigger world