是否有任何语言既没有解释器也没有编译器?

发布于 2024-09-09 09:19:22 字数 327 浏览 7 评论 0 原文

注意:我的意思不是一些没有任何实现的理论问题,只是没有两者的语言!!!!


如今,存在 ac/c++ 解释器(cint)和 python 编译器(到 python 字节码)。

我理解最简单的定义是编译器只是将代码从语言a转换为语言b,然后你有一台机器将它与输入一起运行,而解释器只是接受输入加上语言a中的代码并运行它。如果某个东西有解释器或编译器,那么使用这些定义就可以相当简单地通过立即运行编译器的输出或嵌入带有源代码的编译器来获得解释器来获得另一个。

因此,忽略那些既没有编译器(将 A 到 B 的源代码编译为中间语言,最好是中间语言)和运行大量代码而不编译它们的解释器的语言?

Note:I don't mean some theoretical question which don't have any implementation just languages that don't have both!!!!!


These days there exists a c/c++ interpreter(cint) and a python compiler(to python bytecode).

I understand that the simplest definition is that a compiler just converts code from language a to language b, and then you have a machine which runs b it together with input, while an interpreter is simply something that takes input plus code in language a and runs it. And that using these definitions if something has an interpreter or compiler its fairly simple to get the other by immediately running the output of the compiler or embedding the compiler w/ the source code to get an interpreter.

So ignoring those which languages don't have both a compiler (which compile source code in A to B preferably an intermediate language) and an interpreter that run large chunks of code without compiling them?

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

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

发布评论

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

