3 ms·
For me the two Achilles's heels of JavaScript performance are the lack of easy parallelism and creating new objects in instances where they could mutate existin
by Lerc 5y ago
For me the two Achilles's heels of JavaScript performance are the lack of easy parallelism and creating new objects in instances where they could mutate existing ones.
These could be solved with a sufficiently smart JIT. but the task is not a trivial one.
var data = [[2,3],[4,5],[6,7],[8,9]];
data = data.map(([a,b])=>{let l = Math.hypot(a,b); return [a/l,b/l];});
In instances like this it should be possible for a JIT to modify data in place without allocating any new objects. Similarly should data be large enough A JIT could process the transformation on multiple cores.
A reference counting Garbage collector would have an edge. Alternatively a language could crafted to provide more context for the JIT to do it's work. Having a clear distinction between mutable and immutable and being able to specify that functions are pure. These would assist a great deal.
- remexre 5y agoYou might find https://www.microsoft.com/en-us/research/uploads/prod/2020/11/perceus-tr-v1.pdf https://www.microsoft.com/en-us/research/uploads/prod/2020/1... interesting; not a JIT, but lets you get a similar optimization.
- richeyryan 5y agoThere's a proposal for immutable records and tuples: https://github.com/tc39/proposal-record-tuple https://github.com/tc39/proposal-record-tuple Theoretically they would use structural sharing for their implementation which should reduce the overhead of creating a whole new array of objects like that
- mst 5y agoI believe koka has done a bunch of work making re-use happen automatically. Some really interesting ideas in there.