News for hackers. Stuff that matters.
Re:TypeScript 5.0 by prmph on Thursday March 16, 2023 @03:46PM (#35187328)
I wish MS will fork Typescript into a new language altogether that transpiles to JS or compiles to WASM.

In that case, they can remove all JS weirdness from it, simplify it, add a proper standard library, and add other good parts from other (especially functional) languages to it.

My wish list for such a language (in addition to what is already in Typescript), in no particular order:

- Generic object literals (Why should generic type inference be limited to functions?)

- Deep support for an alternative to exceptions using a Failable<TResult, TError> type

- Localizable keywords (Why should programming languages be tools of cultural hegemony?)

- Dependent types, with no real distinction between values and types (At a certain point, Typescript’s type system begins to look like a separate Turing-complete language within a language. It’s probably time to do away with this dichotomy entirely somehow)

- Higher-kinded types (This is a pending issue in TS since 2014)

- JSX built-in without the need for any React-like dependency (No need to use it if you don’t like it; in the general sense, it’s just syntactic sugar for composing function invocations)

- No return necessary (the last expression in a block is returned). Thus every flow control construct _can_ (but does not have to) be an expression.

- No null, undefined, or any of all that, in favor of using a Maybe<T> type

- Proper decimal types (it’s shameful for a language to be without it now)

- A reasonably extensive standard library (Math, Stats, Collections (pull & push), String, Objects, Date/Time, Async, Functional, DOM, etc.)

That would be getting close to the perfect language for me.

Re:TypeScript 5.0 by modeless on Thursday March 16, 2023 @04:26PM (#35187981)
If you're breaking backwards compatibility then my number one request is replacing UTF-16 with UTF-8 for strings and nothing else comes close.
Re:TypeScript 5.0 by yencabulator on Thursday March 16, 2023 @05:47PM (#35189194)
You're asking Microsoft to undo a very Microsoft oddity that Microsoft seems to use just about everywhere. Good luck!
Re:TypeScript 5.0 by modeless on Thursday March 16, 2023 @06:34PM (#35189833)
Windows finally added a UTF-8 locale. Sanity may yet prevail!
Re:TypeScript 5.0 by NoInkling on Thursday March 16, 2023 @11:12PM (#35192511)
> undo a very Microsoft oddity

I don't think Microsoft are the reason why JS uses UTF-16 strings.

Re:TypeScript 5.0 by dmix on Thursday March 16, 2023 @06:13PM (#35189541)
> Deep support for an alternative to exceptions using a Failable<TResult, TError> type

Is there a good library for this currently?

I've been looking for one and a Maybe library. The Maybe one I use is pretty small.

Re:TypeScript 5.0 by halfmatthalfcat on Thursday March 16, 2023 @07:25PM (#35190396)
fp-ts (and most functional libraries) have a handy Either type just for this: https://gcanti.github.io/fp-ts/modules/Either.ts.html
Re:TypeScript 5.0 by dmix on Thursday March 16, 2023 @08:18PM (#35190893)
That looks perfect thank you.
Re:TypeScript 5.0 by lmm on Thursday March 16, 2023 @07:24PM (#35190384)
> In that case, they can remove all JS weirdness from it, simplify it, add a proper standard library, and add other good parts from other (especially functional) languages to it.

Have you tried Scala.js? It's pretty much what you're asking for - a first-class functional language with all the things you'd expect from that, with compile-to-JS as something that works and feels fully first-class (and good integration with TypeScript types via ScalablyTyped).

Re:TypeScript 5.0 by prmph on Friday March 17, 2023 @05:20AM (#35194883)
Scala.js seems interesting, and I will look into it more. But if it is so nice, why hasn't it taken off like TypeScript?
Re:TypeScript 5.0 by lmm on Friday March 17, 2023 @05:29AM (#35194929)
Scala was traditionally a backend language (and has a bit of an image problem, and some genuine community politics troubles), and isn't so well known on the front end side. I do believe it's genuinely the best language going though.
Re:TypeScript 5.0 by matt_kantor on Friday March 17, 2023 @01:00PM (#35199767)
I think a big part of TypeScript's success is because it's just "JavaScript with types".