4 ms·
Ask HN: Have you seen some beautiful Java Code?
Recently I've been working in Java, on a project started years ago. All the code I see, whether developed inside this project or in external libraries, is horrible.
It is almost devoid of content -- hundreds of classes, each doing a few assignments and logging some data, and then deferring to another class.
I've seen some beautiful C code, e.g. the LuaJit2 compiler written by Mike Pall. I've seen beautiful C++ code in the FLTK project. I've found beautiful Python code e.g. in apenwarr's "bup" and "redo" projects.
But I've never seen any beautiful java code that gets something done clearly. Did you?
- j_baker 16y agoI'm not a Java fan, nor have I read much Java code at all, but I'm willing to go out on a limb and say that somewhere there exists beautiful Java code. Even if for no reason that there's been enough of it written that somebody wrote beautiful Java just by sheer luck.
- beagle3 16y agoI'm sure there is. I want links I can review, because Java sucks the joy of programming out of me.
- gruseom 16y agoI want links I can review What do you think of this? http://sourceforge.net/projects/timeandmoney/ http://sourceforge.net/projects/timeandmoney/. I haven't used the library, but its author (Eric Evans) is an old Smalltalker who wrote a good book, Domain Driven Design, in which the examples are in Java. The book is immersed in OO but also kind of points the way beyond OO into something more like "how to develop domain languages", which I find more interesting.
- slindstr 16y agoYep, though it was internal to the company I used to work for. The project I was on had probably one of the best teams I will ever be on - everyone (for the most part) followed coding standards and if someone didn't then they were called out on it. It was a pretty mature project, and though the source code we inherited had been thrown together in haste, over time we refactored a good deal of that code. Whenever we had to write new code, we had to propose to our peers what we intended on doing and how we intended on doing it. Keeping senior members of the team in the loop kept the younger guys (like myself) in check when it came to implementations and design pattern usage. On top of that, a handful of the people on my team were RELIGIOUS about writing comments first and then coding to the comments. All in all, it was a great experience for me having been fresh out of undergrad.
- jefflinwood 16y agoI've been developing in Java for a while, and a lot of Java code is ugly because the "patterns" developers use are ugly. That's not to say that you can't write great code in Java, but compare a Java app with JavaBean getter/setters to Spring JDBC Template DAOs to a Rails app with ActiveRecord, and it's no contest. Another source of ugliness is logging - logging libraries that abstract away other logging libraries. It was worse when EJB2 was the standard. Take a look at the Play framework for some modern, non-enterprisey Java. http://www.playframework.org/ http://www.playframework.org/
- deleted 16y ago[deleted]