"I have a mind like a steel... uh... thingy." Patrick Logan's weblog.

Search This Blog

Thursday, November 01, 2007


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.


Ian Bicking said...

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.

Patrick Logan said...

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.

Patrick Logan said...

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.

Erik Onnen said...

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.

Chris Double said...

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.

Patrick Logan said...

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.

Blog Archive

About Me

Portland, Oregon, United States
I'm usually writing from my favorite location on the planet, the pacific northwest of the u.s. I write for myself only and unless otherwise specified my posts here should not be taken as representing an official position of my employer. Contact me at my gee mail account, username patrickdlogan.