MICROSOFT .NET, JAVA AND YOU
As if the waters surrounding Microsoft's upcoming .NET platform weren't muddy enough, Microsoft's launch of Visual J# .NET (also known under the unofficial codename Java.NET) Beta 1 is set to add to the confusion. When you look beyond the marketing hype, however, the motivation behind this new Java syntax support is just as confusing.
First of all, if you're anything less than an ardent supporter of Microsoft development tools, you could be forgiven for asking a common question: 'What is .NET?' In short, .NET is Microsoft's new platform for Windows and Web application development. .NET is a big collection of Microsoft server software and development tools that have all been designed to work together. The idea is to make things easier for today's developers who face increasing demands to produce products that go beyond the bounds of traditional software development.
At the heart of .NET is the Common Language Runtime (CLR). All .NET programs (be they Windows applications or Web pages written in ASP.NET) are compiled ahead of time into Microsoft Intermediate Language (MSIL) files. From the point of view of a Windows user, these files look and behave just like Windows .EXE and .DLL files; however, instead of being written in machine code suitable for native execution in Windows, .NET programs use a set of instructions that are understood by the .NET CLR. The CLR sits on top of whatever operating system the user happens to use and translates MSIL into native instructions that are understood by the operating system.
Anyone who has done any Java development before will find that this all sounds eerily familiar. Java programs are compiled into Java bytecode, and are then run on a Java Virtual Machine (JVM) that converts the bytecode into native operating system instructions. This design choice was made to allow Java to be a platform-independant language. In fact, any operating system for which there exists a JVM can run Java programs with no need for recompilation or porting of any kind! So naturally the first question that springs to mind about .NET, which uses the very same design pattern, is this: will .NET be a way to write Windows applications that run on multiple platforms, maybe even on Linux and MacOS X? Microsoft themselves are developing a CLR for the FreeBSD operating system, while Open Source initiatives are already underway to develop a version of the .NET platform for Linux.
Not so fast: .NET is more than just the CLR. .NET also includes the ".NET Framework", a vast collection of class libraries that include the software components neccessary for writing graphical Windows applications, for creating dynamic Web sites with ASP.NET, and for accessing relational databases with ADO.NET, among other things. None of these class libraries will be officially available on any platform except Windows, and with non-Windows incarnations of previous Microsoft-only APIs (such as ASP 3.0 and ADO 2.5) having only just recently become practical, we can expect it will be quite some time before we see any truly useful, platform-independant applications of .NET.
So if Microsoft didn't create the CLR to make .NET multiplatform, what's the point? One of the main features of .NET is the fact that developers have a range of programming languages to choose from. Web developers coming from ASP are likely to be most comfortable with VBScript, and .NET lets them write programs in VB.NET, a very similar (yet much more robust) language. Developers coming from more traditional software development backgrounds, who are likely to have experience with C++ and Java are offered C#. Pronounced 'C Sharp', this brand new language looks a lot like Java, but with a sprinkling of altered keywords and new syntax to help make C++ developers feel more at home.
So what does the newly-announced J# Beta have to do with all this? Well as a seasoned Java developer exploring C# for the first time, I found the differences between the two languages to be more annoying than anything else. Everything that C# can do as a pure language Java can do just as well, often with less typing. We programmers are usually quite set in our ways; Microsoft seems to have recognized that, and created J#.
J# ('J Sharp') takes all of the pure language syntax of Java (classes, interfaces, methods, if statements, for loops, try-catch blocks), and applies them to the .NET platform. Instead of using the javax.swing.JFrame class to create a Window, you use the .NET equivalent. Basically, J# is Java with all of the classes stripped out and replaced with the .NET Framework, including ASP.NET, ADO.NET, and the rest.
-> Microsoft Visual J# .NET Beta 1
Readers with sharp memories (no pun intended) will recall that this is not the first attempt Microsoft has made at commandeering the syntax of the Java language and applying it to its own proprietary API. Microsoft Visual J++, which was confused by many early adopters of Java as just another Java development environment, contained a mix of traditional Java APIs and Microsoft Windows-specific APIs. The courts ended up barring Microsoft from pursuing the development of J++ because it infringed on Sun's right to safeguard the purity of the core Java class libraries.
J++ was a big flop in its time, but it seems that with .NET Microsoft think the timing is right to try again. This time, however, the stakes are higher. Java is no longer an over-hyped language for writing Web applets. Today, Java is the leading platform for enterprise Web applications. If Microsoft can successfully lure developers away from the Java platform by disguising .NET with the trappings of the Java language, they'll have succeeded in doing an end run around Sun's lawyers, who may not be able to protect 'Java the language' with the same success as they were able to protect 'Java the platform'.
Until next issue!
- Kevin Yank
Editor, The SitePoint Tech Times