Having been exposed to OCaml, I'm starting to think that if you have null references, you don't really have static typing. I guess I'll have to look at guava, but it can only help so much in interacting with other code.
And especially not if you have type erasure. Java makes you type class names, and the compiler makes you cast things, as for it being a statically typed language, I'm not really sure. As with most things java it's a lot of typing for not a lot of accomplishing anything useful, but somewhat better than C. OCaml/F#/Scala have far better type systems that check a lot more things, and require less typing.
Why and how I write Java
31–40 of 67 posts
Re: Why and how I write Java
#32Do you use a framework for routing and handling HTTP requests, or just servlets? What about accessing the database, if any? I assume you're not using Java EE. EDIT: For iOS, http://j2objc.org/ can help you share code between platforms, but you'll still do the UI and other platform-specific things in ObjC.
Thanks for the j2objc tip! I will definitely be looking into that. I thought Thrift was as far as I could reach into iOS without Objective-C.
I haven't used J2EE. My experience with Django years ago made me framework adverse. I will be posting a sample app in a month or two that shows what I mean.
Re: Why and how I write Java
#33> With Java I have one language that can target servers, Android, and browsers via Google Web Toolkit (GWT). Credibility shot. He's a fan of GWT. That explains a lot.
GWT may not be fashionable, but the compiler and other development tools are very advanced, and big Google products use it. So I'd think twice about bashing it.
I'm not sure where you got the idea that the compiler was advanced - what it does is amazing but incredibly slow.
The development tools were fine in 2008 but they're showing their age now... the browser plugin only runs in Chrome, Firefox and IE, and it's only fast enough to be productive in Firefox. There are no browser plugins for Safari or mobile and doing a compile to a WAR can take minutes on a big project, which means development for mobile can be glacial.
I've just worked for a year on a big GWT project... it seemed like a good idea to start with but I've grown to hate it over time.
Re: Why and how I write Java
#34Only my grandpa writes in Java anymore.
I hired a junior developer a couple months ago who absolutely refused to write code in Java, swayed by the vitriol that is often spewed by highly opinionated developers against Java. Instead of taking the time to learn the language, he read up on all the Java Versus Everything Else rants out there and emailed me links to them, trying to convince me that his arrival meant our code base should be rewritten in a "more modern language". Needless to say that he didn't last very long.
The fact remains that Java is an incredibly mature language that runs much faster than most other solutions, and makes it significantly easier to handle the complexity of a large project. There is an enormous ecosystem of libraries for Java, and it would be foolish to move to a less mature language which needs more wheel reinvention.
Garbage collection is bad.
There are the obvious downsides to garbage collection, e.g. Android apps running on low-memory devices, but for an enterprise application running on a server you shouldn't be breaking balls about garbage collection. Obviously it would run 10 - 30% faster in C, but we live in a day and age where it is cheaper to provision extra servers than it is to pay people for the extra man-hours they spend gdb-ing for segfaults and valgrind-ing for memory leaks. It is much easier to pick up a good Java developer than a good C developer, because the good C developers have already been picked up by the big companies that actually need the performance advantage. And from my experience working in a company on an enormous C code base, I know firsthand how easy it is to pick up a really shitty C developer.
It seems like most of my Java code is just checking for errors.
Would you rather not check for errors? What I mean is, would you rather allow a single developer's "return null" statement that was absentmindedly used to handle a rare edge case to completely fuck your application when that edge case is actually reached? Pardon my French, but I'd rather take the time to throw/catch exceptions than get fucked by a gung-ho developer's null, since Java will force exceptions to be caught and handled at some level. With a well-architected solution, error handling can be centralized and developers can more easily contribute to the codebase if the throw-catch paradigm is part of the coding standard.
Java's GUI capabilities really suck.
This one can't really be refuted - Java's Swing UI components are indeed quite shitty. But you can work around them by creating your own Swing components, and enjoy the benefits of a cross-platform solution.
I know this rant was long, but a lot of it was taken from emails that I've sent to my devs in our Java vs. no-Java threads. I'm no Java fanboy, but I am better than most at seeing past the haterade to where it works and where it doesn't work. Maybe I'm wrong, but my experience is a bit more practical than just reading an article that nitpicks at Java's perceived downfalls.
Re: Why and how I write Java
#35For me, this was the most amazing thing about this post: "Programming with explicit memory management: This bucket includes C, C++, Rust, D, etc. I haven’t needed to explicitly manage memory, so I haven’t used these." I guess I'm just old.
I suppose I could say, "I haven't used any JVM languages, because I haven't felt the need to gouge my eyes out over memory errors I can't control."
Re: Why and how I write Java
#36Re: Why and how I write Java
#37A little surprised Spring is not mentioned. Composition in Java is a nightmare without Spring, and you can do some really interesting things in configuration that would take you days of writing initialization code in very little time. If not for Spring, I'm not sure I would want to construct things in Java at all.
He does mention Dependency Injection briefly. Anyway Spring is just one option (e.g. Guice is another one).
Re: Why and how I write Java
#38Define "application". There are plenty of cases where Python or Ruby makes sense.
And Java actually makes sense as a learning language aswell, as it has more OO depth which is what most courses focus on largely, without the pain of trying to teach students C++.
Re: Why and how I write Java
#39Not sure if the author of this post is on or not but what did you mean when you say you use java for scripting?
I took this out because it was unclear. I meant scripting in the sense that Python and Ruby are called "scripting languages". One possible policy is to use Java for your application, and something like Python to write scripts for stuff like devops or whatever else "scripting" is. Instead of this, I prefer use one language as much as possible, currently Java.
Re: Why and how I write Java
#40I think one thing that this post touches on is the effectiveness of Java as a programming language for large projects. Although personally I've moved on to Python since it greatly simplifies web-related tasks, a lot of our legacy projects are in Java and I still hear plenty of people sipping the Java haterade. So I thought I'd share some of the most common things I hear. Only my grandpa writes in Java anymore. I hire…