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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Making a Mini-Lisp: Introduction to Transpilers in JavaScript

78 点作者 gdi2290超过 9 年前

6 条评论

ane超过 9 年前
Is the ad hoc distinction between compilation and "transpilation" really worth it? Can't we just call them compilers? I get that the difference between compilation and transpilation is that the target language of the latter is not a lower lever language, which would be in the case of C and Assembler, but that it targets a language that's more or less of a similar level. Is this really worthy of another term? I'm not sure.
评论 #10789022 未加载
评论 #10789119 未加载
评论 #10789021 未加载
评论 #10789011 未加载
评论 #10790339 未加载
lisper超过 9 年前
The language being defined here is not a Lisp, it&#x27;s a (trivial) language that just happens to use (something like) S expressions as the surface syntax. (The reason it&#x27;s only &quot;something like&quot; S expressions is that it has ad-hoc commas to delimit argument lists.)<p>The characteristic that defines a Lisp is that code is not a sequence of characters, it&#x27;s a data structure -- typically a tree of cons cells -- which can be manipulated within the language itself. The language being defined here doesn&#x27;t have that property.<p>It is this property that allows you to write macros, which is what makes Lisp cool. Without it you don&#x27;t have Lisp, you just have a run-of-the-mill programming language with weird syntax.
评论 #10790760 未加载
评论 #10790472 未加载
sinamdar超过 9 年前
Shameless Plug here.<p>Inspired by Peter Norvig&#x27;s &#x27;How to write a Lisp Interpreter in Python&#x27;, I created three variants of it along the same lines as the OP. The first is a Simple Lisp Interpreter in Javascript [1]. The second separates Syntactic Analysis from Execution [2]. And the third supports non deterministic computing [3].<p>[1] <a href="https:&#x2F;&#x2F;bitbucket.org&#x2F;sainamdar&#x2F;lisp2js" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;sainamdar&#x2F;lisp2js</a><p>[2] <a href="https:&#x2F;&#x2F;bitbucket.org&#x2F;sainamdar&#x2F;lisp2js2" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;sainamdar&#x2F;lisp2js2</a><p>[3] <a href="https:&#x2F;&#x2F;bitbucket.org&#x2F;sainamdar&#x2F;lisp2js2nd" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;sainamdar&#x2F;lisp2js2nd</a>
wtbob超过 9 年前
As someone who&#x27;s been working on figuring out a way to transpile or interpret a powerful dynamic language to Lua, JavaScript, Python and Go, the really tough thing to do is non-local exits. If you can solve that, I think that everything else is easy (well, a Simple Matter of Programming anyway).<p>It&#x27;s okay if your target language already supports non-local exits, particularly parameterised ones (although even that can be faked with a well-designed global), but if it doesn&#x27;t then it&#x27;s a pain (imagine how you&#x27;d do it in Go: every single function call will return an additional value, indicating if a non-local exit is intended).<p>Alternatively, imagine trying to transpile call&#x2F;cc to JavaScript…
评论 #10789323 未加载
评论 #10789889 未加载
tlack超过 9 年前
Great article! Really accessible for a newbie. I&#x27;d love to see a comparison between using a manual lexer&#x2F;parser like the one seen here and using OMeta&#x2F;JS, which seems like a real time saver for people playing around with languages. <a href="https:&#x2F;&#x2F;github.com&#x2F;alexwarth&#x2F;ometa-js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;alexwarth&#x2F;ometa-js</a>
评论 #10789308 未加载
Scotups超过 9 年前
formatting on code sample was wonky, just fixed them , refresh and enjoy!