4.23.2010

How I got into Ruby (You've got red on you)

At the inception of our project, my colleague and I had the opportunity to choose the technology stack. Since we were both Java peeps it seemed natural to start designing the app, a REST based service, using the new Spring 3.0 MVC stuff. We even started to watch some videos on Spring Roo to get it off the ground. The reality of our situation though is that we were developing one of many systems to the client. The other system is being developed in Ruby and the majority of developers at the client are also Ruby developers. Based on this, we decided that sticking with Ruby would be a better fit for the client.

There were two factors easing the discomfort of taking on a new technology to deliver a system on schedule. The first is the relatively simple nature of the application.  It's a REST service that does some simple checkout process with moderate performance requirements.  Nothing brutal. The other is having an extremely talented Rubiest on my team. Toby's been more than happy to help convert a Maven loving Java dude like me over to the crimson side. I knew with him around this was my best chance to build my first non-trivial Ruby system.

So far it's been a fun ride and after a few weeks it feels like I'm finally starting to breathe some air.  The syntax and conventions are starting to become familiar and the ability to navigate stack traces and documentation is improving.  Another great ancillary effect is that the functional and dynamic aspects of Ruby have been connecting some of the disjointed dots which surfaced during my brief studies in Clojure.

I do however miss terribly the luxuries that stricter syntax and strong typing enable, especially for tool support. Please refrain from the real coders don't need an IDE spiel. I miss strong refactoring support, especially because my newbie Ruby needs a lot of it.  Static analysis and code completion are also wonderful for learning new syntax and API's. Knowing which methods are available to call on a variable is nice. Being able to click through to the source code of that method or see the doc in a tool tip on hover is very nice.

But I'm always happy to learn even if it means re-learning how to learn.

I will be blogging some of the things I banged my head against in order to help others new to Ruby, allow current Rubiests to laugh at my newbieness now, and most importantly allow me to laugh at myself later! Stay tuned. 

4.21.2010

Chicago Clojure Meetup

There's no doubt that I loves me some Clojure. Just listening to guys talk about though it honestly makes me feel like I never took a college comp sci course and I love it for that. Who would have known LISP would ultimately rule the world! Lispers, I guess.

When Michael Norton asked if I'd like to help out with the Chicago Clojure group I was quick to hop on board. Now, I'm no Phil Hagelberg, but few are? All I know is that playing around in FP land was a wonderful and eye opening experience after being nose to the grind in Java's OO for many years. I can't wait to get these rolling on a regular basis.

So sign up for for the group and bring your self down on May 19th. We are taking recommendation on topics so please suggest something or vote for what you want to hear about.

Plus, there will be pizza!

(I in no way guarntee the availability of pizza at the Chicago Clojure meetings). 

Time to dust this thing off.

So where have I been?

New job. New marital status. New layer of skin (after Jamaican Sun peeled off the first layer). Most exciting to you (my 2 followers (and Minella's RSS feed)). New languages! New technologies! All that jazz.

Since joining Thoughtworks (yay), I've been using a lot of Ruby. I've tried to do Ruby several times in the past but never had the opportunity to do anything non-trivial. The last time I tried to use Ruby was with Gunnar Morling's Sriptable DBUnit DataSet for the Maven/Cargo/Tomcat/H2/Selenium automated web test stack that I never blogged about.

So what I will be talking about in the near future is my experiences of turning to the world of Ruby, which has so far involved the battery of RSpec, Rack, Sinatra, Rake (yes Rake), Passenger, Bundler, Shotgun as well as MongoMapper since we are using MongoDB as our datastore. We needed to make use of geospatial indexing and  MongoDB did one hell of a job against PostGIS for our use case. Although I do love SQL and relational as well as multidimensional data modeling , my first No-SQL experience has been undeniably great.

Hopefully I'll find some time to pretty this generic template up as well. Stay tuned!

1.25.2010

Top 10 reasons why Maven sucks...not!

I'm having a hard time understanding all the Maven bashing that takes place these days. Maven has been a real joy for me. It could be the simple fact that I can move from colleague to colleague's project without wondering what ant tasks are available or where the files are. It could be the fact I don't have to configure IDE's anymore, not even for downloading sources. It could be some of my favorite plug-ins. Maybe it's the 250,739 artifacts that are available in three lines of copy paste declaration. There's a lot to love.

I'll admit, it didn't make sense at first. It felt a little too large and I was leery of the potentially restrictive guidelines.  I was also very nervous to commit to the predefined life cycles and directory layout. Within a short period of time I learned a minimal pom provided more function than a minimal ant script and the conventions are actually what enable you to easily add more to the build. After an objective comparison to previous projects I've worked on I determined that while less flexible, Maven's life cycle is both adequate and consistent. Over a few years of use, adequate and consistent has proven to be far more valuable than unique or powerful. This is the build, not the software we're building.  There's plenty of business logic to make our systems complex.  The statement that alternative build tools are more powerful is also debatable.

Let me be clear, I'm not recommending we all use Maven or stop working on alternative tools. I am, however, asking that people give Maven a break. A lot of Maven criticism borders on ludicrous. We're all open source advocates (right?). If you dislike it, you know what to do. If you have a specific need, write a mojo (and share it, or don't). If you're going to speak out, offer constructive criticism. In the very least, try not to make your anti Maven rant based on a string of fallacies. I'm trying not to pick on any specific alternatives or individual, but let's walk though this one item by item:

10. maven corrupts – software, people.
Maven exposes circular dependencies and actually uses the checksums it generates. The software aspect isn't true. Maybe I'm a little corrupted, but I'd consider it more like being spoiled. There's also the expression that power corrupts and with a side note about absolute power. The availability for corruption seems to resonate more strongly with the thought of an entire programming language at your disposal. It's all up to how the power is used.
9. maven uses an archetype(appfuse) and expects that all your projects look like the apache projects – even those that are not webservers.
I'm not really sure what this means. I think Maven expects that your projects look like Maven projects. That's what the convention means. When I looked at appfuse projects, they looked like Maven projects to me but maybe it's a chicken and egg thing, which much like the riddle itself, doesn't have much incentive to solve.
8. maven has only four build stages – compile, test, install, package – if you have a requirement to automate performance testing you are out of luck
There are quite a bit of hooks in the build lifecycle. It was added later, but I believe you want integration test (with pre and post integration hooks). I use a fully automated functional test suite that deploys and fires up selenium. I heard Terracotta was using it to fire up two instances of Tomcat to test fail over scenarios. These aren't performance tests, but I'm sure it's achievable. 
7. maven requires you to have a standard directory structure that is 5 subdirectories deep – regardless of the fact that your project only has 10 java files.
src/main/java . Let's see that's 1,2,3. I think it's a good convention and so do several other alternatives.
6. tasks that are not implemented in maven have to be implemented in ant and need to be integrated with maven – a big nightmare.
The only situation where I've been forced to use Ant was to sign an applet jar to put into a war-file. That unfortunate situation was due to a defect we experienced jar:sign goal. After 10 minutes of trying to get it to work, we found a defect in a jira somewhere. To work around the issue we tossed in the Ant task from the original build script. Since then the maven-jarsigner-plugin has evolved and I'm pretty sure we could remove the ant-run task if we were into fixing what ain't broke.
With that said, it's stupidly simple to use ant-run. You don't even have to go download Ant, nor does the n'th machine that your build will run on have to download it.  Nightmare? I've spent more time setting ANT_HOME and configuring PATH variables.
5. maven encourages you to integrate via binaries – thus making continuous integration difficult
I've used Hudson and Bamboo extensively. Both have excellent facilities specific to Maven. I don't even understand what the alternative to binary integration is. I wish the complaint had a specific scenario for me give a valid counter point. 
4. every time maven builds it connects to the internet (to verify/update dependencies) – building your project without the internet is extremely hard.
Not true.  Maven grabs it once then it never needs the internet except once a day for snapshot, which is for your convenience and can also be disabled. Don't forget offline mode. And you really should take 5 minutes to setup Nexus for a little durability in the event of an internet outage.
Follow up question, how easy is doing anything without the internet? Specifically, how easy is executing code you don't have on your local machine without the internet?
3. maven manages the projects and subprojects implicitly (since there is convention and then there are overrides) – it makes debugging your build impossible.
You can always see the effecive-pom if you need to. It's not very hard to see exactly what overriding is going on.
2. maven manages the project dependencies in its own repository – called the .m2 repository – which is not part of your application folder – thus making it impossible to track and package development environments.
This repository is the local repo. It is not part of your application folder because you probably have more than one project that requires commons-logging.jar.  You can track which files make up your development environment pretty easily. You can also copy them to your development environment or package them for several different environments. Pretty flexible facilities in place for dependency management
1. maven always downloads the whole internet – to keep its dependencies up to date – even though you don’t want to.
Whole internet? At this point I'm trying hard not to reply with sarcasm. I'm not trying to attack the author, just disprove the points. And to address the point, 2.0.9 and up has predefined plug-in versions. They do not update on their own. Anything else it updates because you didn't tell it not to by specifying a version for your plug-ins.

This is the type of FUD you can easily find by doing a Google search for "Maven sucks". Here's why I believe it doesn't suck.

Maven's declarative model allows you to prepare structured data, the primary application of XML, to a system that knows how to do what you want. Very goal oriented. The primary motivation of Ant was to have platform independent scripts for Java which was platform independent. That's why at the time, Ant was hot sauce on fried chicken! The problem for me with scripting language based build systems is that most remain task oriented. Staying disconnected from the tasks required to complete a goal is a great gain in overall usability. Maven stays focused on the latter and offers the flexibility to tweak the tasks when necessary.

In addition to the lack of branch logic and variable declarations, the main gripe on XML is that it  is too verbose. But so is the documentation for an ENTIRE LANGUAGE!!! DSL subsets make it easier but there's still a learning curve, especially if someone gets clever. Learning Maven definitely does not happen immediately, but what you are learning is domain knowledge for the task at hand, build management. Every other build tool I've given the cursory glance to required I learn about its build process in addition to a full language or DSL. XML, for all of its lousiness, is ubiquitous and self describing. Lack of cleverness can be a good thing.

That might all be a moot point since polyglot maven is right around the corner. I'll probably stick to XML because I don't write XML, Eclipse does (so do many text editors, with syntax and error checking to boot). Still I am very interested in the project and using it as my primary excuse to get some Clojure in my life. I do have fearful thoughts regarding what tricks someone will put into their builds using these alternatives, but if it means more people are happy about Maven I'm all for it.


After all, why shouldn't Maven cater to those who crave the additional power. Let's not forget that it was created to help you, not make your life hell. There's an age old expression I learned from Gary Coleman at a young age regarding different strokes and world domination. Some people drive stick and others prefer automatic. I prefer automatic because it allows me to do other things like spam text messages instead of shifting. A manual transmission might just encourage me to speed off the road or get a traffic violation. There's a method to the madness of preventing someone from acting foolish. Think of that traffic law as a metaphor to prevent a rake script gone crazy. I personally feel that when Maven isn't making something easy, it's because it probably shouldn't be done in the first place, not in the build at least. For all other times, there's the gmaven plug-in, but I really really try not to make my colleagues go through the unfortunate pain of learning a new language just to execute my tests or create a custom jar file.  

Is the power of a Turing complete language really necessary to compile, execute tests, package and/or deploy your code?

So to wrap it up, I don't understand the hatred towards Maven. Some people act like it stole their prom date. I'm happy for alternatives like buildr and gradle and realize no matter how great any project is it will eventually be replaced.  I don't discourage people from trying or developing new tools, even though I would love to see those efforts put into Maven instead. Different strokes!  Opinions aside, it is and will forever be a tool that redefined build management and whatever tool replaces can only improve upon the baseline it has established.

But the inaccurate, almost childish Maven ranting has to come to an end! It's downright ungrateful and disrespectful to the people who have worked very hard to provide a free and open source option.  Newer alternatives greatly benefit from the groundwork laid by Maven in the first place including the repository or directory layout conventions. So in the least pay homage