.NET Platform vs Sun Java VMAdd Comment
<span class="wboxheado">Introduction</span><br> Many people are asking the question is C# better or Java? How is C# different from Java? You say C# is more powerful, how is it so ?<br> Actually the concept of the .NET Platform is so much different from the previous languages used that the older arguments are no longer valid! The argument of C# vs Java has no base since eventually C# code gets compiled to IL code (Intermediate Language or MSIL) which then runs on the .NET Platform. Infact all languages on the .NET produce the same IL code. It does not matter if you use VB.NET, C#, Managed C++, COBOL.NET, Perl.NET or any other language on the .NET they <b> ALL PRODUCE THE SAME IL CODE</b>. So now on the .NET all languages have the same efficiency and power. Its just the developers choice to choose the language whose syntax he is most comfortable with. <br> So if you wanted to argue C# vs Java then you should also be debating VB.NET vs Java, Managed C++ vs Java; the only difference between the three debates will be just about syntax changes. But I consider that the preference of one syntax over another is every developers personal preference and has no use discussing. Its like debating on why you like apples while I like oranges! <p><span class="wboxheado">.NET Platform vs Sun Java VM</span><br> The main debate should be between the .NET Platform and the Sun Java VM (virtual machine). All languages on the .NET gain their powers from the .NET Platform.<br> If you stay in touch with the news then you would know that it was Microsoft who had made the <b> fastest</b> Java VM. They could achieve it by tweaking the VM to give a better performance over Intel platforms. Although due to the legal problems this project along with the VJ++ project has been discontinued. Just to tell you how serious Microsoft is about the .NET Platform, they have spent 4 billion dollars and more in the research and development of .NET and have pledged to devote 80% of their R&D in the year 2001-02 on the .NET Platform. We have already see how Microsoft has ambitiously taken over the market in the past when Windows gained popularity over Macintosh (which people still think is a superior OS). Also the Netscape and IE war was won by Microsoft despite Microsoft's late entry into the browser market.<br> When such a ambitious company is spending so much resources it sure has to have a strong strategy and product! Some points of distinction are explained below.</p> <p dir="ltr"><span class="wboxhead">1) Platform Independence</span><br> I have taken this point first because this is the most ravaged point I have seen crusaders of Sun Java shouting about. I would like to highlight some facts here. Even though Microsoft has not made any open announcements nor are they publicizing Platform Independence, but the fact is .NET Platform Independent. Microsoft is not making any announcements because they don't want to jump around before they have a solid product in their hand. But Microsoft has already announced that they are going to release .NET Platform for Linux! And Microsoft's commitment can also be seen in their acquiring a significant stake in Corel Linux. Slowly there will be a .NET Platform for every OS.<br> (Update 10/May/2002: MONO Project <a class="wbox" target="_blank" href="http://www.go-mono.com">www.go-mono.com</a> is already developing the CLR and C# compiler for Linux. Microsoft has released ROTOR the shared source containing the .NET Platform which works on Free BSD.)<br> One more added advantage of .NET Platform is Language Independence. Since all the code on the .NET ultimately gets converted to IL, you can use components written in one language in another language without writing any extra code!<br> Also people who have tried to migrate big Java projects from one operating system to another, will realize that its simply does not work!! There is some amount of re-coding required to port the application from one platform to another. <br> A example of this is that the Framework classes (System Namespaces) that come with the .NET SDK have been written in C#, but you can use these classes from any language like VB.NET, Managed C++ without ever writing any extra code!<br> </p> <p><span class="wboxhead">2) Performance and Speed</span><br> As I mention before that it was Microsoft that had developed the fastest Java VM which reports say is 5x faster than the Sun VM. They have learned a lot from their previous ventures. The Sun Java VM does not perform any CPU specific optimizations. Although I have heard about the new HotSpot VM from Sun, but its just a code caching mechanism. Microsoft on the other hand is perusing much ahead in the CPU specific optimizations. Be sure these optimizations are made to the JITer and has not effect on the code you compile and this does not make your code Platform Dependent. What these optimizations do? Say Microsoft finds that a particular instruction performed on a Intel P-III gives a higher performance and the same instruction should be performed in a different way on a AMD Durathon, it tweaks the JIT'er for the specific CPU so that it optimizes the performance of your applications according to your CPU. Such optimizations helps you to utilize the true power of the CPU. <br> If you go the Java way, a Java program would more or less perform the same on a Intel 1hz or a AMD 1hz without taking into consideration the special features of the CPU. The .NET Platform will provide different JIT'ers for the Intel as well as AMD CPU's so that it can utilize all the special instruction sets which the 2 CPU's have allowing you to realize the value of the money you have invested in buying a specific processor. <br> Since .NET is in its Beta version there have not been any specific performance charts, but be assured the .NET will out perform its counterpart in its future releases.<br> (Update 10/May/2002 : See <a class="wbox" target="_blank" href="http://www.gotdotnet.com/petshop"> www.gotdotnet.com/petshop</a> for performance benchmarks.) </p> <p><span class="wboxhead">3) Open competition for language and tool developers.</span><br> The .NET platform is sort of a open platform, any vendor can create a compiler for it! All languages can be ported to .NET, may be some day someone might even write a Java compiler for the .NET. As of the Java scene, you have to rely on the arrogance of Sun to provide you with compilers. This limits the chance of open competition between third-party developers. <br> Just like on the native platform, we have compilers for C/ C++ from many vendors like Microsoft, Borland etc. The choice of choosing the compiler rests in the hands of the developer. The .NET Platform too invites vendors to develop their own compilers. I just can't resist mentioning that C# and the CLI (Common Language Interface) has been submitted to the <b> ECMA</b> committee and even you can write a C# compiler!<br> Since third party vendors can create compilers, it goes without saying that they are also free to develop third-party tools, so now the developer will get a better choice of tools to suit his needs.</p> <p><span class="wboxhead">4) Other points</span><br> .NET's features like versioning, type-safety and enhanced security also are worth mentioning. You can run 2 versions of the same component at the same time, this is called Side-by-Side execution. Example: You can run ver1 of your Calculator component together with ver2 of it. The application that you wrote with the ver1 does not break-up even when you upgrade your components to ver2. <br> I could go on but I think I have made enough valid points.</p> <p><span class="wboxheado">Conclusion</span><br> I my view .NET has beaten Sun's Java VM hands down, as I have illustrated. I have heard about Sun's new <b> ONE Platform</b>, but haven't gone through it nor will I go through it, since after my encounter with the power of .NET. I don't think I will be trying anything new for at least sometime now! <br> I hope this will put a end to all the differences your minds about the .NET platform. <p><b>Disclaimer</b> <br> All the views stated in this article are my personal views own and could be misleading or incorrect. <br> Java is the registered trademark of Sun Microsystems, Inc.