使用解释器和编译器时执行的步骤

发布于 2024-09-26 19:34:37 字数 122 浏览 3 评论 0原文

解释型语言和编译型语言之间到底有什么区别。例如,我想打印从 1 到 100 的数字。在解释器和编译器的情况下,操作顺序是如何发生的。

另外,如果可能的话请根据Java语言和C语言提供我的步骤

Thx

What exactly the difference between interpreted and compiled language.For example I want print the numbers from 1 to 100 .How exactly the sequence of operations takes place in case of interpreter and compiler.

Further,If possible please provide me the steps in according to Java language and C language

Thx

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

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

发布评论

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

评论(2

傻比既视感 2024-10-03 19:34:37

编译语言是将源代码转换为机器代码的语言。也称为本机应用程序。

解释型语言是将源代码转换为某种中间代码的语言。在程序执行期间,解释器运行源代码。解释型语言往往(但并非总是如此)明显慢于编译型语言。然而,它们对于便携性很有用。

C 被编译,将源代码转换

for (int i=1;i<=100;i++) { printf("%d",i); }

为汇编代码,然后转换为机器代码。处理器获取每条机器指令并执行它。这非常快。

然而,Java 将源代码转换为中间字节代码。在运行时,它在“虚拟机”上运行,“虚拟机”可能比本机编译的应用程序慢。

A compiled language is a language which converts the source code to machine code. Also known as a native application.

An interpreted language is a language which converts the source code to some intermediate. During the execution of the program, an interpretor runs the source code. Interpreted languages tend to be, but not always are, significantly slower than compiled languages. They are useful, however, for portability.

C is compiled, turning the source code:

for (int i=1;i<=100;i++) { printf("%d",i); }

into assembly, then into machine code. The processor fetches each machine instruction and executes it. This is very fast.

Java, however, converts source code to an intermidiate byte code. At run-time, it is run on a "virtual-machine", which can be slower than a native compiled application.

风筝在阴天搁浅。 2024-10-03 19:34:37

这已经是 StackOverflow 上的常见问题解答 :-)

例如,请参阅以下答案:

实现编译器和解释器有什么区别?

解释器/编译器如何工作

This already kind of a FAQ on StackOverflow :-)

For example, see the following answers:

What is the difference between implementing a compiler and an interpreter?

How does an interpreter/compiler work

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