Programming Languages – Mostly the same – Be it Java or Javascript

Was checking my medium daily digest when I came across a funny article – How Node.js is Going to Replace JavaScript, and then found – “Java is better than Javascript” written by an author unknown to me, until now ( and I’ve sworn if I meet a Java developer like him in near future, I’ll teach the basics of programming then & there).

In another post where he goes repeating the lie (or misinformation) over, he mentions the following code snippet:

var a=0.1
(a - 0.3== 0)  // false or true ?

Any programmer would know – how floating point arithmetic works.

Note: Javascript uses DEC64 as the number format unlike Java’s BigDecimal (as Yakov Fain describes) and that is the reason why you don’t get erroneous results (possibly going out of bounds because of their signed-ness) as given in the screenshot below.

Which language is better: Java or JavaScript?
Image Courtesy – Yakov Fain’s Blog – Which language is better: Java or JavaScript?

Let me take you back to my ‘C’ days

The first programming language I learnt was C more... During our lectures we were taught about Floating point numbers and why an IF condition won’t work on floating points. This is a fundamental portion of any language.

On the same blog there is a comment from user Janos Illes containing a C++ snippet.

double a = 0.1;
a = a + a + a;
cout << "a – 0.3 = " << a – 0.3 <>> a = 0.1;
>>> a = a + a + a;
>>> print ‘a – 0.3 = {0}’.format(a – 0.3)

a – 0.3 = 5.55111512313e-17

This is how floating points have behaved all the time. If you made your first discovery of it with Javascript (probably because you’re learning a programming language properly for the first time in your life), then please don’t diss this language because of your sheer ignorance about the fundamentals – well then good luck writing (and misinforming) your ‘yet to be pulitzer prize winning’ Enterprise Java book and good luck to the readers as well.

Language for the noobs

Yes, the first programming language I learnt was C. The order in which I learnt programming languages.

C -- C++ -- Java -- Javascript -- PHP -- Objective C -- Some more Javascript

There was a question in Quora – Is JavaScript for amateurs?

Well, I was an amateur when I started with C and C++ and even Java. That doesn’t make any of these languages lose credit. In fact, if an amateur can’t learn a programming language, then definitely that language is not well designed. I became a veteran with Javascript later.

On the other hand, if a no. of amateurs write bad codes (which is of course because of their lack of knowledge on the language they’re writing code in) that should not strip the language off of its value.

some popular misconceptions & mythS

  1. Javascript lacks the ability to exploit multiple cores as it is single threaded (read, read more)
  2. Javascript is slow
  3. will keep on adding more

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s