{"id":35,"date":"2007-12-10T16:13:08","date_gmt":"2007-12-10T15:13:08","guid":{"rendered":"http:\/\/www.bluej.org\/mrt\/?p=35"},"modified":"2020-05-15T15:46:27","modified_gmt":"2020-05-15T15:46:27","slug":"in-defense-of-java","status":"publish","type":"post","link":"https:\/\/blogs.kcl.ac.uk\/proged\/2007\/12\/10\/in-defense-of-java\/","title":{"rendered":"In Defense of Java"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bluej.org\/mrt\/wp-content\/uploads\/2007\/12\/wall-smaller.png\" border=\"1\" alt=\"Java sucks\" hspace=\"4\" vspace=\"8\" width=\"460\" height=\"304\" align=\"right\" \/><br \/>\nRecently, I wrote a blog post titled &#8220;<a href=\"http:\/\/www.bluej.org\/mrt\/?p=34\">Can Java be saved from death by feature bloat?<\/a>&#8220;, that commented on some of the feature proposals for Java 7 (and some existing ones).<\/p>\n<p>This post generated many comments. Some of them are so stupid, that I feel compelled to respond.<\/p>\n<p>What I really want to get across with this is: I really like Java. It&#8217;s a great language, and most of the language zealots haven&#8217;t got a clue what they&#8217;re talking about.<\/p>\n<p><!--more--><br \/>\nIn the last post, I was critical of some of Java&#8217;s features. This seem to have been interpreted by some as saying that Java is just bad. (Some of you didn&#8217;t interpret anything at all, and just took this as a chance to share your wisdom in succinct and witty statements such as &#8220;Java sucks&#8221;. The capacity for interpretation of argument there was obviously neither achieved nor required.)<\/p>\n<p>Some comments were made on my blog site, and these are largely thoughtful and interesting observations. The post was, however, also discussed on <a href=\"http:\/\/programming.reddit.com\/info\/62j9j\/comments\/\">reddit<\/a>, and there some comments were&#8230; &#8211; how shall we put it? Let&#8217;s say, in terms of intellectual insight some of them were clearly flying under the radar. Some people don&#8217;t seem to have two brain cells to rub together.<\/p>\n<p>I was, to be honest, quite dismayed to see some of the mindless drivel that passes for comment on reddit, and to become, by association, linked to these diatribes.<\/p>\n<p>So, let&#8217;s get some things straight: The reason why I discuss (and criticise) Java, is because I care about Java. I like to write in that language, and I&#8217;d like to contribute to its evolution.<\/p>\n<p>Too many people who don&#8217;t understand language design, who &#8211; I suspect &#8211; often know only a single language well, think they need to tell the world what&#8217;s right. Java did, in fact, get many more things right than most other languages of its time. Let&#8217;s look at some of the common statements. According to some of these comments, Java is a &#8220;design failure&#8221; because<\/p>\n<ul>\n<li>Java&#8217;s object model is wrong (Java should not have primitive types)<\/li>\n<li>Java should have closures<\/li>\n<li>dynamic typing is a lot better<\/li>\n<li>Java should have had genericity from the start<\/li>\n<\/ul>\n<p>&#8230;and so on.<\/p>\n<p>First of all: Java is one of the most successful languages ever by any metric you care to dream up. Number of lines code written in it. Number of programmers using it. Number of commercial projects using it. Or non-commercial projects, for that matter. Number of job offers. Number of universities teaching it. In all of these, Java would be in the top handful. <em>THIS IS NOT A COINCIDENCE<\/em>! It is just not the case that you alone know what&#8217;s going on and thousands of project managers and academics don&#8217;t. You may think that. If you do, you&#8217;re probably wrong.<\/p>\n<p>Java is, in fact, quite a nice, clean implementation of object orientation. Many of you are whining about a &#8220;design failure&#8221; with the object system, because of primitive types? Get over it.<\/p>\n<p>Even though I like uniform object systems as well (where every entity is an object), the fact is that Java&#8217;s compromise was &#8211; I am convinced &#8211; the right one to make at the time.<\/p>\n<p>To appreciate that you need to be able to remember what the programming world was like when Java came out. When Java was published, one of the main criticisms was that it &#8220;is so slow that you cannot use it for anything that matters&#8221;. This was apparently because it ran on a VM.<\/p>\n<p>The <a href=\"http:\/\/www.idiom.com\/~zilla\/Computer\/javaCbenchmark.html\">myth<\/a> about Java being too slow is, in fact, so strongly perpetuated that even now I get people coming to my classes who don&#8217;t know anything about anything, but come out in the first class with &#8220;I don&#8217;t like Java &#8211; it&#8217;s too slow&#8221;. (When asked why they think that, they usually say something like &#8220;my brother told me&#8221;&#8230;)<\/p>\n<p>And now people suddenly say &#8220;Why is not everything an object in Java&#8221;? (And they are probably the same people&#8230;)<\/p>\n<p>The fact is that Java would have had a MUCH harder time being widely adopted commercially had it not made some of the compromises it has. Had it not made the compromise on the split type system (with primitive types and objects types) for efficiency&#8217;s sake, the hurdle might have been difficult to overcome.<\/p>\n<p>A similar compromise is the choice of syntax. The important concepts (the object orientation model) is influenced by a set of languages (including, for example, Modula-3), but the syntax is based on C. That&#8217;s just horrible, from where I&#8217;m sitting, but I think it was necessary. Java was initially marketed as a &#8220;cleaned up C++&#8221; (which is essentially a lie, but a convenient lie). In fact, it differs so substantially from C++ in all concepts that really matter that the similarity is just skin deep. But it helped perpetuate the myth for a while that &#8220;if you know C++, you almost know Java&#8221;, and encouraged programmers to look at the language and switch.<\/p>\n<p>See, there are basically two types of programming languages. There are research languages that introduce new features and experiment with them. They are usually not commercially successful, but advance programming language design as a discipline. And then there are consolidation languages that take and combine a selection of the best features and mould them into a single, coherent, commercially viable language. Java is such a language.<\/p>\n<p>To do this, one has to make compromises. Getting a language widely adopted is very, very, very hard. I think the compromises made by the initial Java team were very clever and obviously paid off. Not often was a language such a clear step forward as Java was in 1995.<\/p>\n<p>All language design is compromise. Everyone who has ever designed a language knows that. It is incredibly easy to pick a single feature and criticise it, but you are usually ignoring a whole stack of other forces and arguments that play into it as well.<\/p>\n<p>That we discuss how to evolve a language has nothing to do with trying to imply that things were wrong at the time. To take a critical discussion of possible new language features and to turn it into a silly my-language-is-better-than-yours squabble is the most primitive, short-sighted reaction possible.<\/p>\n<p>Every successful language has its strength. Denying that Java has its strong points is just silly. Arguing that one language is better than another is equally silly. No language is better than another full stop. A language is better than another one only <em>for a given purpose<\/em>. Passing value judgements without context is just saying &#8220;a screwdriver is better than a loaf of bread&#8221;. So?<\/p>\n<p>It is easy to look back now in hindsight and say &#8220;but Scala\/Python\/Haskell\/Squeak [insert your hobby horse here] does feature X so much better&#8221;. That might be true.<\/p>\n<p>But language design with the goal of creating a widely useful commercial language is not about single features. It is about the compromises you have to make to successfully build up a whole ecosystem of technology and support, and that includes many more things. Java runs today on desktops, enterprise systems, web platforms, embedded systems &#8211; essentially unchanged. This is an achievement that shows an amazing engineering foresight and success that has not often been reached.<\/p>\n<p>Anyone who doesn&#8217;t recognise this just doesn&#8217;t understand the last 20 years of programming language history.<\/p>\n<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bluej.org\/mrt\/wp-content\/uploads\/2007\/12\/deco.png\" border=\"0\" alt=\"\" hspace=\"4\" vspace=\"4\" width=\"63\" height=\"38\" align=\"middle\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I wrote a blog post titled &#8220;Can Java be saved from death by feature bloat?&#8220;, that commented on some of the feature proposals for Java 7 (and some existing ones). This post generated many comments. Some of them are &hellip; <a href=\"https:\/\/blogs.kcl.ac.uk\/proged\/2007\/12\/10\/in-defense-of-java\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":179,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[63],"class_list":["post-35","post","type-post","status-publish","format-standard","hentry","category-java","tag-java"],"_links":{"self":[{"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/users\/179"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":1,"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":1052,"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/posts\/35\/revisions\/1052"}],"wp:attachment":[{"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.kcl.ac.uk\/proged\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}