TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Architecture for a JavaScript to C compiler

90 点作者 timruffles超过 6 年前

8 条评论

snek超过 6 年前
I don't understand why people keep making js-to-native compilers. the result is always less performance that what modern js engines can do to the original source code, because all those runtime behaviours the author mentions build up really fast. js engines actually run the code and figure out the types and such to create highly optimized machine code.
评论 #19159394 未加载
评论 #19159464 未加载
评论 #19159626 未加载
评论 #19160748 未加载
评论 #19160638 未加载
评论 #19159938 未加载
评论 #19160669 未加载
truth_seeker超过 6 年前
I wonder how much optimization will it bring to compared to existing JS runtimes such as V8.<p>Thanks to competing world for web browsers, JS runtimes not only efficiently parse to optimized native code but also provide really good JIT compilation benefits.<p>Speculative optimization for V8 - <a href="https:&#x2F;&#x2F;ponyfoo.com&#x2F;articles&#x2F;an-introduction-to-speculative-optimization-in-v8" rel="nofollow">https:&#x2F;&#x2F;ponyfoo.com&#x2F;articles&#x2F;an-introduction-to-speculative-...</a><p>Parallel and Concurrent GC - <a href="https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;trash-talk" rel="nofollow">https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;trash-talk</a><p>Good summary on 10 years of V8 - <a href="https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;10-years" rel="nofollow">https:&#x2F;&#x2F;v8.dev&#x2F;blog&#x2F;10-years</a>
评论 #19160654 未加载
rkeene2超过 6 年前
A lot of research and hard work has gone into TclQuadCode [0], which compiles Tcl (which is even more dynamic than JavaScript) into machine code via LLVM.<p>The authors indicated at one point it took around 5 PhDs to get it going.<p>[0] <a href="https:&#x2F;&#x2F;core.tcl.tk&#x2F;tclquadcode&#x2F;dir?ci=trunk" rel="nofollow">https:&#x2F;&#x2F;core.tcl.tk&#x2F;tclquadcode&#x2F;dir?ci=trunk</a>
评论 #19159553 未加载
ndesaulniers超过 6 年前
I actually think this is possible; and started prototyping it (because esprima is awesome, and not to many other languages have an equivalent that&#x27;s so easy to use).<p>Some thoughts: I think it&#x27;s easier to target C++ than C, since C++ can help you write more type generic code. I think it&#x27;s easy to generate tagged unions, then for optimizations try to prove monomorphism. Finally, it may be simpler to start off with support for typescript, and fail to compile if there are any ANY types. I do think it&#x27;s possible though. JS&#x2F;TS -&gt; C++ -&gt; WASM (yes, I was out of my mind when I thought of this)
评论 #19159861 未加载
maxxxxx超过 6 年前
With all the dynamic stuff Javascript has it seems really difficult to create performant C code.<p>There is a PHP to .NET compiler which probably has similar problems. On second thought that one is probably easier because .NEt has a dynamic runtime.
评论 #19159405 未加载
tannhaeuser超过 6 年前
Congrats to completing this project. What&#x27;s the status and further plans for it? I didn&#x27;t find a license.
ridiculous_fish超过 6 年前
How are exceptions handled with this design? For example the `n &lt; 3` may throw (it invokes the valueOf method).
评论 #19159621 未加载
maxgraey超过 6 年前
I wonder why people still try write transpiler from JS to C&#x2F;C++ or LLVM (which make sense at least). But this not performant way and usually produce much bigger overhead than jit vm which use speculative optimizations.<p>Some projects: 1. <a href="https:&#x2F;&#x2F;github.com&#x2F;fabiosantoscode&#x2F;js2cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fabiosantoscode&#x2F;js2cpp</a> 2. <a href="https:&#x2F;&#x2F;github.com&#x2F;raphamorim&#x2F;js2c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;raphamorim&#x2F;js2c</a> 3. <a href="https:&#x2F;&#x2F;github.com&#x2F;ammer&#x2F;js2c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ammer&#x2F;js2c</a> 4. <a href="https:&#x2F;&#x2F;github.com&#x2F;NectarJS&#x2F;nectarjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;NectarJS&#x2F;nectarjs</a> 5. <a href="https:&#x2F;&#x2F;github.com&#x2F;ovr&#x2F;StaticScript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ovr&#x2F;StaticScript</a>