“所有程序都被解释".如何? [英] "All programs are interpreted". How?

查看:49
本文介绍了“所有程序都被解释".如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

计算机科学家会正确地解释所有程序都是解释,唯一的问题是在什么级别.--perlfaq

A computer scientist will correctly explain that all programs are interpreted and that the only question is at what level. --perlfaq

如何解释所有程序?

推荐答案

Perl 程序是由 perl 程序读取的文本文件,它导致 perl 程序遵循一系列动作.

A Perl program is a text file read by the perl program which causes the perl program to follow a sequence of actions.

Java 程序是一个文本文件,它已被转换为一系列字节码,然后由 java 程序解释以遵循一系列操作.

A Java program is a text file which has been converted into a series of byte codes which are then interpreted by the java program to follow a sequence of actions.

C 程序是一个文本文件,它通过C 编译器转换为汇编程序,然后由汇编程序转换为机器代码.机器码被加载到内存中,导致 CPU 遵循一系列动作.

A C program is a text file which is converted via the C compiler into an assembly program which is converted into machine code by the assembler. The machine code is loaded into memory which causes the CPU to follow a sequence of actions.

CPU 是由硬件工程师布置的晶体管、电阻器和其他电气位的混合体,因此当施加电脉冲时,它会遵循物理定律所规定的一系列动作.

The CPU is a jumble of transistors, resistors, and other electrical bits which is laid out by hardware engineers so that when electrical impulses are applied, it will follow a sequence of actions as governed by the laws of physics.

物理学家目前正在研究是什么制定了这些规则以及如何解释它们.

Physicists are currently working out what makes those rules and how they are interpreted.

从本质上讲,每个计算机程序都由其他东西解释,然后将其转换为其他东西,最终转化为您当地社区的电子如何飞行.

Essentially, every computer program is interpreted by something else which converts it into something else which eventually gets translated into how the electrons in your local neighborhood fly around.

编辑/添加:我知道上面的内容有点诙谐,所以让我添加一个稍微不那么愚蠢的添加:

EDIT/ADDED: I know the above is a bit tongue-in-cheek, so let me add a slightly less goofy addition:

解释型语言让您只需一个简单的步骤即可将文本文件转换为计算机上运行的内容.

Interpreted languages are where you can go from a text file to something running on your computer in one simple step.

编译语言是您必须在中间采取额外步骤才能将语言文本转换为机器码或字节码的地方.

Compiled languages are where you have to take an extra step in the middle to convert the language text into machine- or byte-code.

后者可以通过简单的转换很容易地转换为前者:

The latter can easily be easily be converted into the former by a simple transformation:

制作一个名为 interpreted-c 的程序,它可以接受一个或多个 C 文件,并且可以运行一个不接受任何参数的程序:

Make a program called interpreted-c, which can take one or more C files and can run a program which doesn't take any arguments:

#!/bin/sh
MYEXEC=/tmp/myexec.$$
gcc -o $MYEXEC ${1+"$@"} && $MYEXEC
rm -f $MYEXEC

现在你的 C 程序属于哪个定义?比较&对比:

Now which definition does your C program fall into? Compare & contrast:

$ perl foo.pl
$ interpreted-c foo.c

这篇关于“所有程序都被解释".如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