Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run time VS Compile time (.NET)

Tags:

.net

.NET compilation has two phases

  • 1 . Compilation to IL code.

  • 2 . JIT compilation to native code.

Can both these stages can be categorized as compile time? Or does the JIT compilation to native code comes under runtime ?

In terms of error, if an error occurs at the phase two, is it a run time error? (Any error that occurs after the phase 2 ie, when the native code is actually executed should be a run time error )

like image 993
rjv Avatar asked Feb 10 '11 06:02

rjv


People also ask

Which is faster runtime or compile time?

Basically if your compiler can work out what you mean or what a value is "at compile time" it can hardcode this into the runtime code. Obviously if your runtime code has to do a calculation every time it will run slower, so if you can determine something at compile time it is much better.

What is a runtime C#?

As part of the Microsoft . NET Framework, the Common Language Runtime (CLR) is the programming (Virtual Machine component) that manages the execution of programs written in any language that uses the . NET Framework, for example C#, VB.Net, F# and so on.


1 Answers

As per my understanding -

Compiling C# to MSIL and compiling MSIL to native code are two stages of the compilation process. Errors occurring in both stages are compile time errors.

However, it is unlikely that there will be any compilation errors in second stage (JIT). If your C# code compiles correctly to MSIL then it will certainly be JITed to the native code without any problems.

IMO the most important thing that happens during JITing is optimizations for the native platform.

Run-time errors are those which happen during executing your JITed native code.

like image 91
Unmesh Kondolikar Avatar answered Sep 21 '22 13:09

Unmesh Kondolikar