News for hackers. Stuff that matters.
Re:All About E: The Language That Infiltrated JavaScript by edg5000 on Thursday October 27, 2022 @07:45AM (#33356132)
I'm not sure why nobody is talking about TypeScript? If browsers were to natively support it, that would be a game changer. We could phase out quirky features of JS and mark them as obsolete in IDEs. More use of the Map class for example would avoid some quirks of using objects.
Re:All About E: The Language That Infiltrated JavaScript by neongreen on Thursday October 27, 2022 @08:17AM (#33356425)
Map is in JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

TypeScript is designed in such a way that type annotations can't influence the runtime behavior. This is unlike e.g. Haskell, where types can drive code generation. Happy to elaborate more if necessary.

This means that transpiling TypeScript to JavaScript consists merely of stripping the type annotations + transpiling some of the syntactic features that might not be supported by the target JS version.

The "Type Annotations" proposal (https://github.com/tc39/proposal-type-annotations), IIRC championed partly by the TS team, will allow type annotations with almost-TS-like-syntax in plain JavaScript, which will make the "stripping type annotations" step unnecessary. You would still use the TS tooling to actually type-check the code, though.

Which exact part of TS do you want to be built into browsers?

Re:All About E: The Language That Infiltrated JavaScript by indocomsoft on Thursday October 27, 2022 @08:54AM (#33356760)
Do you mind elaborating more on Haskell's types driving code generation? Genuinely curious
Re:All About E: The Language That Infiltrated JavaScript by wruza on Thursday October 27, 2022 @12:04PM (#33359613)
The regular type-based polymorphism/overloading, afair. Just like in C++. Typescript has a way to simulate it, but the code remains the same as if there were no types/overloads. https://www.typescriptlang.org/docs/handbook/2/functions.htm...
Re:All About E: The Language That Infiltrated JavaScript by trinovantes on Thursday October 27, 2022 @09:22AM (#33357103)
There's still non-const enums generating runtime code

I think it would be huge if some future nodejs/web browser can parse native TS so we no longer need to deal with the mess of dev tools like ts-node and babel and wonder why some folder structure or sourcemap is not working

Re:All About E: The Language That Infiltrated JavaScript by indy on Thursday October 27, 2022 @07:57AM (#33356246)
I'm surprised that Microsoft haven't already done this with their Edge browser. At least offer a 'developer' mode which enables TypeScript support only during development
Re:All About E: The Language That Infiltrated JavaScript by mlajtos on Thursday October 27, 2022 @10:54AM (#33358464)
Re:All About E: The Language That Infiltrated JavaScript by protomolecule on Thursday October 27, 2022 @11:50AM (#33359415)
Re:All About E: The Language That Infiltrated JavaScript by toxicFork on Thursday October 27, 2022 @07:48AM (#33356155)
I guess we would not need to compile it down to js and instead evaluate or jit it directly?

Could someone do this on an open source browser perhaps? Or would it require some initial big chunk of work?

Re:All About E: The Language That Infiltrated JavaScript by chombier on Thursday October 27, 2022 @09:23AM (#33357111)
What about ReScript? As far as I understand ReScript has a sound type system which would make it an even better foundation?
Re:All About E: The Language That Infiltrated JavaScript by kragen on Thursday October 27, 2022 @01:27PM (#33360958)
We can't phase out features of JS in browsers, quirky or otherwise, because that would prevent us from running existing, fully debugged, standards-compliant web pages. It would mean that programming for the web was like writing on the beach at low tide.