Oh dear...
Static typing will also allow compiler based unboxing, will it not? That would lead to increased performance along with safety.The browser has a lot of problems. This is not one of them.
"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.
Oh dear...
Static typing will also allow compiler based unboxing, will it not? That would lead to increased performance along with safety.The browser has a lot of problems. This is not one of them.
6 comments:
The very concept of "unboxing" in a language like Javascript is awkward and uncomfortable. There are no boxes in Javascript. What a sad day if they were to be introduced!
If Javascript was just as fast as other mainstream dynamic languages it would be perfectly fine. Not even the fastest of them, just if Javascript was in the middle of the pack... then it would be fine.
Before the Java/C# language designers made un/boxing a concern of each and every developer, the concept used to be a hidden aspect of efficient implementations of dynamic languages.
Translators and runtimes for dynamic languages can look at scopes and lifetimes of variables, in particular numbers like "floats" and "bignums" that could not be represented as "immediates". Small integers can be represented "immediately" in the pointer if the pointer/address space was designed efficiently. And so no heap space is required for them.
Larger numbers and floats generally have to be allocated ("boxed") in the heap because the pointer width does not allow them to be encoded immediately in the pointer. Smart implementations though can minimize the use of heap by "unboxing" those numbers for some stretch of code as long as there are no observable differences in the application.
No one used to care about this. No one should. Let the implementers of runtimes worry about it if and when that becomes a big concern. Unlikely for browser/GUI specific code except in rare circumstances.
Certainly it is not a reason to introduce explicit type declarations. But ActionScript already has them and application code appears ever more to be Java-like rather than dynamic.
Actually, ActionScript has type declarations only if you want them. You can disable all type checking by the compiler and write an application with completely dynamic objects, the only thing that I can imagine would hold you back in doing so would be the underpowered eval.
The types in es4 are optional from what I can see. So you can do:
var foo = doSomething();
and it works fine. Or you can add the type:
var foo : sometype = doSomething();
Much like Dylan in that respect.
Yep. Know they're optional. Don't care for static types, optional or not. Not good programming practice. If you want speed, there's other ways to get it. If you want safety, there's other ways to get more of it.
Post a Comment