DEV Community

Cover image for 5 Reasons why javascript is hated by developers.
Ankit Soni
Ankit Soni

Posted on

5 Reasons why javascript is hated by developers.

Javascript is a programming language build by Brendon Eich in April 1995. He was told to make a language to run in Netscape's browser and that too within 10 days.
The hard part was producing a rich and powerful language while being prohibited from using the object-oriented syntax reserved for Java. A lot of developers hate this language. Below is a comparison of it from other languages.

Comparision of programming languages

In this graph, you can easily see how fast javascript has grown in terms of job opportunities from 2019 - 2020. Now you may have a doubt why it is so popular even if there are so many people who hate this language. In this post, I have tried to give you some reasons why it is being hated.

Reason 1. Loosely typed language.

Javascript is a loosely typed language, but what does it mean? It means that you don't have to declare the type of a variable while defining it.

  • Case 1: Variables without defining any data types.
let a = 2; console.log(typeof a); // logs out number a="coding"; console.log(typeof a); // logs out string
  • Case 2: NaN is a number (quite confusing)
console.log(typeof NaN) // logs out number;
  • Case 3: You can mix different data types in an array.
array = ["banana", 2 , {name: "ankit" , lastname: "soni" } ]; // please click on the run button below to see the log. console.log(array[0] +" "+ typeof array[0]); console.log(array[1] +" "+ typeof array[1]); console.log(array[2].name+" "+array[2].lastname+" "+ typeof array[2]);

Reason 2. Concept of "==" && "===".

In very simple words "==" cares about equality of two variables without caring about the data types, whereas "===" cares about the equality as well as the data type of both the variables. Let's understand it better by the following example.

var a = 1; var b = "1"; console.log(a == b); // prints true console.log(a === b); // prints false

In third line of code, double equals does not care about the data types of the variables which are different and then prints true, whereas triple equals strictly care about the data types of the variables and hence prints false.

Reason 3. Functions can call themselves (IIFEs)

IIFE stands for immediate invoked function experssion. Lets learn its logic.

(function(name) { console.log(name); //logs out "Welcome to the ankit's blog". })("Welcome to the ankit's blog");

This function calls itself by adding parentheses at the end of the function definition.

Reason 4. Adding two variables of different data type

Look at the following example and try to think about the output.

var a = "12"; var b = 3; console.log(a + b); // logs out 123 console.log(+a + b); // logs out 15

It logs out "123" and 15 in the console but how is it happening. Javascript says that when you add number and string then number changes to a string, whereas when you put a plus sign before a string then string changes to a number which is quite bizarre.

Reason 5. Javascript performs differently for different browsers.

This generally happens due to the reason that every browser has its different ECMAScript engine which it uses to compile javascript code. Most famous ones are V8 by google chrome and spiderMonkey by mozilla firefox. Javascript is different from languages like c, c++ and java. Java codes are compiled the same on all the devices which are using JVM in their machines, but that does not happen with javascript. Hence a developer has to look at how their website is performing in different browsers.

Conclusion

I showed you a lot of negatives about this language but don't dare to judge this language to be crappy. It has a huge internet community, as well as a lot of frameworks and libraries, are running on it. Below is the list of some of them.

If you are still reading it. Consider reading my blog on promises by clicking on the following link.

Thank you!

Top comments (7)

Collapse
 
moopet profile image
Ben Sinclair

1, 2, and 4 are common to other languages like PHP.

They're controversial points, but none of them (except the last one, browser compatibility) are really reasons to dislike the language in and of themselves.

Collapse
 
pentacular profile image
pentacular

Javascript is a loosely typed language, but what does it mean? It means that you don't have to declare the type of a variable while defining it.

Not needing to declare the type of a variable doesn't mean it's loosely typed.
It means that it is not manifestly typed.
This can also be true of strongly typed systems with type inference.

Reason 2. Concept of "==" && "===".

The difference here is that == involves implicit conversions, and === does not.

Reason 3. Functions can call themselves (IIFEs)

An IIFE does not call itself.

The function is an expression which can be used in a function call.
The call is from outside the function.

Reason 4. Adding two variables of different data type

Implicit conversions again.

Reason 5. Javascript performs differently for different browsers.

Different implementations of languages generally have different performance characteristics.

This is not a meaningful reason. :)

Collapse
 
nombrekeff profile image
Keff

I think people hate js because it can do mostly everything (although some would say not efficiently or there are some things it can't do).

For me, only the last point is a reason to dislike it. But I don't think it's an issue with JS itself but more with the companies behind the Browsers.

Even so, what can we do? There is no alternative...

Collapse
 
ankysony profile image
Ankit Soni • Edited

Correct We dont have any other option other than js. JavaScript is really dominating in every field. The reasons which i have included are my own perceptions about it. I appreciate your views too. My intend in this blog is targetted to the person who knows well c based languages and now is jumping in the field of javascript.
Moreover i personally love javascript.

Collapse
 
babakks profile image
Babak K. Shandiz

Not to forget the emerge of TypeScript which is completely based on JavaScript.

Collapse
 
ankysony profile image
Ankit Soni

Absolutely right, TypeScript is an improved version of javascript which supports static typing.

Collapse
 
hcminhit profile image
i love Math

thank you, i learned lots of knowleadge from you