Why I hate java
Hello everyone.
I hate java (the programming language, not the coffee nor the island--about which I have no knowledge, and therefor no opinion). I'm here in part to explain why, in part to figure out why. I'm NOT here to tell you that you should hate java--if you really love it, I accept that (depending on such contingecies as the existence or lack of existence of free will, it may or may not be your choice, but in any case it's my choice or lack of choice to accept that--and in fact I would like to understand why). So, on to the good stuff: why do I hate java? The easy answer, which only shifts the question, is that it doesn't posses the qualities that I like about programming languages. That of course raises the question: what is it I like about programming languages? Perhaps I can best figure this out by looking at the programming languages I like the most--at the moment those are C and python--and work out the differences between them and java. Firstly I agree with the `spirit of C' (copied from http://www.artima.com/cppsource/spiritofcP.html), as stated in the ANSI C standard rationale: Quote:
Let's see--does java succeed at this? I don't think so:
Anyways, I've just got a new keyboard in the mail, so I'll shut down my machine now. Perhaps I'll come back and edit this. Just to make sure I get this stated clearly enough: Donald Knuth held a lecture series about CS and religion, during which he was asked what his number one wish wrt. completing TAOCP was, to which he replied (paraphrase): "This field (CS) is moving so fast. I'd wish for more bad ideas to slow everyone down--I'd like to see more things like java." |
This is a very well-written article, and I applaude you on it - great job, but I think it would be better off as a blog post.
Edit: removed an excess "and" - wonder where that came from |
Jonas, nice article. Although I'm not too technical, I think that Java kind of imposes itself in the programmer while other languages like C and Python allow the programmer to work with it.
Good work. And I disagree with Scuzzman. Blog posts get lost easily and nobody ever reads them here. If we have an article to share, then maybe this is the best place, because 1. Linking to our own site is not allowed. 2. Blog gets lost easily. 3. This forum seems to get more visibility than the "Linux - News and Articles" section. Maybe we need a place where people can post these general articles (not specifically related to technical issues with Linux). The blogs just are not visible enough. |
As well written as this post was, it's very, very opinion driven. I, for one, found laughable that this "Committee" believes that portability is not an important issue. I develop Java applications at home and at school and we use a lot of different OS'es. It's a bless that Java's ability to run across platforms does not stay in the way. Some students has Mac, other Linux, some Windows and we code mostly in Sun Sparc / Solaris architectures.
As we would be arguing with our own opinions ratter then facts, I won't post a long message as yours telling you why Java rocks, but I will tell this: Java has it's importance and usability just as C or python does. Use the right tool for the right job. You won't go anywhere trying to write drivers for a piece of hardware with Java as you won't be very successful writing firmware updates using C or Python. And as soon as you step in GUI-programming with C you will be crying for a "real" OOP language. Again, right tool for the right job. Don't go using your F50 to some Off-road weekend. |
Quote:
Quote:
Code:
System.out.printf("i = %02d, A[i] = x = %f, f(x) = %f", i, a[i], f(x)); |
Funny thing is the reason I dislike Java most is it's too C-like. I prefer plain English. Spelling out the word AND is only one character more than && and infinitely less cryptic. Any decade old compile time justification is lost to me on my 3 GHz PC. :o
|
This section is in response to Mega Man X:
Quote:
Quote:
Quote:
[quote]you won't be very successful writing firmware updates using C or Python[quote/] I haven't tried that, so I can't argue against your claim, but I can ask you to explain me why C and python are both inadequate for the job. The following section is in response to jlliagre Quote:
I think the C++ standard library is just about the right size. The only fundamental thing I think is missing is graphs and a few more `garbage collecting' smart pointers, but see also my next installment. Quote:
And I also have a word for crito: yes, I prefer `and' to `&&' by far. python only has english, C++ has both, and C has #define (and I often define `and', `or' and `not' to their expected values). Java has nothing. |
Quote:
Well, here's my opinion: I like java because it's very C-like, and I like it too because it removes some of the C issues. |
@jonaskoelker
I must say, it has been a while since I read threads from peoples who know what they are saying and has a point. I really like reading your thread and your replies, even though I don't agree with everything (otherwise, where would the fun be, ^_^). I actually started a similar thread a while ago called "So, why not Java". I'm mostly interested in game programming and I just happen to use Java a lot. You can check the old thread here: http://www.linuxquestions.org/questi...highlight=Java C is not good to write firmware because, well, it's still too big to fit in embedded systems, as far as I can tell. The language used to write firmware is called "Forth". Forth language is usually used to compile threaded code. It's heavily used by Sun and IBM for their BIOS and coincidentally, FreeBSD uses the fourth language at the first stage boot controller. You can take a look at fourth here: http://galileo.phys.virginia.edu/cla...l01/primer.htm What I dislike in Java, if anything, is actually it's own portability. While portable enough, we have to wait(or beg) for Sun to port the Virtual Machine to other systems(at least officially), such as BeOS or even FreeBSD (OS that I love, by the way). Also, while appealing for me to develop games with, I'm very well awared of the limitations of Java, especially if I ever wanted to move to console programming. Gameboy Advanced uses C, for example (in a very OOP fashion way though). |
Happy hacking
So, this is the second installment in my `I hate java' article.
In this, I talk about some of the other programming languages that I like less than C and python. In particular, I plan to talk about C++, lisp/scheme, perl and bash. I'll also try to compare them to java, and explain why I would pick them over java any day of the week. What all these languages have in common is that I can understand why someone would use them--they all maximize some characteristic: C++ has its expressiveness (that is, you can express everything *very* precisely), lisp through its macro system has its flexibility, perl is very pragmatic, and bash has the biggest `library'. But that being said, each lacks something: C++ is too big and complex, lisp is too verbose--I want to write collection[i], not (vector-ref collection i)--perl is *too* pragmatic (that is, at the cost of maintainability), and bash is unportable. So, let's have a closer look at each one, starting with [b[C++[/b]. I once actually really loved C++, and I think it does contain something very valuable. For one, I think templates is one great idea--type-genericity in general is a good feature. However, the syntax is horribly verbose. I think I'll confine myself to *using* template classes and functions. Of course, it adds praise to good health that there is a decent standard library utilizing templates to achieve something useful: saving the programmer from implementing vectors/lists/maps/sets over and over again (I from time to time miss slists and hashmaps in the stdlib, though, but one can use stlport). Then there's exceptions. While useful sometimes, I both laugh and cry at the option of throwing a bool. It *does* provide a decent way to `return' a bool from a deep recursion tree, but it has to be used carefully to not shoot yourself in the foot. Then again, trust the programmer. I'm abivalent on exceptions as they're implemented in C++ (I think they're done ok in python and SML, and their absence is done well in C). However, on top of something very useful, C++ also adds object-orientation, the problems of virtual/non-virtual inheritance, member pointers, template template arguments (who use these?), horrible iostream syntactic conventions. In other words, C++ loses the simplicity and compactness C and python contains. From `Why python' (http://www.linuxjournal.com/article/3882) by ESR: Quote:
So, in the end I somewhat dislike C++ because of it's lack of compactness, and it's verbosity of templates (SML does templates--`type genericity'--much more elegantly and tersely). Then again, C++ doesn't impose on me--it doesn't stop me from doing what needs to be done. Also, a strength it shares with python and (to a lesser extent) C is its capability of multiparadigm programming (although C++ is best at proceducal and OO, C is best at procedural and OK at OO, python is best at OO and fine at procedural, they can all do some functional `tricks'). Also, given the close-to-the-hardware'ness of C++, I miss a statically sized bit array, and a guarantee that vector<bool> uses only one bit per element (or as close as possible). Also, one thing I slightly dislike about C++ is that strings aren't just a vector<char>: Taken from http://www.paulgraham.com/hundred.html Quote:
I have limited experience with lisp/scheme, and I haven't truly loved them, although I can see why some people would like them: they offer flexibilty and some (in the words of RMS) mathematical cleanliness. It's of course the king of flexibility with the macro system being able to replace any macro invocation with an arbitrary parse tree, something cpp can't (although cpp can do 80% of the job with 20% of the effort--all in the best `worse is better' style). Let me restate a point: Quote:
However, I also dislike the way my code looks (see also http://www.paulgraham.com/pypar.html)--not that I mind the paranthesis, I just don't think there's any way to indent the code such that it's both pretty and doesn't use my whole screen for three levels of nesting. This might be because I'm working against the language instead of with it--admitted, I probably don't truly grasp functional programming--but this *is* a problem, and I'd rather write SML (which has *no* macro system) than any lisp I know currently (elisp, PLT scheme). Also, if the books on functional programming are representative for the languages, the paradigm is only good for writing metacircular interpreters :P In any case, I still think lisp isn't getting in the way, some of it is just getting in my way. All right, next victim is perl. I haven't written a whole lot of perl, but I've read some and successfully added a feature to a script (update-alternatives, a debian tool). So, what was my experience? For one, I really hate that one has to write braces around single-statement-body compound statements (i.e. if, while, for). Yes, one can write them as statement modifiers, but one can only get a subset of the effect, AIUI (How does one do multiple if/else?). But that's an acceptable syntactic issue. Another syntactic issue is the glyphs (what the &@$% was Larry thinking?), but I can possibly accept that. What I really dislike is the distinction between list/scalar context. What does `reverse reverse "hello"' mean in scalar context? In list context? It's not the same. That, plus the use of default variables costs perl a lot in readability, which is much more important than people think. Think about this: a lot of time is spent modifying and debugging code, and a lot less writing it in the first place, during the lifetime of a software project that actually `takes off'. Then again, perl is pragmatic too: "print while(<>)" is a bare-bones cat(1). That extreme brevity may not extend completely to every use of the language, but let's just say that perl is (or at least can be) terse. So it does make for short programs. So, let's have a look at the final language of this installment, bash. bash is, as you know, the default interactive shell for about 90% of all GNU/Linux systems. And for small hack-it-together uses it's quite good: Quote:
However, that library is not guaranteed to exist on every platform, it's not guaranteed to be usable in the same way, and you're not guaranteed any consistent initial state (updatedb has been run recently? Don't count on that). There's not even a guarantee that bash is available, it might be some other posix-compliant shell. So, of course, there's the GNU autotools which outputs portable configure scripts to make your C programs more portable, but still... it says a lot about shell scripting that portable scripts are best generated. So, that concludes my brief tour of other programming languages I like less than C and python. Let me summarize, and explain why I like them better than java. java (esp. java 5) is pretty close to C++: OO, exceptions, templates, strong static manifest (i.e. `spelled-out') types. However, C++ doesn't impose on you--it trusts you to only shoot yourself in the foot when you have to. Then there's lisp. Lisp is the king of flexibility at the expense of brevity. Java, too, is very verbose (`ArrayIndexOutOfBoundsException'? Not `IndexError'?), but it's not a trade-off, it's just a sacrifice--I don't think I gain anything by using java over lisp. Then perl: perl loses some readability, which java also loses through it's (blantantly stupid) only-one-public-class-per-file rule--it takes a lot of programmer time in getting into the deep focus when one has to switch file all the time. However, java doesn't buy me pragmatism (show me a one-statement cat). Finally, there's bash: it matches java wrt. stdlib, and loses out on portability, but it buys a whole lot more of two-line hacks than java can ever dish out--which is a good trade for the domain of bash. So, I'd prefer C or python to each of these four for most projects, I think these are good choices for some programs and/or people. Bash for the two-line hacks, perl for the 100-line hacks, and C++ for the 1M-line `hacks', and lisp for those who like lisp. But C beats java on speed, and python beats java on code size, so I don't still don't think java is the best tool for any job. At least not for me. Maybe if one really likes java (but I can't see that happening). And just to make sure I don't forget to mention it: Paul Graham has a lot to say about java's cover on http://www.paulgraham.com/javacover.html -- and I agree especially on the hyped part: good languages don't have to be hyped, they get used because they are good. Anyways, again, this is just my opinion. If you like java, more power to you. As long as your code is free and can be compiled and run on a free compiler and VM. |
As a side note to Mega Man X, C can be compiled for PICs, some of which have only 256 bytes of RAM. Of course, it's a very limited version of C (not the real C by far), without the stdlib, but still...
|
i just read that for a second but dude
Code:
static void fail(String msg) { no compiler should let you do that. as for java vs other languages its like saying why i like hammers instead of screwdrivers. truth is sometimes one does what you want better that the other. |
It may be a horrible hack but it is the programmer's perogative not the languange's.
Those who like the idea of Code:
#define && and http://thedailywtf.com/forums/60067/ShowPost.aspx |
In college 1 year ago they made me learn Java and JSP saying it was the future. I got out of school and everyone is using PHP and ASP.
|
If it was up to me everyone would be programming in Pascal or Ada. :p Shouldn't take two lines of comments to explain one line of cryptic (C-like) code. :o
|
All times are GMT -5. The time now is 10:04 PM. |