Haters gonna hate…
Ok, but how is it?
It’s not as bad as some make it look like. It’s actually quite good once you get into it. But let’s explore some of the reasons people complain about JS:
- Dynamically typed: Arguably a design choice, has it’s ups and downs, but other languages like python and Ruby have it too, and people don’t seem to complain much about that. Solved if you use Typescript
- Weakly typed: this is the one major flow. Sometimes a type gets randomly coerced into another (for example, you can add something to an empty list and have it transform into a number…) . I’m pretty sure this is solved too if you use typescript
- Prototypical object model: This is again a design choice. Even with the new class notation, it all boils down to prototypes. This is not as bad for a reason that I’ll explain later.
Now, let’s look at the other side of the coin, and the reason why is a great Language
- Pretty huge ecosystem
- Native support for json
- Pretty good support for functional programming, compared to a lot of other popular languages (looking at you, Java)
- Async is the reason that JS on node runs faster than ruby or python. If you get used to it, with a bit of discipline you can write beautiful code through streams, promises, generators and async/await(when it arrives to ES. For now, we have it in typescript)
- Good support for functional programming means that you don’t really use prototypes as much as you would use classes in Java/C#.
I personally think that people kinda hate JS just because it is JS nowadays. Yes, it still has its warts, and yes, a lot of npm packages might be badly written, but the language as a whole has been steadily improving over the years. It also lets you write more expressive, clean and declarative code than a lot of other popular programming languages, like Java or Go. My point is that there seems to be this trend where JS is a terrible language, but when you point at the weak points of other languages ( badly implemented generics in Java, complete lack of them in Go) people don’t seem to care as much. There aren’t as many people saying that Go or Java are terrible languages, but a lot saying that JS is. And I can’t really see why, other than the fact that you can wilfully choose to use most other languages, but you’re forced to in the case of JS.
By the way, if it wasn’t clear enough, I have kind of a hate-hate relationship with Go and Java
So is it a good language?
I will argue that is a great language. You can write any software with it.
Is light weight on the system and nowadays in the MicroServices world the multi-thread and multicore is not even that important (unless you write games or crypto mining), you just spin up more than 1 instance ( as many as you need ) for the task that you need, and than just scale down to 1 or 0 instances to what you need, and will be much cheaper on cloud bill as well. On the light weight only GoLang and web assembly is able to beat JS.
So what do you think about JS?
Leave a commend with your thoughts: is it bad, is it good?
Thank you for reading and have a nice day!