News for hackers. Stuff that matters.
Re:Swift System Is Now Open Source by IggleSniggle on Friday September 25, 2020 @07:37PM (#24595137)
Sort of. Although I will say that the upcoming TypeScript 4.1 with its string-template types potentially opens up TypeScript to limitless power. Imagine the expressiveness and power of tcl, but as your type system / type definitions.

The weird thing about typescript is that this incredible power and expressively must be backported into the runtime environment. And because of that, the promises that the type system makes are unreliable and also lag way behind the actual language features that are implemented.

I hope these criticisms are read in the proper context: I absolutely love TypeScript, and find it to be a really special unique oddball in the world of language design. I wish it had been ReasonML instead of TypeScript, but TypeScript is incrementally working it’s way there and bringing the whole js community with it, so I can’t complain.

Edit: Prediction: prepare for switch statements to become popular as the typescript community gradually adopts exhaustive pattern-matching types.

Re:Swift System Is Now Open Source by symlinkk on Friday September 25, 2020 @08:59PM (#24595553)
What do you mean by “the promises that the type system makes are unreliable”?
Re:Swift System Is Now Open Source by jbboehr on Friday September 25, 2020 @10:04PM (#24595862)
The type of an underlying variable at runtime may be different than what the typescript type declares. Practically, this would probably be due to either poor, incorrect, out-of-sync, or incomplete type definitions.

A poor example, but this compiles without error and crashes at runtime:

let x: string = "foo"; (x as any) = 1; x.substr(0);

Now, technically, you can do this sort of thing in most, if not all, languages, but this happens organically more often with typescript due to many libraries being written for plain javascript and being looser on their types, or type definitions getting out of sync with the libraries they are written for.