liveBook · Manning

Compiler

As explained in .NET in Action, Second Edition

A compiler is a program that translates source code in a programming language into another executable or intermediate representation.

A compiler translates source code from one programming language into another executable or intermediate representation. In .NET, C#, F#, and Visual Basic compilers translate high-level code into Common Intermediate Language (CIL), which the CoreCLR runtime executes. section 1.1 section 1.5.2

The .NET compilation path separates language translation from processor-specific execution:

  • Language compilers produce CIL and package it in a Dynamic Link Library (DLL). section 1.5.1
  • CIL avoids assumptions about processor architecture, operating system, registers, instruction sets, and cache sizes. section 1.5.1 section 1.5.2
  • The CoreCLR JIT compiler converts only code about to be used into machine code at runtime, limiting unnecessary startup work. section 1.5.2
  • An ahead-of-time (AOT) compiler can perform initial processor-specific compilation, trim unused code, and avoid waiting for JIT compilation. section 1.5.2

A portable .NET assembly

A C# compiler produces a CIL DLL rather than a separate binary for every operating system and processor. The DLL can run on machines with a compatible .NET runtime, where CoreCLR converts its CIL into machine code. section 1.5.1

Figure 1.4 .NET languages compile to CIL in a DLL file that can be run on any machine with a .NET runtime.

Use the compilation diagram to trace .NET languages through CIL in a DLL and into execution on a machine with a .NET runtime. section 1.5.1

How .NET in Action, Second Edition covers it

How deep it goes
Explains translation, CIL portability, DLL output, JIT behavior, and AOT trade-offs without detailing compiler implementation internals.
Examples
Uses C#, F#, Visual Basic, CIL DLLs, processor architectures, JIT compilation, and AOT compilation as concrete examples.
What it assumes
Assumes basic programming familiarity while defining machine-readable code, intermediate language, runtime, JIT, and AOT from fundamentals.
What you can do after
Evaluate how .NET code moves from source language through CIL and runtime compilation to processor-specific machine code.
How it connects
Connects compilers with CIL, .NET runtime, CoreCLR, JIT compilation, AOT compilation, DLLs, transpilers, and decompilers.

Also explained in

Compare how 9 books explain compiler →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.