DEV Community

Discussion on: Why Learning JavaScript Is Fun

Collapse
 
erebos-manannan profile image
Erebos Manannán

JavaScript is fun until you realize you HAVE to work with it to build frontends, and how bad the language is.

Yea, the C/C++ style "if you want some thing to be done do it yourself" can be fun for the beginner, but after you've googled to copy & paste your 20th function randbetween(min, max) { ... } (often with small bugs because the first result is a bad solution) or spend more time setting up a working toolchain to build your project in a fun and efficient way you will get tired of it pretty quickly.

In the end JavaScript is a horrible language to work with, it does almost nothing for you to start with, and the ecosystem that the JS developers have built around it is an unstable mess.

The favorite tools for building, grunt/gulp/webpack/etc. keep changing every year, there are a ton of libraries you want/functions you have to implement yourself to give the language the basic capabilities you need to be productive, and all of these combined with the unstable dependency management systems mostly still in use mean that the code that worked a couple of years, month, or even days ago just doesn't work today.

There are some glimpses of hope here and there, e.g. yarn is fixing some long outstanding issues with JS development, but only some. Similarly some libraries like Underscore easily fix some of the more common things missing from the language, but on the other hand come with the extra baggage of some clunky syntax etc.

Add to this the batshit crazy ECMAScript committee going the PHP way with their design -> picking every wrong decision possible. Did ANYONE in the committee for example pause for one second to think "Why is it that in Python they write from module import function instead of import function from module?". If they had, they should've quite quickly realized that the syntax for import {func} from 'bar' is both disgusting in terms of looks, and the objectively wrong way around -> no IDE on the planet is able to accurately autocomplete anything you type as they are in the wrong order.

If CoffeeScript was such a great idea, why didn't it become so much more popular? Why did CoffeScript's awful shorthand function notation have to be adopted into the standard, and why does every JS programmer think it's a great thing if no-one else can read their function definitions easily?

While adding these terrible solutions for mostly non-issues, the ECMAScript committee is also avoiding fixing some of the actual terrible issues of JS, e.g. you using the wrong options -keys and the code just chugging along without any error, notice, or anything hinting at your misuse of the code. This is a simple consequence of the language missing a clear and simple named parameters, and everyone implementing their options -objects without any validation.

Now there are two ways to solve this, the best option of course being adding named parameters, the secondary option adding easy validation for objects that includes making sure no EXTRA data is there (like when you typo something, or guessed the name wrong).

So, while the language does have some nice features about it, and it is sort of getting better at the same time, it's also degrading at an unprecedented rate. The worst part about it is however the community, which is making a large number of programmers really bad at their jobs and then be proud of their non-accomplishments. No other programming community I've seen is so proud of their ability to obfuscate their code, make it unstable and unpredictable, and be unable to detect user error and just keep going on doing the wrong thing, except maybe the PHP community .. tough call this one.

Then there are tools like Flow and TypeScript, which are steps to the right direction, but introduce extra issues to the workflow - few 3rd party libraries still support TypeScript, and the compiler and other tools suffer from the typical JS issues of being poorly documented, having almost no useful logging, and having no ability to detect user error. Also not even TypeScript can remove the dependency to a bazillion 3rd party libraries and every 3rd party library including other 3rd party libraries for the simplest things. This leads you to spend a lot of extra time every now and then to get your fancy tools working again so you can write JavaScript a little more pleasantly than you do without them.

The one hope I have for JS is that something like Kotlin/Nim/Elm/Haxe, a completely separate language with it's own toolchain and community but the capability to compile into JS, will eventually become mature enough to significantly compete for the market.

If you want fun languages to work in that also allow you to be productive try Python and Go, if you're into async programming both offer plenty of chances to do that (for Python e.g. gevent, asyncio, tornado, async and await in Python 3.5+, etc.), while having much better ecosystems and a more of a "batteries included" attitude so you can quickly get to doing your work instead of fooling around with reimplementing the bare bones for the 17th time. I've heard lots of good about Rust as well, though unfortunately have no personal experience with it.

If you want to work on the frontend and do something cool, maybe try Kotlin/Elm/Nim/Haxe, hell try building something with Emscripten, maybe create a nice DOM library for use with Emscripten to make it fully feasible to build your web frontents with Swift, D, or other languages.

Collapse
 
nijeesh4all profile image
Nijeesh Joshy

Thank you for sharing your opinion
Wow thats a long comment.

Every language has its good and bad. Thats the beauty of it when you realise the the bad of the language and work around it to get to your solution will give you a lots of insights and challenges for you to work with.