Hacker News new | ask | show | jobs
by endisneigh 1008 days ago
You should Typescript. Performance comparable to Go. A more flexible typing system than both. Easier to learn than both. A worse package system, but that can be mitigated with discipline. What Typescript currently lacks the most is affordances for embedded or performance intensive work as it's single threaded, but when performance matters use NAPI to use Rust in your Typescript, but the trajectory of performance of V8 and Webkit is such that I wouldn't be surprised if Typescript is within the same order of magnitude for performance as Rust soon enough.

:P

2 comments

Typescript uses an order of magnitude memory that Go. It also doesn’t support concurrency. With on Go pod you can have a web server that automatically uses multiple cores. You’ll get better performance in the real world as a result. You’ll pay less for it too.
Yes, Javascript is single threaded. This has its benefits and drawbacks. In many applications using the Cluster API is enough, but as you said you'll never be able to do super performance stuff with Javascript, but you can use NAPI and call Rust if you'd like.

Memory usage is pretty good with Go, yes. I'm skeptical how much this matters in a real world application, though.

HN's memory usage obsession is basically a meme now. You'll see vastly more JS consternation here for RAM usage than praise for benefits like getting MVPs up stunningly fast, having a gigantic hiring pool, using one codebase to deploy on every major platform, etc. (These critics are often ironically the same folks who endorse avoiding premature optimization.)

And hey, memory usage can be crucial! But the community's distorted emphasis on it is almost comical, when compared to reality. I think it's an understandable perspective, given some devs' proximity to bare metal. But man I wish it wasn't such an omnipresent refrain here. :/

It’s great for bootstrapping. A $5 droplet at Digital Ocean is more affordable than $25 per month. The same is true if you take advantage of lambdas. Quick boot up. Able to do more CPU work per unit of time. All because it’s fast and low memory.

Also the dependency world isn’t as messed up at it is in Typescript. I’ve been spending the better part of my time fixing dependabot issues. Some package I don’t know about is causing me to have to upgrade everything. Crazy stuff.

Is it really meme? There is often opinion that developer and business friendly process is more important than user experience and energy resources.

I do not think that there is single narrative.

I love TypeScript for back-end work. Node.js is astonishingly fast, thanks to V8. TS is concise, has a wonderful/expressive type system, can share code/types with the front-end, and has libraries for damn near everything.

It's the easy choice for new projects. And yeah, if/when it's time to optimize later, and the raw performance of V8 ain't enough, you can reach for threads, WASM, or Rust. 10/10 experience.