TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Is it possible to compile TypeScript to Golang?

9 pointsby alexbezhanabout 2 years ago
Typescript lets me write the complex logic, but the Node concurrency model being single-threaded is very limited.<p>So ideally I would want to have Typescript running in Golang. Is there such a possibility?

10 comments

pc_edwinabout 2 years ago
This is not directly related to question but I would suggest using go just for those use cases.<p>Programming in general has become a lot more abstract and standardised so with some exceptions (C&#x2F;rust) you can easily use multiple languages without incurring much if any costs.<p>Something else you can do thats slightly unorthodox is to write in typescript then ask chatGPT to rewrite your code in golang. You still have to maintain in golang but you get do the initial implementation part in typescript.
fathybabout 2 years ago
No, the Go threading runtime is fundamentally incompatible with JavaScript&#x27;s event-loop model. TypeScript does not define runtime semantics, JavaScript does, and it&#x27;s built to run in a single-threaded environment. You cannot use it to leverage Go&#x27;s coroutines unfortunately.
评论 #35325265 未加载
评论 #35314564 未加载
thesuperbigfrogabout 2 years ago
It sounds like you need a language that supports stronger types and concurrency.<p>There are many good programming languages that might work if neither Go nor Typescript individually would meet your needs.<p>I recommend examining the following to see if they would work better for you:<p>Ada: <a href="https:&#x2F;&#x2F;learn.adacore.com&#x2F;courses&#x2F;intro-to-ada&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;learn.adacore.com&#x2F;courses&#x2F;intro-to-ada&#x2F;index.html</a><p>Elixir: <a href="https:&#x2F;&#x2F;elixir-lang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;elixir-lang.org&#x2F;</a><p>Java: <a href="https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;tutorial&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;tutorial&#x2F;</a><p>Rust: <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;</a><p>All of them have excellent support for concurrency and strong typing to various degrees that help you to write complex logic quickly.
评论 #35314330 未加载
评论 #35314175 未加载
fromabout 2 years ago
Why are routine technical questions constantly appearing on HN? Ask on a specific subreddit Reddit or Stackoverflow.
aristofunabout 2 years ago
Ts is dynamically typed unfortunately. And also this implies the whole js library to be made thread safe.<p>But the good thing is A. Horizontal scalability is far better approach for most usecases anyway B. Nodejs is so performant youd rarely beat it with other GC languages in real applications.
评论 #35314194 未加载
patricktheboldabout 2 years ago
It would be helpful to know what specific problems you have with the single threaded model. You might still have some options staying with node. I think you can have worker threads but maybe you can&#x27;t share memory, or you might be able to run multiple node processes.<p>Otherwise you probably want to just switch to go.
techn00about 2 years ago
Write concurrent heavy tasks in Go. Write other tasks in typescript.<p>Use <a href="https:&#x2F;&#x2F;connect.build" rel="nofollow">https:&#x2F;&#x2F;connect.build</a> to connect them.
Alifatiskabout 2 years ago
I don&#x27;t think it&#x27;s possible to run Ts in Golangs compiler. Have you considered rewriting your code to Go?
crop_rotationabout 2 years ago
No, it is not (nor does it seem feasible). Why not just spin up multiple workers?
bkqabout 2 years ago
&gt;Typescript lets me write the complex logic<p>What is it about Go that prevents you from writing this complex logic?