4 ms·
It's perfectly fine to use Java for this kind of software. The hate against Java comes from using Java for application development: this is largely due to the
by strlen 14y ago
It's perfectly fine to use Java for this kind of software.
The hate against Java comes from using Java for application development: this is largely due to the kinds of applications that are typically written in Java (line of business software) and (this is the most important reason) accidental complexity and low quality of APIs like Spring or J2EE.
Recipe for programming happyness is to use the right tool for the job:
* Python (or Ruby) for web application development, development tools, and "devops" scripting.
* C (or C++) for pieces that need deterministic performance[1], provide a "native" feeling user interface, or require control over memory layout.
Note: performance and efficiency are relative to what your throughput and latency requirements are. Google's crawlers and indexers will remain in C++ for the foreseeable future, but (for example) crawlers for an intranet can get away with being in Java (or Python for that matter).
* Java (or Scala, Haskell, OCaml, Go, Erlang, or one of the many Lisps) for "userland" systems programming. If the majority of the system fits under the last bullet point, use C++.
* Avoid JNI or Swig if you can. Use JSON + REST for cross-language RPC. If you need performance guarantees of a tight binary protocol use Thrift or Protocol Buffers. If you have to use JNI, consider using JNA first.
* No matter what language you use, stick to high quality libraries and tools. For Java, you'll absolutely want to use guava, Guice, and either Netty (or NIO.2 if you are using Java 7) or Jetty + Jersey + Jackson (for REST APIs).
Pick up either emacs and cscope, netbeans, Eclipse, or IntelliJ for navigating a large Java codebase.
All Java build tools suck. Maven sucks less and is the de-facto standard in the open source community. Twitter's "pants" is also worth looking at.
* Don't touch Spring with a 60-foot pole: in the mildest terms it's unequivocal and absolute garbage. Ditto for any other buzzword you may see in a job listing for an "enterprise" Java development job (with 20 years of experience required, naturally).
[1] Java performance can be quite high, but a JIT-ted and garbage collected runtime implies a lack of determinism.
- fingerprinter 14y agoI wish HN had the ability to pin posts. This is great. Absolutely what I was going to write, so naturally I think it is brilliant ;) The right tool for the job. Java has it's place and it just where strlen said it should be.
- bkyan 14y agoWhat does "userland" mean?
- DVassallo 14y agoCan you give us some evidence why Spring is "unequivocal and absolute garbage"?
- mbreese 14y agoI haven't used it for a few years, but I always found it funny that a project that was supposed to make Java application development easier and more agile than J2EE ended up being just as large, if not larger. Core Spring did a lot for dependency injection, which was a big shift in thought. However, for dependency management, I'd go with something like Guice today.
- exelib 14y agoSpring was innovative in 2008. Now, Spring is overbloat, buggy (look at request-mapper) and have old, sensless integration to others modules, see spring-data for NoSQL, or try integrate last version of Velocity with last version of Spring. And additionaly, all, what you can do with Spring, you can do with JEE.
- strlen 14y agoYes, I was careful to say "J2EE" and not "JEE". WebBeans/CDI in Java EE 6 are quite decent. JSR 330 seems as if they just standardized on Guice. JSR 318 is quite good as well: I highly recommend using Jersey if you're building a REST API.
- edwinnathaniel 14y agoI think collectively we should point out the specific Spring modules as opposed to say that "Spring is overbloat and buggy". Some of Spring modules seem to be quite stable enough. Others, the newer modules, will take time to be more mature. Spring's goal have always been to be the 'glue layer' of the Java standards. Of course, now they want to be the 'glue layer' of everything, including Spring-Data for NoSQL (Neo4J and co.). Speaking of which, your last statement is partly correct if only Spring == Spring Core. There's no MVC (in the sense of ASP.NET MVC or Rails MVC) in JEE yet (yet because things might change in the future). JEE has 2-3 technology covering the "VC" options: JSP, Servlet, and JSF. None of these are similar to that of ASP.NET MVC or Rails MVC.
- zht 14y agoSpring is not garbage.
- yifanlu 14y agoWhy is it not garbage?
- esschul 14y agoRigth tool for the right job is key here. I personally like to add Groovy to the devops list.
- exelib 14y agoI think groovy is sensless language. You lost all Java benefits like checked exceptions, robust code... what is about debugging? And you is not faster developing with groovy. You developing faster if you ensure quality and not inline filters or other crap. If you like groovy, look at Python.
- d4m0 14y agoYou're wrong there. I use Java for most things but dive into Groovy when I want features like almost native XML handling (via XmlSlurper & MarkupBuilder). Having a joint Java + Groovy project is simple as it's all just bytecode to the IDE.
- esschul 14y agoI've used it _alot_ especially for scripting. Really powerful support for quickly write dynamic code to run transformations, connect to db's, connect to mq's etc. It's easier to read than python (for me) and you can just drop a lib in groovy_home for support to whatever dbdriver (like oracle). Seriously give it a go, before you call it senseless. But you know, use what you know and what you can be effective with to solve a given problem.
- prpatel 14y agoYou ensure quality by writing automated tests, not by the language you pick to write software in. And for the record Groovy is awesome. I used to develop in it alot, but now do more Rails and JavaScript, and I miss it's power and simplicity.
- slurgfest 14y agoThis post reflects the conventional wisdom very accurately. It is informative and contains good advice. However, I also think it is a biased caricature based on "common sense" that isn't all that well founded. Most of these languages are entirely usable in areas far outside the prescribed areas you have given for them. If you are working on a few domains like embedded or OS stuff, low-level graphics or signal processing - or you need to interact with a specific system that is pretty language-specific like Rails or iOS - then your options narrow a lot. A few tasks are just a little forced unless your level of comfort is very high (doing 1-minute shell script jobs in C++, for example). But it would be very hard to overstate the degree of overlap, in 2012. It no longer usually makes sense to write things in ASM for speed, for example... In the rare situations where your favorite higher-level language is somehow not good enough for a given project, it is rare that you cannot make a mongrel project which drops to another level just where necessary. If your language does not support this then it is broken in a generally important way. If you are not really ready or willing to fill in gaps and just want to glue existing things together, that changes things slightly - then your primary consideration is not the language but the available libraries. The major differences between languages are mostly matters of custom and ideology rather than niche suitability.
- amirmansour 14y agoYes, but you can use Java (or Scala) where C++ was mentioned.
- norswap 14y agoThe rationale for the distinction is given: deterministic performance.