1.4. Intermediate language

How does Java achieve platform independence? Java source codes are compiled into byte codes (which are stored in .class files) by the Java compiler. Byte codes are portable because when they are executed, they are interpreted on-the-fly by the JVM for that specific platform. The JVM – for say the Macintosh operating system – understands both byte codes and how to translate them into native Macintosh machine codes that the Mac operating system understands. Similarly, the JVM for the Windows operating system knows how to translate byte codes into native machine codes for the Windows operating system.

The idea is suspiciously similar for .NET (see Figure 1.1). .NET source codes (whether written in J#, C# or any other .NET ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.