Architectural view of comparing frameworks Internals of Java and .NET. In this article i would compare code loading process in java and .Net. I would also highlight few of the differences.
Code Loading in Java
The Java platform is based on a virtual machine that abstracts the underlying operating system and makes it possible to safely run programs across heterogeneous computing platforms. The Java virtual machine interprets portable byte code delivered in the form of class files. Class files are dynamically loaded into the virtual machine following an explicit search order. The actual run-time mechanism used to load classes in the virtual machine is an instance of the ClassLoader class, which is a special class used by the Java platform to load other classes. All class loaders have a parent class loader, except for the bootstrap class loader. By default, child class loaders delegate class load requests to their parent class loader and only if the parent does not find the class will the child search for the class itself. When a Java application is started, the application's main class is loaded with a default application class loader instance, which ultimately delegates to the boot class loader. It is possible for applications to provide custom subclasses of ClassLoader to perform specialized searches for classes, such as searching remote repositories. It is through class loaders and class loader customization that Java popularized or, at the very least, brought dynamic code loading to the masses.
Code Loading in .NET
Microsoft's .NET platform is similar to the Java platform in many respects, but some significant differences do exist. First, the .NET virtual machine was designed to supports multiple programming languages (e.g., C#, J#, VB.NET, and Visual C++ .NET), whereas the Java virtual machine was only designed to support Java, although other languages for it do exist (e.g., SmalltalkJVM, Groovy, Jython, JRuby, and Nice). In .NET, all languages run on the Common Language Runtime (CLR). The CLR uses a portable language format, called the Microsoft Intermediate Language (MSIL), which is analogous to Java's byte code. High-level languages are compiled into MSIL, which is then compiled into the native code of the underlying computing platform at load time, similar to how Just-In-Time (JIT) compiling works in Java. Unlike anything in Java, the CLR is able to retain assemblies in a Global Assembly Cache (GAC) for later reuse and version management. The official .NET platform is from Microsoft. Microsoft also provides a “shared source” implementation, called Rotor.
In .NET, applications and their components are packaged into assemblies. An assembly is .NET's unit of reuse, versioning, security, and deployment. An assembly is one or more files representing types and resources and is described by a manifest. An assembly manifest is represented in XML and contains information such as version number, natural language, and content hashes. Hashes come into play when calculating an assembly's signature using public key cryptography, which is also referred to as the strong name of the assembly and it is used for identification and security purposes. Assemblies can be dynamically loaded,
but, unlike Java class packages contained in JAR files, it is not possible to load individual types or classes
from an assembly.
Code Loading in Java
The Java platform is based on a virtual machine that abstracts the underlying operating system and makes it possible to safely run programs across heterogeneous computing platforms. The Java virtual machine interprets portable byte code delivered in the form of class files. Class files are dynamically loaded into the virtual machine following an explicit search order. The actual run-time mechanism used to load classes in the virtual machine is an instance of the ClassLoader class, which is a special class used by the Java platform to load other classes. All class loaders have a parent class loader, except for the bootstrap class loader. By default, child class loaders delegate class load requests to their parent class loader and only if the parent does not find the class will the child search for the class itself. When a Java application is started, the application's main class is loaded with a default application class loader instance, which ultimately delegates to the boot class loader. It is possible for applications to provide custom subclasses of ClassLoader to perform specialized searches for classes, such as searching remote repositories. It is through class loaders and class loader customization that Java popularized or, at the very least, brought dynamic code loading to the masses.
Code Loading in .NET
Microsoft's .NET platform is similar to the Java platform in many respects, but some significant differences do exist. First, the .NET virtual machine was designed to supports multiple programming languages (e.g., C#, J#, VB.NET, and Visual C++ .NET), whereas the Java virtual machine was only designed to support Java, although other languages for it do exist (e.g., SmalltalkJVM, Groovy, Jython, JRuby, and Nice). In .NET, all languages run on the Common Language Runtime (CLR). The CLR uses a portable language format, called the Microsoft Intermediate Language (MSIL), which is analogous to Java's byte code. High-level languages are compiled into MSIL, which is then compiled into the native code of the underlying computing platform at load time, similar to how Just-In-Time (JIT) compiling works in Java. Unlike anything in Java, the CLR is able to retain assemblies in a Global Assembly Cache (GAC) for later reuse and version management. The official .NET platform is from Microsoft. Microsoft also provides a “shared source” implementation, called Rotor.
In .NET, applications and their components are packaged into assemblies. An assembly is .NET's unit of reuse, versioning, security, and deployment. An assembly is one or more files representing types and resources and is described by a manifest. An assembly manifest is represented in XML and contains information such as version number, natural language, and content hashes. Hashes come into play when calculating an assembly's signature using public key cryptography, which is also referred to as the strong name of the assembly and it is used for identification and security purposes. Assemblies can be dynamically loaded,
but, unlike Java class packages contained in JAR files, it is not possible to load individual types or classes
from an assembly.
- In Java, the unit of code loading is a class; in .NET, the assembly is the unit of code loading, which may contain many types.
- In Java, the compiler does not record explicit dependencies among classes, which can be arbitrarily resolved at run time; in .NET, assembly dependencies are explicitly recorded at compile time, making them difficult to resolve differently at run time
- In Java, the class search order is nearly completely customizable via class loaders; in .NET, class/assembly searched order controlled by more sophisticated policies that complicate implementing custom search orders.
- In Java, the deployment unit does not form part of the class name; in .NET, the assembly name forms part of the contained type names, ultimately reducing provider substitutability.
Comments