JS is such a simple, dynamic language. It should just stay this way. Please stop bloating it with every feature that’s trendy this year. We already have classes that we didn’t need. We don’t need structs for sure.
JS is such a simple, dynamic language. It should just stay this way. Please stop bloating it with every feature that’s trendy this year. We already have classes that we didn’t need. We don’t need structs for sure.
>It should just stay this way
Counterpoint: JS has been evolving significantly, look at ES6 and ES8 in particular if you need help finding examples.
import * as fooNs from './foo'
fooNs.barBazQuuxFoo(foo, …)
vs foo.barBazQuux(…)Don't use vscode or never bother to write jsdoc/do any strict typing? Never mind. Good luck with your codebase.
The limiting factor on a program's performance should be the design of algorithms and data structures, not the programmer's choice of language or runtime.
Not with the attitude, you don’t.
> Just leave these things to WebAssembly where needed and leave JS as a slow, dynamic language we use for web apps.
The ship has sailed when they made V8 and performance race has started.
The nice thing about fixed layout structs is that it leans in to optimizations people are already doing based on the behavior of JS engines where 'shapes' of objects are important and properties can be looked up by offset if you keep your code monomorphic. It can be a bit of a headache to enforce this and you can accidentally fall off a performance cliff if you end up with many 'shapes' for the same thing. By making this a language feature it codifies and blesses what was essentially a hack relying on the implementation of the underlying engine that could change at any time.
There are also TypedArray's that do provide a bunch of cache friendly (but slightly unergonomic) ways to organize data.
A good resource for the sorts of things people are doing to write high-performance JS is here: https://romgrk.com/posts/optimizing-javascript
Yes, it is surprising. https://stackoverflow.com/questions/6586670/how-does-javascr...
And when jit kicks in, it does all the usual calculate-the-offset things in generated code.
Trendy structs. Did I return to 1980? (wipes happy tear)