4 ms·
> The sluggishness of tsc remains a pain point for many developers tsc isn't just slow, it's SLOW. % : >file.ts % time tsc file.ts tsc file.ts 3
by Beltalowda 4y ago
> The sluggishness of tsc remains a pain point for many developers
tsc isn't just slow, it's SLOW.
% : >file.ts
% time tsc file.ts
tsc file.ts 3.26s user 0.15s system 145% cpu 2.347 total
3.2 seconds is just embarrassing. Nothing is even close to this; every other compiler or interpreter is in the dozens or maybe low-hundreds of ms. clang++ -O2 and rustc are both ~150-200ms, and these are not compilers known for their excellent performance. The startup time of tsc is an order of a magnitude slower than anything else. I didn't measure lines of code/second performance, but with such a slow startup time it's not that important because no matter how small your project: typescript will be ridiculously slow.
I don't want to run any "watchers" or special dev servers for the frontend or all of that ridiculously complex circus to work around this embarrassingly slow tooling. I just want to request "/file.ts" and have it serve a compiled version on the fly. This is simple, easy, and even with caching just a few lines of code. It's how everyone was using coffeescript back in the day.
What we have now is millions of lines of code and a world of complexity to work around an embarrassingly slow compiler.
- deleted 4y ago[deleted]
- Gigachad 4y agoIs it really much of an issue? I work on a large TS project on a 2020 m1 MacBook and I’ve never been aware of the ts compilation. It seems snappy enough.
- Beltalowda 4y ago> Is it really much of an issue? Yes, because I don't want to wait seconds every time I change a typescript file and I don't want to world of complexity to make it have the same performance every other compiler has out of the box. My "solution" for this is to not use typescript. I'd like to, but it's just too painful.
- nawgz 4y agoSo you are writing naked JS or what? A lot of developers decided slow compiles - I don’t know what pathological case you stumbled on to make a single file take 3s tho - is far superior to needing to suss out runtime errors, and I find it hard to believe you made the choice to write naked JS instead of TS. If you picked a different language, fair enough I suppose, but I have to admit I’m not that sure why someone would tap JS/TS if another language is equally suitable. I am a front end guy after all, so I don’t particularly have a choice
- Beltalowda 4y ago> I don’t know what pathological case you stumbled on to make a single file take 3s tho It's an empty file. It's not a "pathological" use case. It's simpler than "hello world". It's literally the simplest possible use case. I do have to say I have a fairly slow laptop, but everything else is plenty fast enough. > I find it hard to believe you made the choice to write naked JS instead of TS Why is this hard to believe? Most things I work on are a few hundred lines, maybe 2,000 lines at the most. Not huge, but not trivial either. Some of these are personal projects, on some I work as a contractor. Many have an uneven pace of development: lots for a bit, then nothing for months or years. I want stuff to "just work", even after 2, 3, or more years, and I don't want to update loads of tooling every time I come back to it. This is already a bit of an issue in JS-world in general, so I try to keep things simple. This means, among other things, simple build steps. With a okay-ish performance (doesn't even need to be "fast") you can keep builds very simple. With the current performance this is a lot harder and you need a lot more complexity to make it work smoothly.
- deleted 4y ago[deleted]
- Gigachad 4y agoYour setup must not be right. The one I’m using at work reloads the page when I save in the editor so by the time I switch to the browser window it’s already loaded. Basically no perceivable compile time.
- lkschubert8 4y agoI suspect you have a different development style than the person you replied to. For test driven development or any development style that validates constantly on file updates seconds is bit frustrating.
- ihateolives 4y agoYes it is. My work laptop is 8th gen i7 (yeah, I know) and every time I have to recompile the whole project I'll have few minutes of downtime. It's too little time to do something else but too much to just stretch, yawn and continue. It's ridiculous. Yeah, most things can be solved throwing more horsepower at it, but currently it's as slow as gradle building with my java projects ffs.
- kaleidawave 4y agoNot sure but I think startup time is impeded by the fact that tsc has to parse and synthesize around 20k+ lines of TS definition files. These require a parse for hoisting, require scanning lots of comments which are only used in LSP mode and are not a optimised format to parse. On the other hand Ezno a semi compatible TypeScript compiler can use a more low level binary format which is only one pass and whose name references are already resolved https://twitter.com/kaleidawave/status/1596445852918325250?s=46&t=XHG-RZePBgDXFYAaI991Bw https://twitter.com/kaleidawave/status/1596445852918325250?s... . This is only really possible because it is written in Rust so low level byte and memory management is relatively simple