Re:I’m porting the TypeScript type checker tsc to Go
by m-hilgendorf on Tuesday January 25, 2022 @01:25PM
(#30075779)
> 1) prototyping something where I don't want to spend time writing types
It doesn't compile to JS, but this is one of the canonical use cases for Stanza 's (1) "optional" type system
Re:I’m porting the TypeScript type checker tsc to Go
by mixedCase on Tuesday January 25, 2022 @03:09PM
(#30077340)
Have you tried doing Type-Driven Development? IME, most of the time constraints are determined through types first with the code being done later tends to replace the game of "what kind of complex and non-obvious types fit my code the most" with a "oh, the implementation is obvious" reaction.
It also makes it easier to determine what behavior is worth testing and which ones are already covered by your types, if you tend to write tests last. If instead you're used to Test-Driven Development you can do types->tests->code.
Re:I’m porting the TypeScript type checker tsc to Go
by eatonphil on Tuesday January 25, 2022 @03:15PM
(#30077432)
I've spent a lot of time programming in Standard ML and yeah that's a prerequisite there.
But no I don't prefer it to what I do in TypeScript.
Re:I’m porting the TypeScript type checker tsc to Go
by tshaddox on Tuesday January 25, 2022 @01:41PM
(#30076011)
Out of curiosity, how often do you have a project in the first mode that gets large enough that the speed of compiling TS to JS is significant?
Re:I’m porting the TypeScript type checker tsc to Go
by nicoburns on Tuesday January 25, 2022 @01:48PM
(#30076137)
If you're writing UI code then even a few seconds is slow. You don't want to be waiting 5 seconds every time you move something a couple of pixels to the left.
Re:I’m porting the TypeScript type checker tsc to Go
by eatonphil on Tuesday January 25, 2022 @01:43PM
(#30076031)
There is a huge difference even in small and mid-size projects.
https://datastation.multiprocess.io/blog/2021-11-13-benchmar...
I don't think I'm remotely alone in doing this but I'll share from my perspective. I have two modes while writing TypeScript stuff: 1) prototyping something where I don't want to spend time writing types (or maybe I write some types but I don't care if they are correct or line up yet) but I still want to have JavaScript generated so I can test the thing out manually and 2) getting types correct as part of long-term maintenance and edge-case removal.
There are fast TypeScript -> JavaScript generators today like swc and esbuild. tsc is not fast. So I can speed up "1)" from above if I use swc and esbuild and only use tsc for "2)" from above.
As people write faster implementations of tsc-the-type-checker though I'll be happy to use that instead and just not use tsc anymore.