评论(11

故笙诉离歌 2024-09-16 09:19:22

有几种深奥语言缺乏编译器或解释器,因为它们只是被设计为智力练习,并正在等待有人真正实施它们。

There are several esoteric languages that lack either a compiler or interpreter, as they have been designed merely as intellectual exercises, and are waiting for someone to actually implement them.

↙厌世 2024-09-16 09:19:22

拉丁语和阿拉姆语。两种已消亡的语言都有翻译,但没有足够的现场使用者来保证任何口译员的存在。你可以添加克林贡语,但我怀疑现在确实有翻译人员。

Latin and Aramaic. Two dead languages with translators but insufficient live speakers to warrant any interpreters. You could add Klingon, but I suspect that there actually interpreters for that now.

眼泪都笑了 2024-09-16 09:19:22

基于翻译的语言怎么样?示例:几乎任何机器组装。汇编器只是将代码翻译为机器操作码。

How about translator based languages? Example: pretty much any machine assembly. The assembler just translates code into the machine opcodes.

寄人书 2024-09-16 09:19:22

如果解释器是指交互式执行部分代码的工具,
然后硬件描述语言(VHDL,Verilog,...)我认为没有这些。
大多数人将 VHDL 和 Verilog 描述模拟为整体来检查网络(咳咳)效果。
Verilog 和 VHDL 最终编译成门(用于 FPGA)并
用于实现为芯片的晶体管电路。

同样,我认为您不会找到许多交互式约束求解器语言。
与硬件设计语言一样,约束程序主要执行
作为整体,因为部分约束会产生太多答案。
约束求解器语言通常被编译为较低级别的表示
它的“处理”多于传播约束的解释
基于依赖性。

一般来说,这些都不会产生“机器指令”。

If by interpreter you mean a tool that executes part of the code interactively,
then hardware description languages (VHDL, Verilog, ...) I think don't have these.
Mostly people simulate VHDL and Verilog descriptions as monoliths to check the net (ahem) effect.
Verilog and VHDL are compiled ultimately into gates (for FPGAs) and
transistor circuits for implementation as chips.

Similarly, I don't think you'll find many interactive constraint-solver languages.
Like the hardware design langauges, constraint programs are mostly executed
as monoliths, because a partial constraint will produce too many answers.
Constraint solver languages are often compiled to a lower level representation
which is "processed" more than interpreted by propagating constraints
based on dependences.

As a general rule, neither of these produces "machine instructions".

檐上三寸雪 2024-09-16 09:19:22
  Compiler vs. Interpreter

解释器将某种形式的源代码转换为可以立即执行和评估的目标表示形式。解释器的结构与编译器的结构类似,但生成可执行表示所需的时间会有所不同,优化量也会有所不同。下图显示了差异的一种表示。
形象的
编译器特性:

* spends a lot of time analyzing and processing the program
* the resulting executable is some form of machine- specific binary code
* the computer hardware interprets (executes) the resulting code
* program execution is fast

解释器特性:

* relatively little time is spent analyzing and processing the program
* the resulting code is some sort of intermediate code
* the resulting code is interpreted by another program
* program execution is relatively slow


(来源:gpollice在 web.cs.wpi.edu)

  Compiler vs. Interpreter

An interpreter translates some form of source code into a target representation that it can immediately execute and evaluate. The structure of the interpreter is similar to that of a compiler, but the amount of time it takes to produce the executable representation will vary as will the amount of optimization. The following diagram shows one representation of the differences.
graphic
Compiler characteristics:

* spends a lot of time analyzing and processing the program
* the resulting executable is some form of machine- specific binary code
* the computer hardware interprets (executes) the resulting code
* program execution is fast

Interpreter characteristics:

* relatively little time is spent analyzing and processing the program
* the resulting code is some sort of intermediate code
* the resulting code is interpreted by another program
* program execution is relatively slow

alt text
(source: gpollice at web.cs.wpi.edu)

夏至、离别 2024-09-16 09:19:22

可编程逻辑控制器 (PLC) 的梯形图语言没有编译器或解释器。梯形图被转换为布尔条件来管理输入、输出和内存状态。梯形图每秒被评估数千次,以便在硬件上实际运行代码。

祝你好运!

参考:维基百科上的可编程逻辑控制器

The ladder language for programmable logic controllers (PLC) has no compiler or interpreter. The ladders are converted into boolean conditions to manage inputs, outputs and memory states. Ladders are evaluated thousands times a second to actually run the code on the hardware.

Good luck!

Reference: Programmable logic controller on Wikipedia

扛起拖把扫天下 2024-09-16 09:19:22

因此,我在此之前声明:任何具有固定语义、能够表达可计算函数的语言都是可实现的。我在这里对冲我的赌注,没有具体说明我所说的“语义”是什么意思,但我通常指的是操作语义(大步或小步)、指称语义或公理语义。

因此,除此之外,还存在两个问题:是否存在根本没有任何语义的语言(因此无法通过任何通常的方式实现),或者是否存在尚未实现的语言,尽管有可能这样做?

后一种情况显然是正确的,但并不是很有趣。仅仅因为人们梦想出一种语言并不意味着它是一个好主意。我现在就可以想到一种语言,它不会有编译器或解释器。不是很有趣。

前一个案例更有趣一些。有些语言实际上是逻辑并且(通过 Curry-Howard 对应关系)这些逻辑中的证明也是程序(反之亦然)。如果逻辑不可判定,或者语言包含某种不强规范化的高阶结构(例如某些非常具有表现力的类型系统),那么编译或解释就会变得有点可怕。这可能开始接近“不编译或解释”的领域,但这是一个有点虚假的说法,因为如果我们可以让计算机操纵这些符号,我们就可以编写一个解释器。类似地,如果它没有语义,那么它可能不会在可计算函数上运行 - 那时它可能只是某种自然语言,不再是“编程语言”。

这尤其正确,因为我们可以认为 丘奇-图灵论文说总是有可能为图灵完备的语言编写一个解释器,即使该解释器最终成为另一个图灵机。

我看到其他一些答案已经提出了有关机器语言的主张。机器语言没有什么神奇之处,只是它具有非常紧凑的表示形式。人们可以很容易地为其编写一个解释器,并且存在许多解释器(例如,忠实地在软件中实现硬件处理器的执行语义的各种虚拟机)。

满足您的标准的语言很可能是没有执行语义的语言,即它们不表达可计算函数。据我所知,以下是几种具有固定语义的语言,它们不能通过解释器直接执行,也不能通过将它们编译为其他任何东西而不用附加信息丰富这些程序

So I preface this with a claim: any language that has a fixed semantics that can express computable functions is implementable. I'm hedging my bets here by not saying specifically what I mean by the "semantics", but I generally mean something that is either an operational semantics (big or small step), a denotational semantics, or axiomatic semantics.

So, with that out of the way, there remain two questions: Are there languages which don't have any semantics at all (and are therefore not implementable by any of the usual means), or are there languages which haven't been implemented, despite it being possible to do so?

The latter case is obviously true, but it's not very interesting. Just because people dream up a language doesn't mean it's a good idea. I could think of a language right now, and it wouldn't have a compiler or an interpreter. Not very interesting.

The former case is a little more interesting. There are languages that are actually logics and (via the Curry-Howard correspondence) proofs in these logics are also programs (and vice-versa). If the logic is not decidable, or if the language includes some kind of higher-order constructs that are not strongly normalising (such as some very expressive type system), then compilation or interpretation becomes a slightly scary affair. This might start to verge into the territory of "not compiling or interpreting", but that's a slightly spurious claim, because if we can make a computer manipulate these symbols, we can write an interpreter. Similarly, if it has no semantics, then it's probably not operating over computable functions - it's probably just natural language of some kind at that point, no longer a "programming language".

This is especially true because we can argue that the Church-Turing thesis says that it will always be possible to write an interpreter for a Turing-complete language, even if that interpreter ends up being another Turing machine.

I see some other answers have made claims about machine language. There is nothing magical about machine language except that it has a very compact representation. One could very easily write an interpreter for it, and many exist (e.g. the various virtual machines that faithfully implement the execution semantics of a hardware processor in software).

The languages that meet your criteria are likely to be ones that have no execution semantics, i.e. they do not express computable functions. Here are a couple languages with fixed semantics I know of that are not directly executable by either an interpreter or by compiling them to anything else without enriching these programs with additional information:

云之铃。 2024-09-16 09:19:22

一些小型 RISC 机器代码两者都没有,因为它们所做的只是推动位。没有解释,因为没有可能的较低级别来运行它,并且没有编译,因为它已经是 0 和 1。

A few small RISC machine codes don't have either, since all they do is push bits around. There's no interpretation since there is no possible lower level to run it at, and there's no compilation since it's already 0s and 1s.

神回复 2024-09-16 09:19:22

我的一位同学可以通过在 CALL -151 之后输入所有十六进制代码,在 APPLE ][ 上编写完整的麦克风输入到扬声器程序。所以答案可能是:机器代码。

One of my classmates can write a complete mic-in to speaker program on an APPLE ][ by punching all the hex codes after a CALL -151. So the answer can probably be: machine code.

洛阳烟雨空心柳 2024-09-16 09:19:22

HTML是一种语言,而且是一种标记语言。我不知道浏览器如何真正解析它们,但我假设它们逐行解释它们,构建 DOM 和渲染元素等。

自然语言,例如英语,具有庞大且不断增加的语法,并且并不总是能够表达除非您使用精确的形式,否则请使用正式的符号(例如 BNF)。我认为。

所以我说你不能真正为英语和许多自然语言构建一个解释器,因为它总是在不断发展——甚至看看聊天语言和文本语言。

基于此,我认为并不是所有语言都可以有编译器。

HTML is a language, but a markup language. I don't know how browsers really parse them, but I assume they interpret them line by line, building up the DOM and rendering elements, etc.

Natural languages, such as English, have a large and ever increasing grammar and are not always expressed in a formal notation (such as BNF) unless you use an exact, precise form. I think.

So I say that you can't really build an interpreter for English, and many natural languages, based on the fact that it's always evolving - look at chatspeak and textspeak even.

I don't think all languages can have a compiler, based on this.

撩人痒 2024-09-16 09:19:22

编译器将整个源代码转换为其他代码,通常是机器代码或某种低级中间语言,如 java 字节码或 .net IL。解释器在执行程序时逐行转换源代码。除非你用汇编语言编写,否则你必须选择其中之一,甚至需要从汇编语言符号转换为二进制机器代码。

A compiler converts the entire of the source code to some other code, usually machine code or some kind low level intermediate language like java bytecode or .net IL. An interpretter converts the source code line by line as it executes the program. You have to do one or the other unless you write in assembly language, and even that needs turning from assembly language nmemonics into binary machine code.

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