Every month, TIOBE Software, a Dutch company that makes developer tools, publishes a survey of the most popular programming languages in use. The company uses Google to approximate the number of engineers who are expert in the language, the availability of courses taught in it, and how many companies sell software using the language. TIOBE comes up with a three-digit "rating" based on the count. Java is currently in first place, with a rating of 45.2; the next language, C, has a rating of 32.2, and C++, ranked third, has a rating of 24.6. C# is all the way down at number 9, with a 4.6 rating, one-tenth that of Java.
But the headline at the top of January's chart tells another story: "C# Still on Track to Become Number 1 Within 2 Years Time." According to TIOBE, the popularity of C# is rising faster than that any other language; Java is relatively steady. This shouldn't come as a surprise -- in a sense, it's to be expected, as more people are starting to use C# because it's new.
But the chart prompts two interesting questions: How did Java become so popular? And why is it not popular enough to beat out C#?
In the early 1990s, Sun Microsystems made what could have been an unfortunate business misstep; the company bet that the era of PCs -- a business in which Sun did not have much of a foothold -- was on the wane, and that the influence of the personal computer would quickly be eclipsed by that of consumer electronics devices like set-top boxes. (In retrospect, that hypothesis was early rather than wrong.) To take advantage of the new market, Sun sequestered about a dozen of its brightest engineers in an nondescript office park in Silicon Valley, telling them to come up with something. A year and a half later, they did: They'd built a device called StarSeven that could control a number of home appliances from the touch of a button; at its heart was Oak, a new programming language developed by a Sun engineer named James Gosling.
In time, Sun realized that the Internet, and not set-top boxes, would rule the new digital landscape; and by 1995, when Oak was renamed Java and officially released, the language was anointed as the first programming system of the Internet era. Sun basked in the Internet glory. Java, which was soon being released with the Netscape browser, could do Web animations, and for a while that was its main claim to fame.
The Java language was innovative in two main respects. First, Java is what's called an "interpreted language." There are many technical ways to define this, but essentially it means that a Java program doesn't give instructions directly to the machine it's running on; instead, Java code tells an "interpreter" what to do, and the interpreter then tells the computer. Interpretation is what allows Java to work on many different computer systems, from all flavors of PCs to mobile phones to large servers. To run a Java program on a specific system -- the Mars Pathfinder rover, say -- all one has to do is write an interpreter for that system. (It's the interpreter -- called the Sun Java Virtual Machine -- that Microsoft was ordered to carry in its products. Interpretation has also been blamed for Java's performance problems; but Sun and, now, Microsoft in .Net, have improved their interpreters to a point that there is often no significant performance penalty to Java and C#.)
Java was also interesting to programmers because it was one of the first easy-to-use "object oriented" languages. In the early 1990s, object orientation was the new wave of programming; it's beyond the scope of this article to get into the specifics of the technology, except to say that OOP, as it's called, is a design construct that helps programmers code small pieces of an application separately, breaking up the code into reusable bits called "classes" or "modules." (A good FAQ on OOP is here.)
Before Java, C++ was the foremost object-oriented language -- but, even though OOP was supposed to make programming easier, teaching object orientation in C++ was difficult. When Java was released, "the universities were in a superheated state," says Robert Harper, a computer scientist at Carnegie Mellon. "They were bursting for some alternative to C++, because they wanted to teach object-oriented programming, but using C++ for beginners is just cruel. So from an education point of view many people jumped on Java for their introductory courses." Several other professors said much the same thing; Java is thought to be the premier introductory language on college campuses, and advanced placement high school students use it as well.
Many people say that Microsoft's C# is just a variation of Java; it does some things better, some things not as well, but mostly the languages are very close. "C# is to Java as the Windows interface is to the Mac OS," Harper said.
Anders Hejlsberg, who designed C#, has acknowledged that the new Microsoft language is similar to Java; C# is also object-oriented and interpreted. But Hejlsberg also says that there are significant differences between the languages and that C#, and .Net, are improvements over Java.
According to various developers who've used both systems, the nicest thing about Microsoft's .Net is that it uses multiple languages. The system doesn't lock people in to one language, as the Java platform does; instead, developers can write code in almost anything -- whether in C++, C, C#, or even in Java -- and then have it all translated into what Microsoft calls the Common Language Runtime (CLR). It's this code that is run in an interpreter on your machine.
Miguel de Icaza, the co-founder of the open-source software company Ximian, leads the Mono Project, which has created a Linux version of .Net. He says the advantage of .Net is that it lets developers protect their "code investment." All the code they've already written in C++ or C can be translated -- or "compiled" -- to the CLR. Then, additions to the old code can be added with C#, which will also compile to CLR. Everything will work together as one application, even though many languages may have been used in the creation.
Conversely, "the Java solution to reuse your code investment is to throw everything out and do everything in Java," he said.
Some developers are OK with making that sacrifice in order to use Java, because they see .Net as having one big risk: It will become a Windows-only language. Microsoft denies this charge and points to the standardization of C# as proof. But Rick Ross, the founder of Javalobby, a Web forum for Java developers, said that although he's used C# and likes some aspects of it, he thinks of it as a "Windows-only" language.
What about projects to port .Net to other systems? "I don't expect those to come to fruition in the way that Java is cross-platform," he said, echoing the sentiments of many Java developers. "I know the amount of work that Sun has done to create portability: the fixing of bugs, really working hard to be cross-platform. And Microsoft is not doing that kind of work, and I don't think they'd dispute that. Only small parts of C# got standardized. So yeah, maybe you can you see C# on other platforms, but I wouldn't expect to build a cross-platform application."
But de Icaza disputes such claims. "There's a lot of crack being smoked," he said. "I'm going to tell you what it is -- there are very very very hard parts in .Net, extremely hard parts to do, and those are the things that got standardized. The binary file formats for .Net applications, that got standardized. Everything else that was easy didn't get standardized, but the important parts did."
As a consequence, he said, .Net on Linux is a reality, "and Mono is good proof of it. De Icaza said that Ximian is already coding some of its programs in C#, and he expects that in time its flagship programs -- like Evolution, the company's mail program -- will be coded, in part, in the .Net scheme.
But even so, de Icaza concedes that it will take a while to create applications in .Net for Windows that can also easily run on Linux in Mono. That's because key parts of what makes an application work in Windows aren't available in Mono. And some of those parts are very closely guarded pieces of the Microsoft empire -- so is it reasonable to expect the company to let that stuff go to other platforms? That's not likely.
When asked to guess whether C# or Java would be more popular in the long run, almost every programmer contacted for this article demurred -- and then waxed philosophical on the nature of languages. Programming languages, several said, are like religions; programmers grow accustomed to a language, or a family of languages, and despite all logic or argument or practical necessity, they will stick with it because it's what they know, what they believe in.
In the end, C# and Java are perhaps best analyzed in that light. They may be similar languages, but there's a philosophical gulf between the two. The people who ultimately choose Java will likely value compatibility over the performance gains you get from building a program specifically for one system. They'd prefer that everything ran everywhere, even if they have to lose their "code investment." The people who choose .Net may also care about going cross-platform, but they'd like some flexibility in the matter. They'd like to be able to build a program that runs only on Windows, so it works with all their other programs that also work only on Windows.
What will the majority choose? That question could have vast implications for the world of software. Not least would be the one that scared the hell out of Gates in 1996: If Java wins, and most programs run across all software, what use will any of us have for Windows anymore?