Wednesday, June 11, 2008

My Java "Aha" moments - Article that I posted on Javalobby

The flood of technology choices in the Java world is overwhelming. I have an analogy that always comes to my mind for the developers who are faced with this flood of information - a python trying to gorge an elephant!!

Technologies like J2EE, JBI/SCA are massive and have a very steep learning curve. I attempted getting through the J2EE specification once and promptly lost my appetite for J2EE. I ended up using the simpler parts for the projects that I have worked on – the web application frameworks, the design blueprints etc and basically became proficient on the job.

There are technologies that have come up in the Java world that have helped manage the bloat considerably and have provided an aha moment for me - when something just clicks in the mind and has simplified the development process considerably for me. Here are my top 5:

1. Spring Framework:

Understanding the principles behind Dependency injection and its implementation in Spring Framework has been a great aha moment for me. Spring has helped me break out of the J2EE hell and has massively simplified the fundamental way in which I have considered projects by forcing some simple conventions like programming to interfaces, business logic as POJO’s.

2. Appfuse:

I have attempted developing web applications from scratch and have found it difficult to put a good structure in place with all the different myriad Java libraries integrated and working smoothly. Putting a modular structure from scratch also has been extremely.

And then came Matt Raible’s Appfuse and its successor Appfuse 2. Appfuse has been a Godsend. It made the initial ramp up time very smooth by providing a canned structure or a template based on good design and blueprints that any project can start from and move forward.

3. JRuby and JRuby on Rails:

When Rails first came out it was an aha moment for me. I loved the Ruby language before rails was released – I was a smalltalk developer and Ruby as a language was the closest that I had seen to Smalltalk. Rails for the first time enabled me to quickly get up and running with developing a web application, no messing around with a mountain of libraries, everything just worked beautifully. I quickly picked it up, learned enough to create some small applications for myself. I was very pleased to see that the excellent JRuby contributors finally got the Rails framework working on JRuby and promptly now use it for all my internal work.

4. OSGi, Equinox, Apache Felix :

OSGi promises modularization for Java – components can be developed as independent modules, and then put together in the OSGi runtime – like Equinox or Apache Felix, which takes care of hosting the component, resolving dependencies, versioning of the components etc.

OSGi was initially a bit of a difficult concept to get my head around, but then once I had tried a few examples, it quickly became an aha moment and see great promise for it in the Java world.

5. Google Web Toolkit:

Google Web Toolkit is amazing; it lets developers create, develop and test the UI with a Java Swing like constructs, and then internally does magic to convert the Java code to cross browser compatible Javascript for web application deployment. Getting a UI working with GWT was indeed an aha moment for me.

In conclusion, the developers in the Java and the broader software technology world are extremely innovative and I am indebted to these simpler technologies that finally present simpler meal options to the python in my analogy.

Sunday, February 10, 2008

JRuby on Rails - First project

I have been wanting to explore jruby on rails for sometime, I finally managed to scramble together a small working project and like what I am seeing.

So this is what I did on my Windows box:

1. Install JRuby. I have installed the latest RC available at this time - 1.1RC1

2. Set the Environment variables -
PATH - to the bin directory of JRUBY_HOME

3. Install Rails:
jruby -S gem install rails --include-dependencies --no-ri --no-rdoc

4. Install jdbc adapter:
jruby -S gem install activerecord-jdbc-adapter

5. Install Derby adapters:
jruby -S gem install activerecord-jdbcderby-adapter

6. Install Mongrel - To use Mongrel as the webserver instead of the default, download and,
jruby -S gem install gem_plugin --no-ri --no-rdoc
jruby -S gem install cgi_multipart_eof_fix --no-ri --no-rdoc
jruby -S gem install mongrel-1.0.1-jruby --no-ri --no-rdoc

Now start up on the rails project - my project is to simply record my vehicle mileage:
7. jruby -S rails mileage

8. Modify config/database.yml to use derby:
adapter: jdbcderby
database: db/development
timeout: 5000

9. That's it, the rest of the steps are same as for rails. Once the application is ready, it can be run with the following command:
jruby script/server