5 ms·
Me too. I had a hard time reading on after that. Java is absolutely chock-full of "things that sounded like a good idea" -- unboxed types, single inheritance,
by jrockway 17y ago
Me too. I had a hard time reading on after that.
Java is absolutely chock-full of "things that sounded like a good idea" -- unboxed types, single inheritance, interfaces without the possibility of shared implementation (or state), public / private / protected / default, positional constructor arguments, "Type foo = new Type", etc. Actually, none of those even sound like good ideas. (But I guess after the brain damage that was C++, it was inevitable that The Industry would overcorrect. Hopefully we've learned one important lesson from Java -- making the language "simple" won't stop people from writing bad code, but it will stop people from writing good code.)
Java also popularized some very very experimental ideas, like virtual machines and automatic garbage collection. (And I am very thankful for both.)
So now that I think about it, I don't get that quote at all.
- mike_organon 17y agoAlso, checked exceptions were not used before, but sounded like a good idea. And they turned out to be harmful in my experience.
- jrockway 17y agoYes, you are absolutely right. They sound like a great idea, but it seems like "throws Exception" is something that gets tacked onto any method with side effects. It's just not easy to write imperative programs without throwing exceptions somewhere along the call chain. (Another thing that could have gone this way are parameterized types representing null/not-null, like Haskell's Maybe or Either. It seems like a lot of work to annotate every type that can possibly be null, but it is not onerous at all in real life. A few functions are Maybe/Either, but most aren't; and for the price of an annotation you can be sure that you will never get a "NullPointerException". Checked exceptions could have turned out this way, but something about Java, Java's libraries, or imperative programming in general made this not so.)
- bad_user 17y ago> It's just not easy to write imperative programs without throwing exceptions somewhere along the call chain With checked exceptions it is also not easy to be a good OOP citizen and not break encapsulation, since checked exceptions become a part of your interface.
- wingo 17y agoIt's not all that consistent, no. But for me what it cues is Perlis: "Algol is a blight. You can't have fun with Algol. Algol is a code that now belongs in a plumber's union. It helps you design correct structures that don't collapse, but it doesn't have any fun in it. There are no pleasures in writing Algol programs. It's a labor of necessity, a preoccupation with the details of tedium." From http://www.eecs.berkeley.edu/~bh/ss/foreword.html http://www.eecs.berkeley.edu/~bh/ss/foreword.html.
- axod 17y agoI'll have to disagree with you there. Type foo = new Type() is a bad idea? why? Shape myShape = new Rectangle(); seems pretty logical to me. If you want to use static types, you can't really argue against that syntax. single inheritance sidesteps lots of potential issues, and interfaces are cleaner IMHO >> "but it will stop people from writing good code." I'd also strongly disagree with that. Arguing that Java prevents you from writing good code is nonsense. As much sense as saying using French prevents you from writing a good story. I've seen some brilliant code written in Java (If you steer well clear of 'enterprise' etc).
- jerf 17y agoBecause "Type foo = new SubType()" comes up approximately never. Note, I did not say never. But don't give me a line about how you use it all the time. You don't. If you think you do, go grep over your code; you may think you do but I still bet you don't, it's probably a perceptual bias where you notice the exceptions out of proportion to their actual occurance. If you still pass that test, congratulations, I was wrong, you're one of the five people who do it all the time. You should probably stop, as something is probably very wrong with your design. Meanwhile, optimizing the syntax for this case is a terrible optimization decision. That's the real problem, forcing literally millions (conservatively) of type annotations that are totally redundant. "I've seen some brilliant code written in Java (If you steer well clear of 'enterprise' etc)." You don't see the brilliant code that was never written because Java doesn't offer you the ability. I also point to the "brilliant code" that isn't Java code at all, but compiler and bytecode hacks, which I suspect had you taken the time to mention some examples of "brilliant code" would have been in the list. That's not brilliance you can credit to Java, it's simply stuff that was so desirable it had to be done despite the fact Java didn't permit it.
- axod 17y agoI do use it every now and then, but personally even when types are the same, I don't really have issue with it. Makes it easy to see which type something is, and keeps things uniform and sane. Shape foo = new Shape(); is often written separately: Shape foo; // Further down foo = new Shape(); So in that instance it's easy to see in both places what foo is. If you do have issues with the duplication, it wouldn't be crazy hard to just write a pre-processor to insert the Types on the left if you haven't specified them, before compilation. I simply don't buy the notion that you can't write great code in language X. Language is largely irrelevant to how great the code is or isn't. Also irrelevant to how well you can scale, how successful your startup will be, etc etc Great coders write great code. Languages are just ways of communicating that great code with machines, and other people.
- radu_floricica 17y agoWhy? You're right that Java was a reaction to C++, and in that view it was a rather simple language. Virtual machines and garbage collection were indeed new (well, new for C-like languages. actually, new for c++), but one was necessary in order to make java embeddable (which was one of its primary goals initially), and the second was a very necessary solution to too many years of malloc. But the essential point is that after HelloWorld a C/C++ programmer with a JavaDoc can pretty much start churning code. The immediate consequences, way before getting to esoteric disputes about single/multiple inheritance, were only positive: the code was portable, memory problems disappeared, the documentation was in one place, the library was standard etc. The language itself, for the ordinary programmer of the time, was just simplified C++.