Why Javascript is Retarded: Part 1
Four reasons why Javascript is just... lol... absolutely ridiculous.
Did he just insult Javascript?
Yep
Should I be mad at him about that?
Nah.
Should I retort with why I think he’s wrong?
I wouldn’t.
Wait. Did he just say “retarded”? Can he say that?
*shrug*. Seems so.
Should I be mad at him about that?
Nah.
The Lunduke Journal Community — About the Lunduke Journal — Subscriber Perks
The Lunduke Journal Weekly Schedule:
Monday - Computer History
Tuesday - Computer & Linux Satire
Wednesday - Podcast (Subscriber Exclusive)
Thursday - Computer History (Subscriber Exclusive)
Friday - Wildcard day! Anything goes!
Saturday - Linux, Alternative OS, & Retro Computer News Article
Sunday - Linux, Alternative OS, & Retro Computer News Podcast
Alright - the example with 0.1 is well-understood. decimal fractions like 0.1 and
0.2 do not have a finite expansion as a binary fraction. The reason the noise is
so far out on the end is because JS uses
double precision floats so error is pretty small. But it is UNAVOIDABLE in binary
floating point arithmetic.
And that, folks, is why COBOL
(and PL/1) have support for fixed-point DECIMAL arithmetic, so that 10 dimes
will actually make a whole dollar without rounding.
floating point binary is wonderful for many things, but it is not without surprises awaiting the unread. without support for un-normalized values, a sufficiently small number added to a sufficiently large number will equal that large number.
the small number is called a “relative zero”
for the large number. this only happens when the dynamic range of values is very large, but there are science and engineering computations where this must
be considered quite carefully. This is not
limited to any particular programming language, but is a consequence of computer arithmetic, in the dark corners, being a very poor approximation of the Real Numbers. Airplanes have disintegrated in mid-air before this was sufficiently understood.
-mo
Best title ever.
In an effort to make things easier and more accessible, JavaScript made some things more problematic in the end. There's a hidden cost to ignorance.