Earlier quoted context omitted.
Javascript is not simple AT ALL. It has 3 ways to declare functions, multiple variations on arrow functions syntax, a weird prototyping inheritance system, objects you can create out of "new" on functions, object literals that can act an pseudo-classes, classes, decorators, for-i loop + maps + filter + for-in loop (with hasOwn) + forEach, async / await + promises and an invisible but always-on event loop, objects pro…
3 ways to declare functions? I am probably blanking but I can only think of: ``` function foo () {} const foo = () => {} ```
Proposal: JavaScript Structs
241–250 of 371 posts
Re: Proposal: JavaScript Structs
#242I am not sure how to really refine this thought I have had, but I have this fear that every language eventually gets so bloated and complicated that it has a huge barrier to entry. The ones that stand out the most to me are C# and Typescript. Microsoft has a large team dedicated towards improving these languages constantly and instead of exclusively focusing on making them easier to use or more performant, they are c…
Javascript is not simple AT ALL. It has 3 ways to declare functions, multiple variations on arrow functions syntax, a weird prototyping inheritance system, objects you can create out of "new" on functions, object literals that can act an pseudo-classes, classes, decorators, for-i loop + maps + filter + for-in loop (with hasOwn) + forEach, async / await + promises and an invisible but always-on event loop, objects pro…
Re: Proposal: JavaScript Structs
#243Earlier quoted context omitted.
Javascript is not simple AT ALL. It has 3 ways to declare functions, multiple variations on arrow functions syntax, a weird prototyping inheritance system, objects you can create out of "new" on functions, object literals that can act an pseudo-classes, classes, decorators, for-i loop + maps + filter + for-in loop (with hasOwn) + forEach, async / await + promises and an invisible but always-on event loop, objects pro…
> reasons to believe JS is simple it's because people are talking past each other, and that's because people are using language wrong, and are merely talking past each other. The word simple is often used to mean "easy" or "familiar". Simple is very different from easy, and familiar things are easy but doesn't have to be simple at all. javascript is not simple, but it is easy.
Re: Proposal: JavaScript Structs
#244Earlier quoted context omitted.
Typescript is the best thing to happen to JavaScript since ES6
Types are great, but I prefer Not having to transpile everything. Stepping throught the TS Code with a Debugger ist non trivial.
Re: Proposal: JavaScript Structs
#245Earlier quoted context omitted.
Typescript is the best thing to happen to JavaScript since ES6
Types are great, but I prefer Not having to transpile everything. Stepping throught the TS Code with a Debugger ist non trivial.
Re: Proposal: JavaScript Structs
#246Earlier quoted context omitted.
.NET/Java are only as performant as Go if you completely ignore memory usage and focus only on time.
And startup time. JIT languages are a bad match for command line applications, for example.
https://learn.microsoft.com/en-us/dotnet/core/deploying/nati...
Re: Proposal: JavaScript Structs
#247Re: Proposal: JavaScript Structs
#248Earlier quoted context omitted.
Call me when browsers support another language. What are we going to use? CSS?
wasm "but wasm has to call JavaScript to use browser APIs" WasmGC is shipped in Chrome and Firefox and enabled by default in WebKit nightly
Re: Proposal: JavaScript Structs
#249I initially didn't like the high level idea, but I warmed up to it. My only concern is that the constructor isn't guaranteed to define the same fields with the same types, which kind of defeats the point. I'd improve this proposal in two ways: 1. Explicitly define the layout with types. It's new syntax already, you can be spicy here. 2. Define a way for structs to be directly read into and out of ArrayBuffers. Fixed…
I agree; the point of a struct type would be to allow a compact memory representation, and you're not going to get it if your constructor can do if(someArg) { a = 1; } else { a = 1; b = 2; }. You don't strictly need known/consistent types, but it sure helps, since otherwise everything needs to be 8 bytes. I don't think a way to read into and out of ArrayBuffers is possible, since these can have pointers in them. I th…
Arguably that's worse than what the runtime is able to do today already with hidden classes.
> I don't think a way to read into and out of ArrayBuffers is possible
If you know all the types and only allow structs and primitives, you could use relative pointers to encode the 2nd+ references to structs that appear more than once in the encoded object. You'd need a StructArray for efficient arrays, but a linked list would encode pretty compactly. But you're very right.
Re: Proposal: JavaScript Structs
#250Earlier quoted context omitted.
This is easily the most appealing thing to me about Go. I learned Go through the "Learn Go with Tests" way and I had a ton of fun. It is hard for me to recommend using Go internally since .NET/Java are just as performant and have such a mature ecosystem, but I crave simplicity in the core libraries. Here's the link for anyone considering learning Go: https://quii.gitbook.io/learn-go-with-tests
.NET/Java are only as performant as Go if you completely ignore memory usage and focus only on time.