I wasn't around when all this was happening. But when I look at it now, I see Java appeared in 1995 whereas C# appeared in 2001. And the history section for C# on Wikipedia says only the following.
James Gosling, who created the Java programming language in 1994, and Bill Joy, a co-founder of Sun Microsystems, the originator of Java, called C# an "imitation" of Java; Gosling further claimed that "[C# is] sort of Java with reliability, productivity and security deleted." Klaus Kreft and Angelika Langer (authors of a C++ streams book) stated in a blog post that "Java and C# are almost identical programming languages. Boring repetition that lacks innovation."
I was left thinking as to how did these to programming languages, almost "imitations" (then) came to be. Why do you think C# came to be when the world already had Java back then?
For those of you who see subjectivity, consider the question as
What technological factors and necessities led to the development of C#? Were some of the key points not already covered by Java?
PS: I'm aware they both differ now at certain key points, as Jon Skeet points out [1]. But they didn't seem to back when C# came out.
Microsoft originally was on the Java bandwagon with their own implementation/JVM. However they fell out with Sun over licensing and I think Microsoft were trying to put extensions into the Java API which was a big no no for Sun who wanted a common standard (and you have to applaud Sun for this at least, having a 100% common API was a big part of Java's cross-platform credentials).
So Microsoft decided to write their own C-based language with a API/VM for it (C# and .NET/CLR). .NET was wider than just C# as it also supports VB and C++ (plus a few others I'd guess).
Initially C# was a poor cousin of Java, the collection library was (and to some degree still is) pretty poor. However with the advent of features such as first-class functions, lambdas/closures and LINQ, C# is moving ahead of Java and personally C# now shades Java in productivity for a lot of simple stuff using Linq.
Java is trying to catch up now with 7/8 supporting closures but I have my doubts whether they will come up with something as good/simple as C#s syntax. That should take a leaf out of MS's book and just nick the good stuff!
the collection library was (and to some degree still is) pretty poor.
Emphasis on was
and to some degree still is
- Abe Miessler
TreeSet
(RB tree) and ConcurrentSkipListSet
(Skip list) that don't have analogs in BCL. I don't say that java is better because of it, just an example - Andrey
(Just to add to what's already mentioned here).
Also, just to clarify why C# and Java were almost identical (when C# was introduced) is due to this person, Anders Hejlsberg [1]. He was actively involved in the Windows Foundation classes for J++, (J++ is Microsoft's implementation of Java) which (as you know, J++ conformed to the Java language specification, with the exception of JNI, RMI, etc.), allowed Anders to see advantages/disadvantages of Java and incorporate it in C# (which he still is a development lead to this day).
Wiki article on Anders [2]:
[1] http://www.c2.com/cgi/wiki?AndersHejlsbergMicrosoft needed a modern platform for windows development which would be as simple as VB6 and mighty like [D]COM. Both were already a bit rusty and microsoft needed a good replacement, they also feared that Java would dominate programming in some time.
Java is not the best way to program for windows, since you cannot access the Windows GUI and API directly, also the Java GUI is much slower than the native Windows GUI and doesn't look like it. Also, you need to install the JRE to get programs to run.
Initially C# and .net were developed by Microsoft to create next generation framework for Windows development. Java was taken as example, a lot of it's features were adopted. But MS didn't plan to take features of Java longer and they significantly splitted after C# 2.0 (.net 2.0), and now they are common in only very basic parts.
The same reason the Microsoft makes a kagillion dollars every year. When they see a good technology they try to either buy it out or make their own.
Examples:
The list [7] goes on for quite a bit.
[1] http://en.wikipedia.org/wiki/Microsoft_SQL_ServerI think one thing to consider also is that C# was not created in an internal vacuum, either; .NET itself was being developed, which was originally intended to be the next iteration of COM.
Think of it as forking a project. Your starting point might be exactly the same as the original project, but now you're free to take it in different directions. Microsoft has done that (not the forking part, since it didn't start out exactly the same, but the different directions part) with C#.
It all comes down to simple business logic:
The .NET platform was intended to be as language-agnostic as possible from the beginning -- one runtime (the CLR, a virtual machine) running its machine instructions (IL, or Intermediate Language) compiled from source code created in any of a number of languages. There was Visual Basic .NET for programmers who were comfortable working in the VB idiom, J# for the Java-inclined, and C# for those used to working in C and C++. (This was at a time in the great Long Ago, before there were any real language alternatives for the JVM.) Java and the C family of languages are very similar to begin with, inheriting their basic syntactical structure from Algol; the primary difference between J# and C# was at the level of minor differences in language keywords and operator characters. The reason there were two such similar languages to begin with was to flatten out the learning curve -- a developer would have to spend a considerable amount of time learning the libraries, but shouldn't have to stop and think about basic language details. There was more apparent similarity between C# and Java arising from the way libraries are accessed than from the languages themselves.
There has been an increasing amount of convergence between C# and Java, and it hasn't all been because of movement on Microsoft's part. Java has learned a few tricks from C# over the years as well. And J#? Well, it was never too popular to begin with. It didn't use the standard Java libraries (it used the .NET libraries, of course) so the convenience of keeping a handful keywords intact was far outweighed by the need to forget all of the no-brainer library functions (standard class methods for data types you'd use every day without thinking). Add to that the history of enmity with Sun over Java implementations, and the cost of maintaining the language just wasn't worth the bother.
As for why a whole new VM was deemed necessary, well, that had mostly to do with the corporate desktop. Have you ever run a major desktop application written in Java (especially those written circa 2003, like the then-current versions of OpenOffice.org or Eclipse)? Have you tried to run it on a typical corporate "we'll upgrade the hardware every seven years whether we need to or not" machine? JNI and SWT didn't begin to make up for the performance and resource problems. VB6 was good for RAD GUI apps, but it had some major limitations (especially data type incompatibilities when accessing external DLLs) and Visual C++ was inaccessible to the average cubicle drone. The .NET platform killed a lot of birds with the fling of a single stone (common data types across languages, optimized access to the native platform APIs, etc.).
Note: I'm not a .NET fanboy, nor do I develop anything on that platform these days, but I do understand the corporate dev environment. C#, and the .NET platform, filled a major void at the time, and its acceptance had at least as much to do with the merits of the solution as it did with Steve Balmer yelling "developers, developers, developers!!!" on stage.
Money. Why pay the organ grinder when you can play the thing yourself and take a bigger share of the profit.
I'm not into this whole technical argument of what is best, because as far as I am concerned its all about the Benjamins.
The argument that Microsoft just buys in technology I think is wrong and very naughty to say. Microsoft does make its fair share in the IT market place and they do innovate. Don't get me wrong I am no Boy lover of Microsoft, but fairness where fair is due, without Microsoft there would be nothing worthy to compete against. They have and still do set the mark in some areas, although they are having a rough time of it trying to compete with something as broad minded as open source.
Hopefully like IBM one day they will see the light and realise that its all very symbiotic and need to get out of the 1980's and start thinking bigger, better and wiser about where they will be in 20 years time. Hopefully Windows will go open source.
Why does google succeed. Simple, they understand the new business way of taking small chunks from lots of people, instead of big chunks out of everyone.
By the way, a little history lesson. Anders Hejlsberg came from Borland with all his wonderful Delphi knowledge, came to Microsoft and started with J++. He then moved across to c#. I moved ship from Borland to Microsoft when he moved, and for good reason. he is one of the best in the field. Take a look at Delphi which precedes java and you will see that most of the constructs look a lot like Delphi. C# for me is Delphi done with curly brackets :)
At the beginning of C#, compared to the rest of computer languages, Java and C# were almost twins.
Microsoft paid hundreds of millions of dollars to Sun for Java related patents.
I find it despicable that the C# camp never gave any credit to Java. Of course, from Anders Hejlsberg(C# inventor)'s point of view, there is nothing new under the sun, he didn't steal anything from Sun, just many old ideas well know to computer scientists for years.
Yet, in 1990s, the idea of Java was preposterous. Sun deserves a lot of credit to push this seemingly academic and toy language to the industry, and proved that it rocks. Without Sun's work, Anders Hejlsberg will not be hired by Microsoft to create a similar product.
I think a good point to note that C# took a lot of concepts from Java and in some cases improved them, and also added a lot of new features to the language such as LINQ.
Both are great platforms for development but I think C# is starting to get an edge over Java, and Im glad I have both available to me as opposed to just one of them.