ECMAScript Version 5 Approved
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.")
instead of using floating point for representing decimal numbers, one can of coarse easily use fixed point... for currency computations, just store every value multiplied by 100 and use some fancy printing routine to put the decimal point at the right position.
and if you're afraid that you might mix up floating point and fixed point numbers, just define a special type for the fixed-point numbers, and define corresponding overloaded operators... oh wait
If Pandora's box is destined to be opened, *I* want to be the one to open it.
JSON was *always* in Ecmascript. It's just object literal notation, a shorthand way of instantiating an object with properties.
The debate over floating point numbers in ECMAScript is interesting. IEEE 754 has plenty of pitfalls for the unwary but it has one big advantage - it is directly supported by the Intel-compatible hardware that 99+% of desktop users are running. Switching to the IEEE 754r in ECMA Script would have meant a speed hit to the language on the Intel platform until Intel supports it in hardware. This is an area where IBM already has a hardware implementation of IEEE 754r - its available on the POWER6 platform and I believe that the z-Series also has a hardware implementation. I suspect that IBM will continue to push for IEEE 754r in ECMAScript, I wonder whether Intel is considering adding IEEE 754r support to its processors in the future.
Disclaimer: I have no contact with the IBM ECMAScript folks.
Cheers,
Toby Haynes
Anything I post is strictly my own thoughts and doesn't necessarily have anything to do with the opinions of IBM.
Until we get a slick gui editor for javascript+svg animation, no.
When you have strict regulatory rules about how rounding must be done, and your numerical system can't even represent 0.2 exactly, then it is most certainly a concern. There are other solutions, such as using base-10 fixed point calculations rather than floating point, but having decimal floating point is certainly more convenient, and having a hardware implementation is much more efficient.
13:51 into the video is where you want to skip to if you want to hear just this argument. I just don't have the time for the whole 55:42 video. Nice non-youtube player though.
Until we get a slick gui editor for javascript+svg animation, no.
In other words, we need GNU Ecmas.
formal name of JavaScript - now turn in your geek card
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".
Statically typed Catches type errors at compile time. Dynamically typed Catches type errros at run time. Strongly typed Always catches type errors. Weakly typed Doesn't always catch type errors.Sorry, as a programming languages researcher this is a pet peeve of mine. Carry on.
I fail to see how being loosely typed means that support for higher precision numbers is any uglier than in a strongly typed language. Simply adding a new up for a Decimal type that gave a stronger precision number internally, or had an extra notation for a strong number's initialization could work. IIRC, Python has a pretty decent numerics.
Michael J. Ryan - tracker1.info
Catches type errros at run time.
And no, I don't know what the name is for a language that catches spelling errors.
When you have strict regulatory rules about how rounding must be done, and your numerical system can't even represent 0.2 exactly, then it is most certainly a concern.
The numerical system in use at my employer includes a fixed-point representation of money. All money values are assumed to be fractions with a denominator of exactly 100.
There is nothing stupid about using javascript for financial calculations. More and more applications are moving to the web, and the more you can put in the client, the more responsive the application will be. Imagine a budgeting app like Quicken on the web, or a simple loan/savings calculator whose parameters can be dynamically adjusted, and a table/graph changes in response. While critical calculations (when actually posting a payment for example) should be (re)done on the server, it would not be good if your "quick-look" rounded differently then the final result.
And no, people should not be using floating point for currency, ever, and fixed-point calcualtions aren't hard. But there is more to it that "just put everything in cents"; for example, you often have to deal with rates that are given as fractions of a cent. A decimal type would make this more convenient.
Finally, I don't know if IBM's proposal is a good one. I haven't looked at it; I was just talking in generalities.
The floating point representation issue could be resolved the same way it is handled in Python 3.1 by using the shortest decimal representation that is rounded to the exact same binary floating fraction.
With this solution 1.1 + 2.2 will show as 3.3 (it doesn't now) but it will not test as equal to 3.3. It's not as complete a solution as using IEEE 754r but it handles the most commonly reported problem - the display of floating point numbers.
See What's New In Python 3.1 and search for "shortest".
Stop worrying about the risks of nuclear power and start worrying about the risks of not using nuclear power.
Back when ECMAScript 4 was still alive there was a proposed Vector class that had the potential to provide O(1) access. This is very useful for many performance sensitive algorithms including coding, compression, encryption, imaging, signal processing and others. The proposal was bound up with Adobe's parameterized types (as in Vector<T>) and it all died together when ECMAScript 4 was tossed out. Parameterized types are NOT necessary to provide dense arrays with O(1) access. Today Javascript has no guaranteed O(1) mechanism, and version 5 fails to deal with this.
Folks involved with this need to consult with people that do more than manipulate the DOM. Formalizing JSON is great and all but I hadn't noticed any hesitation to use it without a standard... ActionScript has dense arrays for a reason and javascript should as well.
Maw! Fire up the karma burner!
Read the article, it provides some explanation of why things are the way they are.
Plus, what exactly are your other options? Doing the entire page in flash or active X?
Also, sort of makes perl 6's development look a lot better, doesn't it?
Well.. maybe. Or Maybe not. But Definitely not sort of.
In fact, I think Scheme demonstrates pretty effectively that being dynamically typed (which, not loose typing, is what JavaScript is) is entirely compatible with having an extraordinarily elegant system of numeric representation which seamless scales from exact integer representation through exact rational representation through to inexact representations.
Could someone 'splain why i was modded down? It's a legit question and not even snarky in its wording.
Utilizing the synergization of benchmark e-solutions to pre-workaround action items!
PHP doesn't have a built in fixed point type either, yet many programmers use it for financial calculations and simply round to 2 decimal places when it's time to display. Sure, you can use the bcmath extension (about as easily as writing your own fixed point math code in javascript), but very few people do.
Goedel-script, but it's never gonna get finished, well not consistently and completely...
Rgds
Damon
http://m.earth.org.uk/
not quite, the various javascript,Ejscript,ActionScript are dialects of it, which means it has significant variations from the standard.
does anthing use the real ECMAScript.
also, geek card not required, language is a pathetic throwback to 1980s c++ type language.
There are several other things, the most significant of which in my opinion is property descriptors:
eg. For any property (value/function) of an object you can specify whether it is: writable, enumerable, or configurable; allowing for read only properties, properties which do not pollute a for(val in obj) call, and properties which cannot be messed with by other programmers.
See: http://ejohn.org/blog/ecmascript-5-objects-and-properties/ for a better description.
Sorry, as a programming languages researcher this is a pet peeve of mine.
I feel your pain. I'm a Python fan and I'm always quick to remind people that Python is in fact strongly typed, but not statically.
However, in this case, I wonder why you picked the nit, because Javascript is in fact weakly typed.
"1234" * 1 is a legal expression, which evaluates to 1234. That's pretty weak if you ask me.
steveha
lf(1): it's like ls(1) but sorts filenames by extension, tersely
However, in this case, I wonder why you picked the nit, because Javascript is in fact weakly typed.
Meh, I would say that it just has automatic coercion. Soundness is still preserved.
Unfortunately on the strongly vs. weakly typed scale there are several different stopping points so one man's strong is another man's weak (e.g. to a Haskell or ML programmer, both Python's and Perl's type systems are fairly weak). It also doesn't help that strong vs. weak is use to refer both to the level of sophistication and to whether it is possible to violate soundness.
And no, I don't know what the name is for a language that catches spelling errors.
Freud?
May Peace Prevail On Earth
Now turn in yours. JS takes concepts from Self and Lisp, not C++.
I know tobacco is bad for you, so I smoke weed with crack.
no, it doesn't take any *useful* concepts from either of those languages. It's merely a weakly typed semi-OO (all objects are associative array, ew) langauge with a truly crappy implementation of closures as inner functions.
Oh, and what is your idea for an object implementation? And do you have a better idea for closures?
I know tobacco is bad for you, so I smoke weed with crack.