3 ms·
Garbage collection is a massive gain. Far less code, and less bugs. No brainer decision there. Typing a few less characters on boiler plate doesn't buy you any
by axod 17y ago
Garbage collection is a massive gain. Far less code, and less bugs. No brainer decision there.
Typing a few less characters on boiler plate doesn't buy you anything, unless you're a slow/lazy programmer.
Typing "public static class" is boring, yes. But it's irrelevant. It can't contain bugs, so getting rid of that doesn't buy you anything at all.
Less typing != less bugs (When the code is compiled, statically typed, etc).
There is absolutely no reason to duplicate code in Java, and if you're copy/paste coding, it's not the languages fault, it's yours.
- jodrellblank 17y ago"""Typing a few less characters on boiler plate doesn't buy you anything, unless you're a slow/lazy programmer""" Must be nice to have an infinitely large short term memory.
- jrockway 17y agoNot to mention that I have never said a thing about things like "public static void". I specifically mentioned the object system above and how much manual easy-to-get-wrong code is required simply to make things that have an equals method also have a "not equals" method. Sometimes I wonder why I bother arguing with axod. Wait, I always wonder that...
- axod 17y agoCome on. How often do you really need an equals method in your classes? It's not a big deal. (No, I'm not one of those people who insist on writing equals/hashcode/toString on everything even when it's not being used). I wonder why I try to bring sanity to these sorts of discussions also :/
- jrockway 17y agoThe example is an example. For "not equals" you might as well just write not, then equals. But amazingly, sometimes code more complicated than that needs to be reused I wonder why I try to bring sanity to these sorts of discussions also :/ When did you do that? You seem to bring a lot of emotion, very few technical arguments, and a lot of words like "fashion".
- cia_plant 17y agoSince Java lacks generics, there are many kinds of code which require duplicate code in Java. Specifically, every place where you would use generics in another language (Templates in C++, or TypeClasses in Haskell, for instance).
- hazzen 17y agoJava definitely supports generics as of 1.5 - did you mean that it doesn't support generics to the extent of C++? Most basic uses (containers) are identical between the languages, and while Java doesn't allow compile-time "duck typing" that C++ does, you can fake it by using the "? extends SomeInterface" syntax.
- cia_plant 17y agoJava supports type erasure, which it idiosyncratically calls "generics", even though it does not allow generic programming. A generic function in a language with actual generics can work generically, on more than one type. A "generic" function in Java can work on exactly one type, namely the type which the "generic" type becomes after type erasure. You can use "? extends SomeInterface" only if you write SomeInterface wrappers for every type which you want to use "generically." This is boilerplate relative to most other languages.
- hazzen 17y agoPersonally, I find this boilerplate equivalent to the comments one has to write documenting the requirements of the type, with the added benefit of readable error messages when you pass the wrong type. In other words, I find: // T here is a type that must support these two operations: // bool froznit(); // void frobnob(Foo* foo); template <class T> class Frozner { ... } And public interface SomeStupidName { public bool froznit(); public void frobnob(Foo foo); } public class Frozner<? extends SomeStupidName> { ... } To be just as much work to type.