To the benefit of my own sanity and happiness, the last few years I have been doing most of my work, both personal and academic, in Ruby. Why? Well, because it's simply beautiful, especially if you use Ruby on Rails on top of it do to web development. I could tell you all the horror stories about developing the simplest of the web systems in Java/Servlets/Hibernate but I won't. You already know them. And if you like sanity too, you have kept yourself away from it.
But all this time away from the Java ecosystem also kept me away from some technologies that have emerged in its community to specifically tackle the "configuration hell" problem Java has always had (since version 5 at least).
Java is the programming language I'm using right now for this PIRE project, as Ruby's support for Rule-systems and the like is inadequate for my tasks. But I need a way to cleanly communicate back to the other Ruby-based modules. So I was happy to find JSR 311, or more commonly JAX-RS, which is a definition for a set of APIs in Java to be able to implement RESTful Web services in a very nice way:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/helloworld")
public class Example {
@GET
@Produces("text/plain")
String getMessage() {
return "Hello World!";
}
}
Well, as nice as Java can be. In this Hello World example, we are using three of the annotations from JAX-RS. @Path("/helloworld") specifies that, if we see that path in the URI, then the underlying implementation should route that HTTP request to the Example class. The @GET annotation specifies that the getMessage() method responds to GET HTTP requests only. Finally, the @Produces("text/plain") annotation specifies that we will return a response with that MIME type back.
I guess I could do the exact same thing with 2 lines of Ruby, but hey, to my surprise, it works! ... (after 2 hours of configuring all the dependencies
)