运行时和编译时的区别是什么?
当前回答
这里有一个非常简单的答案:
Runtime and compile time are programming terms that refer to different stages of software program development. In order to create a program, a developer first writes source code, which defines how the program will function. Small programs may only contain a few hundred lines of source code, while large programs may contain hundreds of thousands of lines of source code. The source code must be compiled into machine code in order to become and executable program. This compilation process is referred to as compile time.(think of a compiler as a translator)
用户可以打开并运行编译后的程序。当应用程序正在运行时,它被称为运行时。
术语“运行时”和“编译时”经常被程序员用来指代不同类型的错误。编译时错误是一种问题,例如语法错误或缺少文件引用,从而阻止程序成功编译。编译器产生编译时错误,并通常指出源代码的哪一行导致了问题。
如果一个程序的源代码已经被编译成一个可执行程序,那么它在程序运行时可能仍然有错误。例子包括不能工作的特性、意外的程序行为或程序崩溃。这些类型的问题被称为运行时错误,因为它们发生在运行时。
参考
其他回答
编制时间:
在编译时执行的操作在最终程序运行时几乎不会产生任何开销,但在构建程序时可能会产生很大开销。
运行时:
或多或少完全相反。构建时成本小,运行程序时成本大。
从另一边;如果在编译时执行了某些操作,那么它只在您的机器上运行;如果在运行时执行了某些操作,那么它将在用户的机器上运行。
相关性
An example of where this is important would be a unit carrying type. A compile time version (like Boost.Units or my version in D) ends up being just as fast as solving the problem with native floating point code while a run-time version ends up having to pack around information about the units that a value are in and perform checks in them along side every operation. On the other hand, the compile time versions requiter that the units of the values be known at compile time and can't deal with the case where they come from run-time input.
编制时间: 将源代码转换为机器码以使其成为可执行文件所花费的时间称为编译时间。
运行时间: 当应用程序正在运行时,它被称为运行时。
编译时错误是那些语法错误,缺少文件引用错误。 运行时错误发生在源代码被编译成可执行程序之后,并且程序正在运行时。例如程序崩溃、意外的程序行为或功能不工作。
嗯,好吧,运行时是用来描述程序运行时发生的事情。
编译时间用来描述在构建程序(通常由编译器)时发生的事情。
这里有一个非常简单的答案:
Runtime and compile time are programming terms that refer to different stages of software program development. In order to create a program, a developer first writes source code, which defines how the program will function. Small programs may only contain a few hundred lines of source code, while large programs may contain hundreds of thousands of lines of source code. The source code must be compiled into machine code in order to become and executable program. This compilation process is referred to as compile time.(think of a compiler as a translator)
用户可以打开并运行编译后的程序。当应用程序正在运行时,它被称为运行时。
术语“运行时”和“编译时”经常被程序员用来指代不同类型的错误。编译时错误是一种问题,例如语法错误或缺少文件引用,从而阻止程序成功编译。编译器产生编译时错误,并通常指出源代码的哪一行导致了问题。
如果一个程序的源代码已经被编译成一个可执行程序,那么它在程序运行时可能仍然有错误。例子包括不能工作的特性、意外的程序行为或程序崩溃。这些类型的问题被称为运行时错误,因为它们发生在运行时。
参考
对于S.O.来说,这不是一个好问题(这不是一个特定的编程问题),但总的来说,这不是一个坏问题。
如果您认为这是微不足道的:那么读时与编译时的区别是什么呢?什么时候这是一个有用的区别?编译器在运行时可用的语言呢?Guy Steele(不是笨蛋,他)在CLTL2中写了7页关于EVAL-WHEN的内容,CL程序员可以使用它来控制这一点。两句话只能勉强给出一个定义,而定义本身还远远不够解释。
In general, it's a tough problem that language designers have seemed to try to avoid. They often just say "here's a compiler, it does compile-time things; everything after that is run-time, have fun". C is designed to be simple to implement, not the most flexible environment for computation. When you don't have the compiler available at runtime, or the ability to easily control when an expression is evaluated, you tend to end up with hacks in the language to fake common uses of macros, or users come up with Design Patterns to simulate having more powerful constructs. A simple-to-implement language can definitely be a worthwhile goal, but that doesn't mean it's the end-all-be-all of programming language design. (I don't use EVAL-WHEN much, but I can't imagine life without it.)
关于编译时和运行时的问题空间是巨大的,而且在很大程度上仍未被探索。这并不是说S.O.是进行讨论的正确场所,但我鼓励人们进一步探索这一领域,特别是那些对它应该是什么没有先入为主概念的人。这个问题既不简单也不愚蠢,我们至少可以给检察官指出正确的方向。
不幸的是,我不知道任何好的参考资料。CLTL2稍微讲了一下,但对于学习它并不是很好。