Why Spark Will Not Ignite For Me
Posted
Let me first share this great comment someone on Reddit said about creating an open source project:
"if you made an open source project, you're automatically awesome; if your implementation is sound, you're doubly awesome. It doesn't matter if somebody thinks that your idea is flawed - you never know until you try." /via dcapacitor on @proggit
In that respect, I tip my hat to the creator of Spark, a Java Sinatra-inspired microframework but I can't endorse it as a solution.
Let's first look at the Hello World code:
import static spark.Spark.*;
import spark.*;
public class HelloWorld {
public static void main(String[] args) {
get(new Route("/hello") {
@Override
public Object handle(Request request, Response response) {
return "Hello World!";
}
});
}
}
It is definitely more concise than a traditional J2EE app, it is bloated compared to a similar Sinatra or Groovy Ratpack application. Way too much scafolding to get to the actual work at hand. Linked here is a less trivial example. You'll see how as the app grows in size, it begins to go out of control.
One the Why? page for Spark, Spark's creator incorrectly states:
Why not use Sinatra?
If you're an experienced programmer in functional languages you should definitely use Sinatra. However, if you're a Java developer and want to get the benefits you get from Sinatra but you don't want or have the time (money) to learn a new language, Spark is a really good alternative!
Edit: Page was edited to remove references of functional programming.
Firstly, Ruby is not a functional language and that shouldn't matter anyways. The greater problem with the statement is that it is conflating the concept of routing as the only benefit of Sinatra. Yes, routing is a plus but it is also the middleware that helps Sinatra to shine. As you can see with the non-trivial Spark examples, you get routing which is new, but everything else is the same old Java. Currently, it doesn't have a built-in template engine or seemingly any other niceties for static file serving, etc. I'm unsure that someone who would be looking for a solution that is trailblazing against the status quo would be someone that felt that exploring a new language was something they didn't have time for.
Should we always teach seeking knowledge is never a wasteful enterprise?
Related Posts:
Motej with Groovy
Building PlayN applications with Gradle
Serving Images (Favicons) with Ratpack Middleware
Using Markdown with Ratpack
Comments
blog comments powered by Disqus