Suppose I have an application written in native C++ (over 500k lines of code) and I want to port it to .NET (C#). One thing I’m worried about is the JIT compiler. It takes my native code compiler over 30 seconds to compile. Does that mean that each time the user starts my C# app, it’s going to take that long just to load it (since the JIT compiler has to compile it every time)?
Share
The JIT compiler isn’t quite “compiling” in the sense you’re thinking. It’s converting one instruction set (IL bytecode) to another (x86 or x64 machine code) on demand. The conversion’s pretty straightforward, by design, and doesn’t take anywhere near as long as C++ takes to compile an app. It doesn’t even normally happen all at once (“Just in time” means the instructions are translated at about the time they’re “executed”), so the app will start pretty quickly.
The hard and time-consuming part of compilation is the conversion from human-readable instructions (source code) to machine-readable ones (bytecode or native code, depending on your language/platform). That part is already done when the EXE is created, and doesn’t need to be redone unless the source code (or its meaning) changes.