Is JavaScript a bad language?

Meanwhile JavaScript just keeps getting more powerful and increasingly popular.

I was told “you will never be able to build a career on JavaScript” by a js hater back in 1999. Fortunately I ignored that person, chose the path less traveled and it has worked out splendidly.

Yes, in my experience, those who hate on JavaScript the hardest stumble the most when when they actually have to use it… which goes to show they often don’t know it well enough to be voicing an opinion.

Developers coming from classic application centric languages often don’t understand the async nature of JavaScript and take their frustrations out by blaming the language rather than attempting to learn something new.

Does JavaScript have bad parts? Yes… don’t use them and move on. It’s not that big a deal. There are also “bad” parts of English. I rarely use “ain’t” or “shalt” or “wouldst”. People who get hung up on bad parts of a language (and won’t shut up about it) are perhaps just sexually frustrated and should be humored and handled with kid gloves.

Is JavaScript elegant? I think so… if elegance is defined as expressing an idea efficiently and succinctly, JavaScript is QUITE elegant especially is you use function chaining and native promises with async/await. If you want to see an inelegant language, I’d nominate PHP. (I did PHP for a decade so I’m allowed to hate on it a bit)

Just because someone doesn’t know how to write elegant code in JavaScript doesn’t mean it’s not possible. It usually takes many years to reach the clarity of thinking required to write elegant code. When you get there, JavaScript can do it.

I think it’s ironic that some people hate on JavaScript so much but look back fondly on cryptic / quirky languages like Perl or weak academic languages like Pascal.

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
  • Async: IO in Javascript is asynchronous, meaning when you call a function, It doesn’t stop, execute the function, then return, but runs the function alongside the code. Basically, it doesn’t wait for the function to end before moving on
  • 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!

--

--

--

Full stack developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Nervos CKB Development Dossier #42

How to Deploy a Debian or Ubuntu Linux VM with NGINX in Azure using Terraform

Automation of Elasticity Task Using Python

Meet The Team Lead of Suretly Mobile Development

CodeGirl to OT and Back to CodeGirl

What new Python programmers should know

Postgres backup and restore the whole DB

Collect Naraka Hero to win $50,000!#NarakaNFT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Brainless

Brainless

Full stack developer

More from Medium

Javascript — Object creation

Functional Programming Examples using JavaScript

HashMap: Map vs Object in JavaScript

Js: Introduction to functional programming