- Microsoft Dumps Java for their new language: C Sharp
- Enter C Sharp (C#)
Enter C Sharp (C#)
If Microsoft could not give their power hungry developers Java in the form of Visual J++, why not create a whole new language? That is what Sun did. Sun Microsystems took C++, Smalltalk, and Objective-C, and decided to make an object oriented language that is robust, easy, powerful, and modern. Java was born directly from those other languages. Much of the Java syntax is straight C++. Microsoft took the same idea and built C# (pronounced C sharp). C# has heavy influences of Java (very, very heavy), Visual C++, and Visual Basic. C# fills the gap that the abandoned J++ leaves behind. Not only does it fill the gap, but it gives Visual Studio (VS) developers a language that has the simplicity of Java, without the brain-deadness of VB nor the often overwhelming complexity of VC++, but still gives the VS developers speed and Win32 hooks, which are missing in the "pure" Java environments for Windows.
Why is this good news for Sun and Java developers? Well, if Microsoft continued distorting the Java language, a splintering could have formed which would have severely crippled Java forever. Java has now been left in the dust by Microsoft, which allows the Java community to continue making their great language even better, more stable, more robust, and more system independent. Meanwhile, Microsoft has a new toy (yes it looks a lot like Java, but it also looks similar to VB and C++ in many ways). This allows two, possibly competing languages to evolve separately. Some might be angry that Microsoft copied Java, but didn't Sun copy C++ to make Java, and didn't C++ copy OOP concepts from Smalltalk, and Smalltalk copied ADA, etc, etc...
The interesting thing is that Microsoft knows that the whole philosophy behind the Java technology is hot. That is why their inside developers were so quick to take advantage of Java, and now they have completely rebuilt their entire Visual Studio development suite around C#. Instead of Java and WFC, though, Visual Studio is being built around the .NET Framework, which is very similar to the Java 2 core class package library API.
Here is a chart of similarities:
Sun Java API |
Microsoft .NET Framework |
java.lang. |
System. |
java.io. |
System.IO. |
java.net. |
System.Net.Sockets. |
java.lang.reflect. |
System.Reflection. |
As you can see, the library names, class names, and even method names are very similar. The C# dot structure is easy to navigate and will be familiar to those who already know Java. Compared to Java, C# is a bit more complex and cluttered. Java has under 50 keywords, where C# has 76. Java has 8 primitive data types, C# has 13 simple data types. Most of the Java keywords are either the same in C# or renamed slightly. For example a final class in Java is a sealed class in C#.
Java |
C# |
size bits |
byte |
sbyte |
8 |
|
byte |
8 |
short |
short |
16 |
|
ushort |
16 |
int |
int |
32 |
|
uint |
32 |
long |
long |
64 |
|
ulong |
64 |
char |
char |
16 |
float |
float |
32 |
double |
double |
64 |
boolean |
bool |
1 |
|
decimal |
128 |
C Sharp's "simple" data types are identical to Java's primitive data types, with additional unsigned versions of byte, short, int, and long. The one significant addition to the primitive data types is the decimal type. This comes directly from Visual Basic and is a 128 bit number that holds its precision better then a float or double due to the problematic floating point arithmetic errors. The Microsoft C# documentation states that the decimal type is best suited for financial calculations.
But C# has made things much more simple that in Java can be a bit awkward. One complaint Java gets often is the mix of a pure object oriented system with non-object oriented primitive data types. For example converting an int to a string in Java can be a bit convoluted. In Java you might do something like this:
int i = 5; String s = Integer.valueOf(i).toString();
or the hackier:
String s = i + "";
Where in C# it is a bit more straight forward and object oriented:
int i = 5; string s = i.ToString()
Will Java programmers abandon BEA, IBM, Oracle, and Sun and flock to Microsoft? Probably not. Will existing Visual Basic and Visual C++ programmers take interest in C#, I think so. C# will be even more attractive to VB and VC++ programmers when they see how central C#'s roll in the new Visual Studio.NET and ASP.NET environment that Microsoft is banking on. Plus, now Microsoft has a "cool" language of their own that is simple, powerful, object oriented, but also one they can truly call their own. C# serves as a great compliment to VB and VC++, making Visual Studio 7 very popular for existing Visual Studio programmers.