What is the difference between runtime and compilation time?

So what is a runtime? This is a virtual machine that runs semi-compiled code that cannot run on a specific processor. If so, what kind of virtual machine? Is it other software that also translates semi-compiled code into machine code? So, what if we are talking about one of those languages ​​that do not compile into intermediate code, but rather translate / compile directly into machine code. What is the lead time in this situation? Is it hardware (CPU and RAM)?

Also, what's the difference between compile time and runtime? Are the stages of the software life cycle. I mean, the program was originally a collection of text files, right? Thus, you compile or translate them into data form, which can then either be loaded into memory and executed by the processor, or if it is a “managed” language, then it will need additional compilation before it can work on hardware. What is a managed language?

Finally, is there such a thing as debug-time and what is it?

In my first year I study computer science, and it really bothers me how illogical they teach. “Information” is thrust into my throat, but whenever I try to understand everything, organizing everything related to a single system of clearly defined components and relationships, I get stuck.

Thanks in advance, Garrett

+8
c # compilation runtime compile-time
source share
3 answers

A type of code suitable for reasoning by people (let it be called "source code") must go through several stages of translation before it can be physically executed using basic equipment (such as a processor or graphics processor):

  • Source.
  • [optional] intermediate code (for example, .NET MSIL or Java bytecode).
  • Machine code corresponding to the target set architecture.
  • The microcode that actually flips the logic gate in silicon.

These translations can be performed at different stages of the life cycle program. For example, a particular language or programming tool can choose a translation from 1 to 2 when the developer “builds” the program and translates it from 2 to 3 when the user “launches” it (which is usually done using software called “virtual machine” 1 which must be pre-installed on the user computer) This scenario is typical of "managed" languages ​​such as C # and Java.

Or it can translate from 1 to 3 directly during assembly, as is usual for native languages ​​such as C and C ++.

Translation between 3 and 4 is almost always done using the main equipment. This is technically part of the "runtime", but is usually distracted and largely invisible to the developer.

The term "compilation time" usually refers to a translation from 1 to 2 (or 3 ). There are certain checks that can be performed during compilation before the program actually runs, for example, make sure that the types of arguments passed to the method correspond to the declared types of method parameters (provided that the language is "strongly typed"). The sooner a bug is caught, the easier it is to fix it, but it must be balanced with flexibility, so some scripting languages ​​do not have comprehensive compile-time checks.

The term "lead time" usually means a translation from 2 (or 3 ) up to 4 . Even at runtime, it can be broadcast directly from 1 , as is done using the so-called "interpreted languages".

There are certain problems that cannot be caught at compile time, and you will have to use appropriate debugging methods (such as debuggers, logging, profilers, etc.) to identify them at runtime. A typical example of a run-time error is an attempt to access a collection item that does not exist there, which can then appear as an exception at runtime and is the result of a too complicated script execution for the compiler to “predict” at compile time.

"Debug time" is just the runtime, while the debugger is connected to the running program (or you are tracking the debug log, etc.).


1 Do not confuse this with virtual machines that are designed to run native code, such as VMware or Oracle VirtualBox.

+10
source share

Compilation time and runtime usually refer to when checks occur or errors may occur. For example, in a statically typed language such as C #, static type checks are performed at compile time. This means that you cannot compile the application if, for example, you try to assign a string to an int variable. On the other hand, runtime refers to the time when the code actually executes. For example, exceptions are always thrown at runtime.

As for virtual machines and such; C # is a language that compiles into the Common Intermediate Language (CIL or IL). The result is code that is the same no matter which .NET language you use (C # and VB.NET produce IL). The .NET Framework then runs this language at runtime using just-in-time compilation . So, you can see the .NET Framework as a virtual machine that runs a special sublanguage against the target machine code.

As for debugging time, I don’t think there is such a thing, since you are still running the program when debugging. Therefore, if anything, the debug time will be the runtime with the debugger attached. But you would not use such a term.

+4
source share

Compilation time - the period when the compiler will try to compile some code. Example: "The compiler detected 3 type errors during compilation that prevented the compilation of the program."

Execution time - the period during which the program runs. Example: "We did not find the error before the execution time, because it was a logical error."

Runtime and virtual machines - two separate ideas - your first question does not make sense to me.

Virtual machines are really software products that translate the "object" code [Java, C #, etc.] into byte code that can be run on the machine. If a language uses a virtual machine, it also often uses Just In Time compilation, which means that compilation time and runtime mostly occur at the same time.

Conversely, compiled languages ​​such as C, C ++ are usually compiled into bytecode before being executed on the machine, so the compilation time and the runtime are completely separate.

Typically, “managed” languages ​​have garbage collection (you do not directly manipulate memory using allocations and de-allocations [Java and C # are both examples]) and run on some type of virtual machine.

+2
source share

All Articles