ECMAScript Version 5 Approved 158
systembug writes "After 10 years of waiting and some infighting, ECMAScript version 5 is finally out, approved by 19 of the 21 members of the ECMA Technical Committee 39. JSON is in; Intel and IBM dissented. IBM is obviously in disagreement with the decision against IEEE 754r, a floating point format for correct, but slow representation of decimal numbers, despite pleas by Yahoo's Douglas Crockford." (About 754r, Crockford says "It was rejected by ES4 and by ES3.1 — it was one of the few things that we could agree on. We all agreed that the IBM proposal should not go in.")
Re:I can guess why IBM was pushing for IEEE 754r (Score:5, Informative)
Why do processors need decimal number support? 10 is just an arbitrary number humans picked because they happen to have 10 fingers. There's no connection between that and computers.
Clearly you've never dealt with an irate customer who has spent $$$ on your software product, has created a table using "REAL" (4-byte floating point) types and then wonders why the sums are screwing up. IEEE754 can't accurately represent most fractions in the way that humans do and this means that computers using IEEE 754 floating point give different answers to a human sitting down with pen and pencil and doing the same sums. As humans are often the consumer of the information that the computer spits out, making computers produce the correct results is important.
There are plenty of infinite precision computing libraries out there for software developers to use. However, they are all a lot slower than the 4, 8 or 10 byte floating point IEEE 754 calculations which are supported directly by the hardware. Implementing the IEEE 754r calculations directly on the CPU means that you can get close to the same performance levels. I'm guessing that at best, 128 bit IEEE 754r performs about half the speed of 64bit IEEE 754, purely because of the data width.
Cheers,
Toby Haynes
Re:I can guess why IBM was pushing for IEEE 754r (Score:3, Informative)
Re:I can guess why IBM was pushing for IEEE 754r (Score:2, Informative)
(...) I'm guessing that at best, 128 bit IEEE 754r performs about half the speed of 64bit IEEE 754, purely because of the data width.
According to Douglas Crockford "...it's literally hundreds of times slower than the current format.".
point in video where Crockford talks about this (Score:2, Informative)
Re:I can guess why IBM was pushing for IEEE 754r (Score:5, Informative)
(...) I'm guessing that at best, 128 bit IEEE 754r performs about half the speed of 64bit IEEE 754, purely because of the data width.
According to Douglas Crockford "...it's literally hundreds of times slower than the current format.".
I don't doubt that the software implementations are "hundreds of times slower". I've had my hands deep into several implementations of decimal arithmetic and none of them are even remotely close to IEEE 754 in hardware. IEEE 754r is better than some of the predecessors because a software implementation can map the internal representation to integer maths. However, IEEE 754r does exist in hardware and I was guessing that the hardware IEEE 754r is still half the speed of hardware IEEE 754.
One other thing that IEEE 754 has going for it is the emerging GPU-as-co-processor field. The latest GPUs can do full 64bit IEEE 754 in the stream processors, making massive parallel floating point processing incredibly speedy.
Cheers,
Toby Haynes
Re:JSON is in!? (Score:5, Informative)
Is that how JSON took hold? By being easy to parse using eval?
No, it took hold because it's Javascript's native object notation. And, as you can imagine, if you have a string of code you use eval to convert it. There are several JSON parsers which do some validation before using eval to ensure that it contains only an object definition and no statements. It would be nice if that validation was standardized and built-in.
they could have just used XML instead
Developers have a choice between XML and JSON (XML is already well supported), but many developers choose JSON instead of XML. Among other things, a JSON structure is typically smaller than a comparable XML structure, and when it's decoded you don't need to use anything special to use it.
instead of inventing a new serialized object format.
They didn't really invent this so much as realize that the native object format can easily be used to transfer arrays and objects between languages. It's very easy to create an associative array in PHP, encode it and send it to Javascript, and end up with virtually the exact same data structure in Javascript. Working with an associative array in PHP (or Javascript) is obviously a lot easier than working with an XML structure. Virtually any language you would use on a server has support for associative arrays or generic objects, so it makes a lot of sense to pass those structures around in a way where you lose no meaning and each language natively supports it.
Re:Floating point numbers and decimals (Score:3, Informative)
This is an area where ECMAscript pays the price for not being a strongly typed language.
I think you mean "statically typed" not "strongly typed".
Sorry, as a programming languages researcher this is a pet peeve of mine. Carry on.
Re:I can guess why IBM was pushing for IEEE 754r (Score:4, Informative)
> ECMAScript is client side,
You may be interested in http://en.wikipedia.org/wiki/Server-side_JavaScript [wikipedia.org]
I agree that user-visible ECMAScript is client-side, but user-visible _everything_ is client-side, really.
Re:I can guess why IBM was pushing for IEEE 754r (Score:3, Informative)
Actually, 754r handles situations like these via exception flags. If large_num + small_num == large_num, then the "inexact" and "rounded" flags will be raised (possibly others, too; I haven't looked at this in a while), which the programmer can use to take some alternate logic. It's certainly true that stupid programmers can use these tools incorrectly (or not use them), but isn't that true of any system? Sufficiently stupid programmers can defeat any countermeasures.
Re:I can guess why IBM was pushing for IEEE 754r (Score:1, Informative)
You should learn the definition of an irrational number yourself. From the definition of a rational number, you get that real number is rational if and only if any radix representation of it is finite or periodic. Whether a number is rational or irrational does not depend on the radix representation at all. You're essentially saying that that 0.2 is rational and irrational, which is nonsense.
Of course, the point you were trying to make is correct (in one base, the radix representation of some rational number is finite, in others it's infinitely periodic), but 0.2 is most definitely not irrational.
Re:use fixed point instead (Score:3, Informative)
Except that there are all kinds of areas where units smaller than cents are required when working with US currency. If you don't believe me, try finding a gas station whose prices aren't specified in mils. The smallest subdivision for which coins are minted -- or which normal bank transactions can be conducted in -- is not necessarily the smallest unit that needs to be stored or used in calculations.