编程语言的第二种实现可以用该语言编写吗?

发布于 2024-09-10 13:18:31 字数 125 浏览 1 评论 0原文

这个问题只是我最近一直在思考的问题。一种编程语言可以用该语言编写作为第二种实现吗?例如Java。是否可以使用java编程语言重写java编程语言?

如果这是一个愚蠢的问题,我很抱歉,但我需要知道!

GF

This question is just something that I have been thinking about lately. Can a programming language be written in that language as a second implementation? e.g. Java. Is it possible to rewrite the java programming language using the java programming language?

Apologies if this is a silly question but I need to know!

GF

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

感情洁癖 2024-09-17 13:18:31

总是。任何图灵完备语言都是——好吧——图灵完备语言。如果您可以用一种完整的语言编写编译器,那么您就可以用任何等效的语言编写它。

Always. Any Turing-Complete language is -- well -- a Turing-Complete language. If you can write the compiler in one complete language, you can write it in any equivalent language.

格子衫的從容 2024-09-17 13:18:31

是的,这是可能的。查看 BootStrapping

Yes, it is possible. Check out BootStrapping.

双手揣兜 2024-09-17 13:18:31

对于任何图灵完备语言都是如此。 Lisp 被认为是最容易为自己编写解释器/编译器的语言之一。

Yes for any Turing Complete language. Lisp comes to mind as one of the easiest languages to write an interpreter/compiler for itself.

胡渣熟男 2024-09-17 13:18:31

可以。最近的一个例子是 python 有 pypy。维基百科页面上有更多信息和一些很好的链接。

It can. A recent example is that python has pypy. A little more information is on the Wikipedia page and some good links.

强辩 2024-09-17 13:18:31

当然。

许多年前,我的第一台家用计算机 Vic 20 配备了内置 BASIC 解释器,但仅此而已。所以我用 BASIC 为它编写了第一个版本的汇编程序。然后我用我的第一个原始汇编器编写了一个更好的汇编器。

Sure.

Many many years ago one of my first home computers, a Vic 20, came with a built-in BASIC interpreter but that was it. So I wrote the first version of an assembler for it in BASIC. Then I used my first primitive assembler to write a better assembler.

無處可尋 2024-09-17 13:18:31

是的。只要该语言是图灵完备的,您就可以实现该语言本身。

Yes. As long as the language is Turing Complete, you can implement the language in itself.

梦一生花开无言 2024-09-17 13:18:31

一书中免费提供:

这方面有很多实际例子,其中一个例子是 Oberon 语言,它在本次讨论中很有趣,因为编译器代码非常易读,它在《Project Oberon 》 oberon.ethz.ch/bibliography/publications" rel="nofollow noreferrer">http://www.oberon.ethz.ch/bibliography/publications

http://en.wikipedia.org/wiki/Bootstrapping_(编译器)

There are many practical examples of this, one example is the Oberon Language, which is of interest in this discussion because the compiler code is very readable it's in the book Project Oberon available for free:

http://www.oberon.ethz.ch/bibliography/publications

http://en.wikipedia.org/wiki/Bootstrapping_(compilers)

燃情 2024-09-17 13:18:31

GCC 编译器是用 C 编写的。

自从有人从汇编语言构建任何 C 编译器以来已经很长时间了。

The GCC compilers are written in C.

It has been a long time since anyone built any C compilers from assembly.

慢慢从新开始 2024-09-17 13:18:31

不仅可能,而且对于本机代码编译器来说,这是最常见的实现技术。 Andrew Appel 的论文 公理引导:编译器黑客指南

Not just possible, but for native-code compilers, this is the most common implementation technique. A good how-to guide is Andrew Appel's paper Axiomatic Bootstrapping: A Guide for Compiler Hackers.

纵山崖 2024-09-17 13:18:31

它不仅可以,而且确实如此。 ecj(Eclipse 的编译器)就是一个例子,我认为 SDK 本身附带了一个纯 Java 编译器,尽管我的看法可能是错误的。

It not only can, it is. ecj (Eclipse's compiler) is one example, and I think the SDK itself comes with a pure Java compiler, though I could be wrong about that.

静谧幽蓝 2024-09-17 13:18:31

用java编写一个java编译器——完全没问题。实际上我认为Sun的javac是用java编写的。

然而,“java”通常意味着比 javac 更多的东西,所以你的问题不是很清楚。

write a java compiler in java - no problem at all. actually I think Sun's javac is written in java.

however, 'java' usually means more things than just the javac, so your question isn't very clear.

小梨窩很甜 2024-09-17 13:18:31

当然。我什至见过有人用 COBOL 编写了 COBOL 编译器! (好吧,不是一个完整的编译器......但至少是一个解析器。)

Sure. I've even seen someone write a COBOL compiler written in COBOL! (OK, not a full compiler ... but at least a parser.)

美人迟暮 2024-09-17 13:18:31

查看 3-LISP

Check out 3-LISP

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文