News for hackers. Stuff that matters.
Re:Lessons learned building a multiplayer game in NodeJS and... by kevingadd on Monday November 19, 2012 @03:35PM (#4806250)
Unfortunately there aren't any particularly efficient ways to do immutable values in JS right now. readonly properties tend to behave in poor ways (like silently discarding attempted writes, or slowing down jitted code) and immutability forces you to create way more object instances than you would otherwise (which, as the post mentions, tends to perform poorly due to the relative immaturity of JS GCs.)

At this point I consider this to be a bigger problem than it was when I wrote about it [1]. On the upside, it's possible to use tools like Emscripten or LLJS to produce JavaScript code that doesn't suffer from these downsides because it doesn't rely on the JavaScript GC or heap, but that introduces its own issues.

Ultimately, JS engines either need dramatically better garbage collectors or, the language needs to evolve to the point that an ordinary piece of JavaScript isn't going to place tons of pressure on the collector. Proposals like Binary Data [2] will help pave the way here but it may ultimately take the addition of value types that behave like structs in C/C#.

[1] http://www.luminance.org/blog/code/2011/06/18/performance-ch...

[2] http://wiki.ecmascript.org/doku.php?id=harmony:binary_data

There are no comments on this comment yet.