运行时和编译时的区别是什么?


当前回答

运行时和编译时的主要区别是:

如果代码中存在语法错误和类型检查,则抛出编译时错误,而-as运行时:它在执行代码后进行检查。 例如:

Int a = 1 Int b = a/0;

这里的第一行末尾没有分号——在执行操作b时执行程序后,>编译时错误,结果是无限的——>运行时错误。

编译时不会查找代码提供的功能的输出,而运行时则会。

其他回答

编制时间:

在编译时执行的操作在最终程序运行时几乎不会产生任何开销,但在构建程序时可能会产生很大开销。 运行时:

或多或少完全相反。构建时成本小,运行程序时成本大。

从另一边;如果在编译时执行了某些操作,那么它只在您的机器上运行;如果在运行时执行了某些操作,那么它将在用户的机器上运行。

以下是前面类似的问题的答案,运行时错误和编译器错误的区别是什么?

编译/编译时/语法/语义错误:编译或编译时错误是由于键入错误而发生的错误,如果我们没有遵循任何编程语言的正确语法和语义,那么编译器就会抛出编译时错误。除非您删除所有语法错误或调试编译时错误,否则它们不会让您的程序执行一行。 例如:在C语言中缺少分号或将int错误地输入为int。

运行时错误:运行时错误是指程序处于运行状态时产生的错误。这些类型的错误将导致您的程序出乎意料地运行,甚至可能杀死您的程序。它们通常被称为例外。 示例:假设您正在读取一个不存在的文件,将导致运行时错误。

阅读更多关于所有编程错误

Imagine that you are a boss and you have an assistant and a maid, and you give them a list of tasks to do, the assistant (compile time) will grab this list and make a checkup to see if the tasks are understandable and that you didn't write in any awkward language or syntax, so he understands that you want to assign someone for a Job so he assign him for you and he understand that you want some coffee, so his role is over and the maid (run time)starts to run those tasks so she goes to make you some coffee but in sudden she doesn’t find any coffee to make so she stops making it or she acts differently and make you some tea (when the program acts differently because he found an error).

编译时间:您作为开发人员编译代码的时间段。

运行时间:用户运行你的软件的时间段。

你需要更明确的定义吗?

编制时间: 将源代码转换为机器码以使其成为可执行文件所花费的时间称为编译时间。

运行时间: 当应用程序正在运行时,它被称为运行时。

编译时错误是那些语法错误,缺少文件引用错误。 运行时错误发生在源代码被编译成可执行程序之后,并且程序正在运行时。例如程序崩溃、意外的程序行为或功能不工作。