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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: What current common languages use an AST interpreter?

1 点作者 wassenaar10超过 3 年前
Pretty much what the title says.<p>AST (abstract syntax tree) interpreters are about the easiest form of language implementation to write, but they typically result in pretty slow performance due to the amount of memory they take up, the additional instructions involved in evaluating an AST, and the difficulty in making them cache-efficient. For this reason, it seems that most interpreted (or traditionally interpreted, e.g. &quot;scripting languages&quot;) opt to use some combination of a bytecode interpreter or JIT-compilation for their most common implementations. Examples include Python , JavaScript, PHP, Lua, Perl, and so on.<p>I&#x27;m curious, however, what common (feel free to stretch the definition of &quot;common&quot;) programming languages or implementations use an AST interpreter instead. From what I can tell it&#x27;s not many - Matz&#x27;s Ruby Interpreter is one of them, but I&#x27;m not very deep into the Ruby world and I don&#x27;t know how common it is to use MRI vs another implementation. Besides that, I find it likely that many command line languages (bash, zsh, cmd.exe, powershell, etc.) and some Unix utils (like sed or awk, which are programming languages, albeit small ones) are implemented as simple AST interpreters since the most common usage patterns for these languages are short-running or IO-bound scripts and commands.<p>Curious to hear what everyone has to say and if any of my assumptions are incorrect.

2 条评论

armchairhacker超过 3 年前
Some languages might have prototype or deprecated fallback AST interpreters. I know that R has a fallback AST interpreter although unless you run with a special flag you’ll run the byte code compiler.<p>Simple DSLs might have AST interpreters, or any sort of language where speed <i>really</i> doesn’t matter.
pipeline_peak超过 3 年前
None…..lol A common language is expected to run as fast as it can. It is usually designed by specialists knowledgeable enough to implement a byte code vm.<p>AST interpreters are found in, as you said, traditional Unix interpreters, undergrad projects, and toy languages. They are an outdated concept, and rightfully so because they aren’t much more easier to develop than a byte code compiler anyway.<p>You could think the benefit would be AST modifications at runtime like Lisp. But even then, I don’t think that’s an exclusive feature.