Ask HN:TS 编译器

3 分•作者: apple_george•大约 2 个月前
大家好,我是一名经验丰富的 JavaScript 和 TypeScript 开发者。 我之所以比其他任何语言都更喜欢 JavaScript,是因为它能让我轻松地表达自己。不知何故,我用 JavaScript 或 TypeScript 比用其他任何语言都更容易表达自己。 我认为,我们都清楚 JavaScript 的一些不足之处,以及 Go 的强大之处。 我认为我们都非常喜欢 Go 的一个特性就是 goroutines。 我一直在认真思考如何创建一个包含类似 goroutine 功能的 TypeScript 版本。 我曾认真地讨论过如何实现这一点,包括修改 V8、构建自己的自定义编译器等等。 经过深思熟虑,我找到了我认为处理这个问题最好的方法。我认为最终最好的方法是,从 Go 编译器开始,修改它的解析器,使其能够解析 TypeScript。 我设想的实现方式是:首先,我们创建一个完美的 TypeScript 到 Go 的转译器。 一旦转译器完美工作,我们就进入下一步,即修改 Go 的解析器,使其能够内部解析 TypeScript,并将其转换为 Go 编译器使用的结构化表示。 我相信这将是最有效,也是最重要的,是创建真正的 TypeScript 编译器的最简单途径。 我想在此寻求一些帮助来构建这个项目,因为不幸的是,我现在没有电脑,也没有任何钱。 如果有人愿意借一台笔记本电脑,或者提供 Codex 或类似的订阅服务,我将非常乐意开始。 我在网上看到有人用 OXC 和 LLVM 构建了一个 TypeScript 编译器,我觉得这非常酷。然而,我认为,为了让 TypeScript 成为人们真正喜欢使用的东西,最终它必须拥有类似 goroutine 的功能。 另外,既然我们谈到了,我认为我们还应该添加类似能够正确处理切片语法的功能,这样我们就可以在 TypeScript 中进行人工智能开发。 老实说,现在 AI 几乎能编写所有代码,我不太确定编程语言还有多重要,但我仍然认为这是一个有趣的可以着手做的项目。 我认为这个项目的主要缺点是,现在几乎所有人都用 Rust 编写代码,然后编译成 WebAssembly 等等,所以鉴于 AI 已经能够编写所有代码,我不确定这是否仍然是一个值得做的项目,但我很想听听大家的想法。
查看原文
Hey everyone, I am an experienced JavaScript and TypeScript developer.<p>What I love about JavaScript more than any other language is that it is so easy for me to express myself. It’s easier for me to express myself in JavaScript or TypeScript than any other language for some reason.<p>I think we all, however, are really aware of some of the shortcomings of JavaScript and of how amazing Go is.<p>The feature about go that I think we all really love is goroutines.<p>I have thought really hard about making a version of TypeScript that includes the ability to do something like a goroutine.<p>I have seriously debated how to make this work, including modifying V8 building my own custom compiler, etc.<p>After much thought, I have come across what I believe is the best way to handle this. I think ultimately the best way to do this would be to start with the go compiler and to modify it’s parser so that it can actually parse TypeScript.<p>The way I envision this working is first what we do is we create a perfect TypeScript to go transpiler.<p>Once we have the transpiler working perfectly then we take the next step which would be to actually modify the parser in Go to internally parse it and convert it to the structured representation that the go compiler uses.<p>I believe that this is going to be the most efficient and most importantly, the easiest route to making a true type script compiler.<p>I would like to get some help on building this because unfortunately I no longer have a computer or any money right now.<p>If anyone would like to loan a laptop and a Codex or some type of a subscription like that, I would love to get started.<p>I saw on here that somebody made a type script compiler that uses OXC and LLVM which I think is really cool. However, I think that in order for type script to be something that people really like using it’s gonna have to have something like go routines in the end.<p>Also, while we are at it, I think we should go ahead and add something like the ability to handle slice syntax correctly so that we can do artificial intelligence in type script.<p>Honestly, now that AI codes everything I’m not really sure that the programming language matters that much but I still think it would be a fun project to work on.<p>I think the major downside to this is that essentially everybody now is writing everything in rust and compiling it down to Web assembly and stuff like that so I’m not sure if this is actually a worthwhile project to do at all now that AI codes everything but I would love to know everyone’s thoughts.