News for hackers. Stuff that matters.
Re:How we failed, then succeeded, at migrating to TypeScript by throwaway_bad on Sunday October 13, 2019 @05:54PM (#21243391)
> Typescript seems to be approaching C++ levels of syntax

I've been a bit traumatized by C++ so I can't help but see this as a bad thing.

A lot of the insanity in C++ is because template metaprogramming made a lot of micro-optimizations possible. You can use CRTP to achieve static polymorphism. You can use SFINAE for tag dispatch to choose a different algorithm at compile time. You can even fold entire algorithms down to a constant with constexpr.

This is great if you care about low level control of your code, but this is usually premature optimization in the JS world.

Luckily typescript will be immune to this because the types can't affect runtime at all. So far I haven't seen any truly monstrous generics that are so prevalent in C++.

Re:How we failed, then succeeded, at migrating to TypeScript by desert_boi on Sunday October 13, 2019 @06:41PM (#21243719)
There's some Typescript type stuff that can probably get close.

https://stackoverflow.com/a/47914631/1924257

https://stackoverflow.com/a/53229857/1924257

Re:How we failed, then succeeded, at migrating to TypeScript by morelisp on Sunday October 13, 2019 @06:51PM (#21243792)
I don't agree - the TypeScript code you link is "complicated" because it's modeling complicated types, or implementing higher-order types which need to handle complicated types. And honestly it's not that complicated - an explanation of what RecursivePartial must do maps closely to the type expression ("each key of the partial type is optional, and each value's keys are also recursively so").

This isn't at all close to CRTP or SFINAE, not just because TS/JS lacks the dispatch features necessary, but because in both cases you link it's still just about type declaration. CRTP and SFINAE are both ways to hack the type system to _run_ differently.