6 ms·
Why I hate Java
- Analemma_ 9y agoIs there a date on this? This feels like a (1997) article at the latest.
- jaclaz 9y agoMaybe not 1997, but surely not "recent" (let alone "news") at least the Wayback Machine has it archived since Feb 8,2006: https://web.archive.org/web/*/http://warp.povusers.org/grrr/java.html https://web.archive.org/web/*/http://warp.povusers.org/grrr/...
- deleted 9y ago[deleted]
- foota 9y agoIt predates generics at least.
- Retric 9y agoGenerics don't solve the TypeDef problem. It's the old, I am probably never going to need anything over 2 billion, but I am not 100% sure.
- AstralStorm 9y agoGeneric method syntax is both much more limited and more complex... Foo<? super Bar extends Madness> with various insane limitations. Makes C++ SFINAE seem elegant...
- foota 9y agoI was talking about the following: "Now, in Java, if you use a data container provided by the language, you are forced to upcast all the time." Which is solved by generics.
- Retric 9y agoLast I checked, if you store an int in a generic it get's converted to an object which takes more memory to store. So, the syntax is similar, but the actual behavior is not because int's can't be null, but Integers can for example. This costs 8 ish bytes of memory.
- foota 9y agoThat is true. It looks like there is some work being done to potentially relax this constraint, http://openjdk.java.net/jeps/218 http://openjdk.java.net/jeps/218
- zokier 9y agoAnd according to Wikipedia generics were added to Java in 2004, so that gives some baseline. JSR14 was for introducing generics, and it was initiated in 1999. That leaves 5 year window during which the article was most likely written.
- khedoros1 9y ago> And according to Wikipedia generics were added to Java in 2004 I was in college around that time, using Java as a language for coursework. The professors jumped on generics right away, so between two quarters, the style that we wrote our Java in shifted drastically. I was nice to rip the band-aid off that fast.
- nayuki 9y agoThe index page has dates for other articles, but not this one. http://warp.povusers.org/grrr/index.html http://warp.povusers.org/grrr/index.html Archive.org's first snapshot of this page is on 2006-02-08. The HTTP response headers contain the entry: "Last-Modified: Sun, 14 Oct 2012 08:58:12 GMT"
- CalChris 9y agoArchive.org says 2006. https://web.archive.org/web/20060208015310/http://warp.povusers.org/grrr/java.html https://web.archive.org/web/20060208015310/http://warp.povus...
- maxxxxx 9y agoI ma not sure about the rest of the points made but I agree about the lack of deterministic destructors to free up external resources. C# has the same problem. It would be really good if the destructor ran when the reference count of an object goes to 0. This would make a lot of code that deals with OS resources much cleaner.
- markdoubleyou 9y agoIsn't this what the AutoCloseable interface (combined with try-with-resources statements) addresses for everything except memory? It wasn't added until Java 1.7, though, so maybe the article predates that feature. https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html https://docs.oracle.com/javase/tutorial/essential/exceptions... ...basically it's the same as .NET dispose pattern for achieving deterministic cleanup. Most IDEs and code analysis tools will throw a fit if you don't use an AutoCloseable/IDisposable class properly in a try-with-resources/using statement.
- maxxxxx 9y agoThe dispose pattern puts the work on the user of the resource. In addition I have seen cases of classes that didn't need to be disposable but later changes were made that required them to be disposable. Now you have code using these classes that don't dispose them. I much prefer destructors like in C++ (or VB or even PHP) that run when the reference count goes to 0.
- zzalpha 9y agoC# has a using block that makes resource deallocation explicit syntax, which I far prefer to implicit destructor behaviour. That said, we need IDEs that sound the klaxons if a Closeable is not placed in a using statement.
- maxxxxx 9y agoI find the using syntax pretty ugly especially once you have several objects. Some keyword like "autodispose" may help. Managed C++ has this. Objects that are allocated with the stack syntax get disposed at the end of the scope.
- yincrash 9y ago"Why I hate garbage collected languages"
- adgasf 9y agoIt would be interesting to see a language that implements RAII but provides a GC as a fall-back.
- dmead 9y agoor just manual memory management with gc as a catchall..
- advisedwang 9y agoYou might like to have fun with the Boehm GC: http://www.hboehm.info/gc/ http://www.hboehm.info/gc/.
- akvadrako 9y agoPython uses reference counting with GC as a fall-back. RAII is basically reference counting with destructors, but it's not very useful if the object lifetimes are not easy to reason about. The optional GC (for circular references) greatly complicates things. [1] http://arctrix.com/nas/python/gc/ http://arctrix.com/nas/python/gc/
- zokier 9y agoRust went through that stage at one point. It had language-level support for GC, first by having @-pointers (e.g. @i32 would have been pointer to GC-managed int) and later when sigils were removed it had short-lived Gc<T> type. iirc GC support was finally completely removed during the crunch to 1.0. I'd point out that afaik rustc never got a proper good GC implementation (which probably weighted heavily in the decision to remove it before 1.0), so @T/Gc<T> were mostly plain old refcounted pointers with some smoke and mirrors. See http://words.steveklabnik.com/pointers-in-rust-a-guide http://words.steveklabnik.com/pointers-in-rust-a-guide for example (section "Managed pointers")
- kazinator 9y ago
- TheGuyWhoCodes 9y agoShould add 2006 to the title...
- tieTYT 9y ago> Why does this matter? It matters for the exact same reason why memory leaks are bad in general: They consume more memory than necessary. Thing is, this doesn't usually matter. I have never gotten an out of memory error from a leak in Java. Now compare that to all the development time I've saved by not having to deal with pointer arithmetic. I consider it a huge win. It's all about the type of apps you're making.
- AstralStorm 9y agoYou haven't used anything nontrivial then. Say, IntelliJ eating 2 GB of RAM, quite a lot for a glorified editor...
- tieTYT 9y agoI didn't build that. How are you so sure it would have less leaks if it were written in a language like C++? I'd bet it would be worse.
- seanmcdirmid 9y agoJust because IntelliJ is using 2GB of RAM doesn't mean they have a memory leak. As long as that 2GB profile is stable, it isn't going to bring down the system.
- majewsky 9y agoWhen I play Minecraft on my notebook, I first shut down all nonessential system services (I have a handy line in the shell history for that). This allows me to get around 45 minutes out of Minecraft (instead of 30 minutes) before it gets struck by the OOM killer.
- tieTYT 9y agoI've used tons of programs that have problems and crash for various reasons. Is this an argument against the language? I don't think there'd be any left to use with this line of thinking. Besides, there's too many variables in your anecdote. Is it a laptop from 1995? Is the OOM from a bug that could/should be fixed?
- sanbor 9y agoWhat about the point of gc solving the issue of your app crashing or security issues everywhere because a malformed input ends up crashibg/executing code? In the debian security mail list almost every week there is a path for that situation so looks like it's pretty common.
- AstralStorm 9y agoGC does not solve any kind of a crash. (In fact might cause some extra NPE or out of memory crashes.) Safe pointers do. That is a separate feature of Java from GC.
- nayuki 9y agoA precise garbage collector requires safe pointers. A precise GC allows the copy/move/compact strategy, whereas a conservative GC only allows mark-and-sweep.
- kronos29296 9y agoI don't know about the other things but Even Bjarne Stroustrup calls multiple inheritance the wrong way to go. I don't think I'm better than him. So I disagree on that. The other stuff - Well all languages are imperfect. That's why we have so many of them.
- lispm 9y ago> One problem with garbage collection is that it needs to see the entire memory used by the program even if the program is not using big parts of it for anything. The first generational GC was proposed for Lisp in 1983. See Liebermann&Hewitt. The heap is divided into generations based on the lifetime of objects. Typically only the youngest generation, which is kept small, is scanned. This is based on the observation that a lot of objects are only short-lived. Thus a GC does typically does only need to look at a fraction of the memory. Also GCs might want to use regions of similar objects. That way only those regions need to be looked at, which may free up space for an ohject that wants to be allocated currently.
- carsongross 9y agoJava is a decent language for its time, with a bad default tool set and a development culture that leans very heavily towards J2EE-style verbosity (javascript is trending that way now too, w/ angular, react, etc). The JVM, however, is a national treasure.
- westoncb 9y agoProbably worth jumping up a level in the URL to: http://warp.povusers.org/grrr/ http://warp.povusers.org/grrr/ —and noting that this comes from the guy's "What grinds my gears" page, which also links to a "Why I hate C" article.
- burntrelish1273 9y agoRisking discussing religiousity: Java as a language has some rough-edges: multiple inheritance and verbosity. Personally, I'd use Kotlin if there were a requirement to run on the JVM. In terms of the JVM: Erlang VM is under-appreciated: each "process" (not an OS process and lighter than an OS thread) has its own heap so there's no global GC pauses, share-nothing and let-it crash doesn't take out Erlang VM. For anyone stuck on JVM, look at Azul's free Zing for shorter/less GC pauses and a generally faster JVM.