Typed Objects and Classes

Brian Barnes ggadwa at charter.net
Wed Jun 22 12:35:21 UTC 2016


OK, thanks, that answers my question!

[>] Brian

> On Jun 22, 2016, at 7:31 AM, Isiah Meadows <isiahmeadows at gmail.com> wrote:
> 
> For what it's worth, engines already optimize for static object layouts. So if you never change the property set for instances of that class, the struct won't help performance much in practice. Similarly, standard arrays with just numbers are almost as fast as typed arrays as well, so unless you're in serious performance critical, likely asm.js, code, you might get a 0.5% boost.
> 
> 
> On Mon, Jun 20, 2016, 11:20 Brian Barnes <ggadwa at charter.net <mailto:ggadwa at charter.net>> wrote:
> As far as I can read, Typed Objects/Structs are in consideration for a
> later version of ecmascript (but not in the spec) and there exists some
> implementations.  It depends on the engine, but has there been any
> thought to how costly they might be to fake at least some rudimentary
> type support?  For instance:
> 
> class point2D
> {
>         constructor()
>         {
>                 this.props=new Structure({
>                         x:uint32,
>                         y:unit32
>                 });
>         }
> 
>         setMe(x,y) {
>                 this.props.x=x;
>                 this.props.y=y;
>         }
> }
> 
> This doubles the property lookups but that can probably be optimized
> away (maybe) -- but it does force the engine to consider x/y as always
> ints.  Of course, this doesn't do anything about the function signatures.
> 
> I don't think types are coming anytime soon, and just wondering if, in
> the future, messy code like this might be worth it, or otherwise, to let
> implementers know this is something that people might try with their
> code and would be an interesting path to look at.
> 
> [>] Brian
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org>
> https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160622/1f6ecc7c/attachment.html>


More information about the es-discuss mailing list