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.
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.
- Case 2: NaN is a number (quite confusing)
- Case 3: You can mix different data types in an array.
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.
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.
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.
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.
- Front-end: Reactjs, Angular, Vuejs, emberjs etc.
- Back-end: Nodejs
- mobile-development:React native and ionic
- game-development: Phaser, babylonjs and playcavasjs
- Desktop application: electron
If you are still reading it. Consider reading my blog on promises
by clicking on the following link.
Top comments (7)
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.
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.
The difference here is that == involves implicit conversions, and === does not.
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.
Implicit conversions again.
Different implementations of languages generally have different performance characteristics.
This is not a meaningful reason. :)
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...
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.
Not to forget the emerge of TypeScript which is completely based on JavaScript.
Absolutely right, TypeScript is an improved version of javascript which supports static typing.
thank you, i learned lots of knowleadge from you