Posts Tagged ‘Java’

Spring and Jetty Integration

Wednesday, December 10th, 2008

Jetty is a pretty darn awesome J2EE web container. With amazing features like non-blocking IO, continuations and immediate integration with Cometd - I feel that it is a solid, production ready container.

I hate war files, I hate web.xml files - there’s just way too much black magic that needs to be done to get things up and running. It is nice once someone has done the dirty work, and got the initial web.xml constructed, but I wouldn’t want to be that person who starts it all off.

Oh - another thing - I absolutely LOVE dependency injection. Using the web.xml approach, you’ll almost always have to start off a servlet of some sort to initialise various services that you’ll need - moreover the easiest way to access these services on other servlets is to use singletons, and we all know why singletons are bad!

So, I end up using Jetty in an embedded setup, and used to write various wrappers around the configuration so that I can do most of the common things with minimal code. A good example will be to setup a bunch of contexts and a DefaultServlet for regular file serving. However, the way Jetty is written makes it really easy to be used in Spring - everything is a simple bean with a bunch of setters.

To start off, lets write down the bean. Notice I’ve added an init-method attribute to start(). If you don’t want Spring to kick off your server, then just grab hold of the bean and call start() on it explicitly.

<bean name="WebServer" class="org.mortbay.jetty.Server" init-method="start">
</bean>

Then, lets add some connectors to it:

<property name="connectors">
  <list>
  <bean name="LocalSocket" class="org.mortbay.jetty.nio.SelectChannelConnector">
      <property name="host" value="localhost"/>
      <property name="port" value="8080"/>
  </bean>
  </list>
</property>

You will need some handlers (one of them will be a context handler to serve your servlets). I’ve added a logging handler so that the server logs requests in the same format as apache’s combined log.

<property name="handlers">
  <list>
    <bean class="org.mortbay.jetty.servlet.Context">
      <property name="contextPath" value="/"/>
      <property name="sessionHandler">
        <bean class="org.mortbay.jetty.servlet.SessionHandler"/>
      </property>
      <property name="resourceBase" value="/var/www"/>
      <property name="servletHandler">
        <bean class="org.mortbay.jetty.servlet.ServletHandler">
          <property name="servlets"> <!-- servlet definition -->
            <list>
            <!-- default servlet -->
            <bean class="org.mortbay.jetty.servlet.ServletHolder">
              <property name="name" value="DefaultServlet"/>
              <property name="servlet">
                <bean class="org.mortbay.jetty.servlet.DefaultServlet"/>
              </property>
              <property name="initParameters">
                <map>
                  <entry key="resourceBase" value="/var/www"/>
                </map>
              </property>
            </bean>
            </list>
          </property>
          <property name="servletMappings">
            <list><!-- servlet mapping -->
            <bean class="org.mortbay.jetty.servlet.ServletMapping">
              <property name="pathSpecs">
                <list><value>/</value></list>
              </property>
              <property name="servletName" value="DefaultServlet"/>
            </bean>
            </list>
          </property>
        </bean>
      </property>
    </bean>
    <!-- log handler -->
    <bean class="org.mortbay.jetty.handler.RequestLogHandler">
      <property name="requestLog">
        <bean class="org.mortbay.jetty.NCSARequestLog">
          <property name="append" value="true"/>
          <property name="filename" value="/var/log/jetty/request.log.yyyy_mm_dd"/>
          <property name="extended" value="true"/>
          <property name="retainDays" value="999"/>
          <property name="filenameDateFormat" value="yyyy-MM-dd"/>
        </bean>
      </property>
    </bean>
  </list>
</property>

And thats about it. If you need to add more servlets, then all you have to do is add an entry to ServletHandler’s properties for servlets and servletMappings.

Now, image if I had to get a reference to a DAO, or some other service in my servlet - it’s just going to be a matter of adding a member, exposing it via a setter and whacking in the dependency on the servlet Spring config above. All done in nice dependency injected way. No more overriding init() on the servlet and picking up some context attribute via some magic string. The best part of this

Here’s the whole Spring config - hack away to your needs!

<bean name="WebServer" class="org.mortbay.jetty.Server" init-method="start">
<property name="connectors">
  <list>
  <bean name="LocalSocket" class="org.mortbay.jetty.nio.SelectChannelConnector">
    <property name="host" value="localhost"/>
    <property name="port" value="8080"/>
  </bean>
  </list>
</property>
<property name="handlers">
  <list>
    <bean class="org.mortbay.jetty.servlet.Context">
      <property name="contextPath" value="/"/>
      <property name="sessionHandler">
        <bean class="org.mortbay.jetty.servlet.SessionHandler"/>
      </property>
      <property name="resourceBase" value="/var/www"/>
      <property name="servletHandler">
        <bean class="org.mortbay.jetty.servlet.ServletHandler">
          <property name="servlets"> <!-- servlet definition -->
            <list>
            <!-- default servlet -->
            <bean class="org.mortbay.jetty.servlet.ServletHolder">
              <property name="name" value="DefaultServlet"/>
              <property name="servlet">
                <bean class="org.mortbay.jetty.servlet.DefaultServlet"/>
              </property>
              <property name="initParameters">
                <map>
                  <entry key="resourceBase" value="/var/www"/>
                </map>
              </property>
            </bean>
            </list>
          </property>
          <property name="servletMappings">
            <list><!-- servlet mapping -->
            <bean class="org.mortbay.jetty.servlet.ServletMapping">
              <property name="pathSpecs">
                <list><value>/</value></list>
              </property>
              <property name="servletName" value="DefaultServlet"/>
            </bean>
            </list>
          </property>
        </bean>
      </property>
    </bean>
    <!-- log handler -->
    <bean class="org.mortbay.jetty.handler.RequestLogHandler">
      <property name="requestLog">
        <bean class="org.mortbay.jetty.NCSARequestLog">
          <property name="append" value="true"/>
          <property name="filename" value="/var/log/jetty/request.log.yyyy_mm_dd"/>
          <property name="extended" value="true"/>
          <property name="retainDays" value="999"/>
          <property name="filenameDateFormat" value="yyyy-MM-dd"/>
        </bean>
      </property>
    </bean>
  </list>
</property>
</bean>

del.icio.us:Spring and Jetty Integration  digg:Spring and Jetty Integration  spurl:Spring and Jetty Integration  wists:Spring and Jetty Integration  simpy:Spring and Jetty Integration  newsvine:Spring and Jetty Integration  blinklist:Spring and Jetty Integration  furl:Spring and Jetty Integration  reddit:Spring and Jetty Integration  fark:Spring and Jetty Integration  blogmarks:Spring and Jetty Integration  Y!:Spring and Jetty Integration  smarking:Spring and Jetty Integration  magnolia:Spring and Jetty Integration  segnalo:Spring and Jetty Integration  gifttagging:Spring and Jetty Integration

Related Posts:

Converting PEM certificates and private keys to JKS

Wednesday, December 3rd, 2008

If there is one irritating, arcane issue about Java, it is their SSL and Crypto framework. It is a pile of mess. I remember using openssl as a library about 3-4 years ago in a project that was pretty crypto heavy and their library can be used by any junior developer - it’s that simple to use.

However, Java’s crypto framework is just absolutely irritating to use - tons of unnecessary boiler plate, and not enough of self discovery of file formats (as an example). Try to do SSL client certificate authentication from ground up and you’ll know what I mean. Knife, wrist - sound familiar ?

Last night, I had to convert some PEM formatted certificates and private keys to JKS (was getting SSL nicely configured under Jetty). I remember doing this a few years back and there were molehills mountains of issues to jump across and I did pull my hair out back then. Last night was no different. However, I did manage to solve it and ended up with much less hair.

So, to save everyone else the trouble (and their hair!), I’m jotting down some notes here on how to convert a certificate and private key in PEM format into Java’s keystore and truststore in JKS format.

The Keystore

If we’re starting with PEM format, we need to convert the certificate and key to a PKCS12 file. We’ll use openssl for that:

Remember to use a password for the command below, otherwise, the Jetty converter (the following step) will barf in your face!

openssl pkcs12 -export -out cert.pkcs12 \
  -in cert.pem -inkey key.pem

Once that’s done, you need to convert the pkcs12 to a JKS. Here, I will be using a small utility that comes bundled with Jetty called PKCS12Import. You can download the necessary library (you’ll need the main jetty.jar) which can be a huge download for such a small thing, or just grab the jar from here. Run the following command and use the password from the step above and your keystore password:

java -cp /path/to/jetty-6.1.7.jar \
  org.mortbay.jetty.security.PKCS12Import \
  cert.pkcs12 keystore.jks

The Truststore

Next, you’ll almost definitely need to import the certificate into your truststore whenever you need to do anything related to SSL.

First, export the certificate as a DER:

openssl x509 -in cert.pem -out cert.der -outform der

Then import it into the truststore:

keytool -importcert -alias mycert -file cert.der \
  -keystore truststore.jks \
  -storepass password

And that’s it! You have your key in the keystore, and your certificate in the truststore. Hope this helps some of you out there.

del.icio.us:Converting PEM certificates and private keys to JKS  digg:Converting PEM certificates and private keys to JKS  spurl:Converting PEM certificates and private keys to JKS  wists:Converting PEM certificates and private keys to JKS  simpy:Converting PEM certificates and private keys to JKS  newsvine:Converting PEM certificates and private keys to JKS  blinklist:Converting PEM certificates and private keys to JKS  furl:Converting PEM certificates and private keys to JKS  reddit:Converting PEM certificates and private keys to JKS  fark:Converting PEM certificates and private keys to JKS  blogmarks:Converting PEM certificates and private keys to JKS  Y!:Converting PEM certificates and private keys to JKS  smarking:Converting PEM certificates and private keys to JKS  magnolia:Converting PEM certificates and private keys to JKS  segnalo:Converting PEM certificates and private keys to JKS  gifttagging:Converting PEM certificates and private keys to JKS

Related Posts:

Follow up on XP-Dev.com release

Thursday, November 20th, 2008

A quick follow up post on the recent release of XP-Dev.com. There were some bugs that needed to be resolved. Some pretty critical ones, while others were just minor annoyances. However, the dust should have settled now. I’m not saying that there aren’t any bugs left, but most have been fixed. Of course, if you do notice anything odd, please raise a support ticket and we’ll resolve it asap.

I decided to take it easy the past couple of days, as I’ve been working on XP-Dev.com like a maniac for the past 4 weeks. Just to give this some context - I began rewriting the whole of XP-Dev.com from 16th October 2008 and released it on 17th November 2008, which is about a months worth of work. I current site has 13k lines of Java (not including unit tests) and 2k lines of HTML/Velocity templates. There’s about 1k lines of XML, but most of that is just Spring configuration (NOT their web framework - I’m only using Spring for IOC), and I had a day job to take care of. There was plenty of refactoring done during this time, and these numbers are only the final figures. All in all - a crazy month, but well worth it!

It is a complete re-write with a whole new custom MVC framework and object relational mapper (ORM) layer. I’m seriously considering releasing the MVC framwork as open source (the ORM needs some work!), which I think is pretty darn good - writing new dynamic pages and forms is a breeze! Now, I’m sure a lot of you might be wondering why I embarked on such an ambitious journey ? Well, stay tuned as I will be posting a series of blog posts on how I re-engineered and re-architected XP-Dev.com, and the reasons behind those decisions.

The new XP-Dev.com has only been released for 3 days and I did get quite a few mails from users who expressed their gratitude. I can’t begin to thank all of you for those kind emails and support tickets - it is really good to know that there are plenty of you out there who are happy users, and that the past month has been well worth it! I’ve got many more ideas to put into XP-Dev.com, so, think of the recent release as the beginning of something new :)

del.icio.us:Follow up on XP-Dev.com release  digg:Follow up on XP-Dev.com release  spurl:Follow up on XP-Dev.com release  wists:Follow up on XP-Dev.com release  simpy:Follow up on XP-Dev.com release  newsvine:Follow up on XP-Dev.com release  blinklist:Follow up on XP-Dev.com release  furl:Follow up on XP-Dev.com release  reddit:Follow up on XP-Dev.com release  fark:Follow up on XP-Dev.com release  blogmarks:Follow up on XP-Dev.com release  Y!:Follow up on XP-Dev.com release  smarking:Follow up on XP-Dev.com release  magnolia:Follow up on XP-Dev.com release  segnalo:Follow up on XP-Dev.com release  gifttagging:Follow up on XP-Dev.com release

Related Posts:

IntelliJ 8

Sunday, November 2nd, 2008

I have blogged in the past on a very sensitive issue - Eclipse vs IntelliJ. I come from the IntelliJ camp where I strongly feel that IntelliJ really improves developer efficiency tremendously. It might be a little opinionated, but here’s the drill: I have been working at my current job (no, its not a career, but that is content for another blog) for roughly 8 months, and I can only use Eclipse, for a multitude of reasons. So, I might be able to claim that I do use Eclipse and IntelliJ a lot.

Here’s what I found when comparing Eclipse to IntelliJ: Eclipse has way too much clutter. It does not refactor right. It is really slow in auto-completion. It just does not offer the right suggestions during auto-completion. The list goes on. It could be that I’m facing these issues because I’m using Eclipse 3.3. I really should upgrade to Eclipse 3.4 and hopefully some of these might go away.

My IDE has to be really fast, and has to be smart enough to give me the right auto-completion. My IDE has to be able to help me develop real quick. Eclipse falls short - way short. I tend to develop much faster (about 2x productivity) thanks to IntelliJ’s pretty smart auto-completion, and somehow the code comes out cleaner, as I don’t have to worry about the IDE screwing up big refactors. I end up spending less time typing, and more time refactoring.

However, the one thing that I always liked about Eclipse is that it supported various other languages and IntelliJ fell short in the category. Well, not for long - IntelliJ is catching up and now with version 8 - there’s a ton of features added with new language support. This list is just the tip of the iceberg on the new features.

Grab your evaluation copy, and try it out. Tips to using IntelliJ properly:

  • Shortcuts, shortcuts, shortcuts! Learn all the keyboard shortcuts. Use the reference card (Windows + Linux, Mac) and memorise it.
  • Stop touching that mouse! Every single time you move one hand from the keyboard to the mouse you have just wasted a few seconds of good coding time. Break this habit.
  • Learn to type fast, without looking at your keyboard.
  • Get in the habit of refactoring. There maybe once, or twice in my 3 years of using IntelliJ that it failed on my when refactoring, and I use that bloody rename shortcut like it is going out of fasion. The more often you refactor, the cleaner your code will become. It will be more maintainable as well.
  • When you’re editing something that is not exactly code, like XML for instance, don’t use notepad or some old crummy text editor! Chuck it into IntelliJ and you might get a suprise that it does auto-completion for you.

Some useful sites to help you get your head around IntelliJ:

del.icio.us:IntelliJ 8  digg:IntelliJ 8  spurl:IntelliJ 8  wists:IntelliJ 8  simpy:IntelliJ 8  newsvine:IntelliJ 8  blinklist:IntelliJ 8  furl:IntelliJ 8  reddit:IntelliJ 8  fark:IntelliJ 8  blogmarks:IntelliJ 8  Y!:IntelliJ 8  smarking:IntelliJ 8  magnolia:IntelliJ 8  segnalo:IntelliJ 8  gifttagging:IntelliJ 8

Related Posts:

Hibernate, MySQL and Case-Sensitivity

Wednesday, October 29th, 2008

Since going live with XP-Dev.com a few months ago, there has been a nasty little bug that I’ve been trying to chase down where a weird exception is thrown in some obscure situations. When I say “weird”, I mean “I look at the code and keep saying to myself: this exception can’t possibly be thrown here”. Now, the exception is very domain specific and its almost pointless for me to attempt describing it here, as that will take a few posts, rather than just the one.

In a nutshell, a user could login to XP-Dev.com using valid username and password credentials, but then found that he/she could not perform any tasks. It turns out that this only happens if a user logs in using a slightly different case for his/her username. For e.g. When user ‘developer‘ logs in using ‘Developer‘, he’ll basically hit this bug.

The problem is two fold:

First, MySQL stores varchar columns as case insensitive. So, when you run a SQL query like:

select * from Users where username='Developer'

MySQL will return the rows with username ‘developer’.

This is not a problem per-se, as I’ve found this design feature pretty useful when attempting to do web oriented work in the past. The web in general is case insensitive, and system facing the web should reflect that. There is no difference between XP-Dev.com and xp-dev.com.

So, from this perspective, its not really a security bug as well, as you can’t really register the user ‘Developer’ anyway and attemp to ’steal’ the other user.

Here comes the annoying second part of this fiasco.

I use Hibernate as a Object Relationship Mapper/Persistence Layer on the current version of XP-Dev.com. Carrying on with the MySQL example above, pulling out a User object from the Users table using Hibernate can be done as follows:

User user = (User) org.hibernate.Session.get(User.class,
                                             "Developer")

The problem is that the User object returned will have the member ‘username’ set to ‘Developer’, rather than ‘developer’ as it is on the database. The object that Hibernate returns to you does not reflect the database state at all.

Coming back to the bug: Whenever a user logs in, I keep his username in memory attached to his session on the server-side, and refetch a fresh new User object on every HTTP request. The problem was that performing any tasks failed because it relied on strong Foreign Keys on the database tables. For e.g. if user ‘developer’ had 3 repositories, and logs in using ‘Developer’, I will refetch ‘Developer’ using Hibernate and get the username ‘Developer’ back, rather than ‘developer’. The user ‘Developer’ does not have any repositories and the permissions layer that I wrote (which is case sensitive) will throw a nasty exception when user ‘Developer’ tries to access repositories for the user ‘developer’. The permissions layer should be case sensitive as it’s a very critical part of the architecture and should be as restrictive as possible.

It’s nasty the way Hibernate does not return the exactly values back on the data object as it is on the database. The work-around is to use something like below:

org.hibernate.Session.createQuery("from User where username = ?")
                             .setParameter(0, "Developer")
                             .list()

Magically, Hibernate DOES return a User object with username set to ‘developer’. This approach has an extra overhead of creating a list on every call, but I suppose I’ll have to live with that for now.

On the new version of XP-Dev.com, I got rid of Hibernate and Wicket. I’ve had growing pains with Wicket as well, but that’s a rant for another blog post. Hibernate is just too bloated, and I can’t afford the performance overhead.

del.icio.us:Hibernate, MySQL and Case-Sensitivity  digg:Hibernate, MySQL and Case-Sensitivity  spurl:Hibernate, MySQL and Case-Sensitivity  wists:Hibernate, MySQL and Case-Sensitivity  simpy:Hibernate, MySQL and Case-Sensitivity  newsvine:Hibernate, MySQL and Case-Sensitivity  blinklist:Hibernate, MySQL and Case-Sensitivity  furl:Hibernate, MySQL and Case-Sensitivity  reddit:Hibernate, MySQL and Case-Sensitivity  fark:Hibernate, MySQL and Case-Sensitivity  blogmarks:Hibernate, MySQL and Case-Sensitivity  Y!:Hibernate, MySQL and Case-Sensitivity  smarking:Hibernate, MySQL and Case-Sensitivity  magnolia:Hibernate, MySQL and Case-Sensitivity  segnalo:Hibernate, MySQL and Case-Sensitivity  gifttagging:Hibernate, MySQL and Case-Sensitivity

Related Posts:

Java 6 on FreeBSD, anyone?

Thursday, August 28th, 2008

Beastie

Java on FreeBSD has been working for a long time. While most things worked, it was never officially supported, as it was not a complete implementation. Not everything on the JVM worked as expected on FreeBSD. Well, that has changed (I might be late to join the party on this one!) and Java 6 is officially supported now, and the downloads include pre-built binaries.

BTW, they’ve dropped official support for the Java 5 JVM. From their Java project page:

Packages for JDK/JRE 1.5.0 are still available for download although they are not supported any longer.

I stopped using FreeBSD since I started using a multi-core desktop and FreeBSD did not have SMP support . Even that has changed, and they have come a long way from FreeBSD 5. I’ll be keeping a close watch on them. Who knows, maybe the whole of XP-Dev.com might run on FreeBSD in the future ?

del.icio.us:Java 6 on FreeBSD, anyone?  digg:Java 6 on FreeBSD, anyone?  spurl:Java 6 on FreeBSD, anyone?  wists:Java 6 on FreeBSD, anyone?  simpy:Java 6 on FreeBSD, anyone?  newsvine:Java 6 on FreeBSD, anyone?  blinklist:Java 6 on FreeBSD, anyone?  furl:Java 6 on FreeBSD, anyone?  reddit:Java 6 on FreeBSD, anyone?  fark:Java 6 on FreeBSD, anyone?  blogmarks:Java 6 on FreeBSD, anyone?  Y!:Java 6 on FreeBSD, anyone?  smarking:Java 6 on FreeBSD, anyone?  magnolia:Java 6 on FreeBSD, anyone?  segnalo:Java 6 on FreeBSD, anyone?  gifttagging:Java 6 on FreeBSD, anyone?

Related Posts:

IntelliJ IDEA vs Eclipse

Wednesday, May 21st, 2008

With a risk of starting a religious war between these schools, I will be bold enough to say that when it comes to Java development, IntelliJ wins hands down, and I’ll explain my perspective below.

But, before moving on to the gist of it, let me add some context and background to my current situation. Having been a geek at heart, I am always looking for even geekier ways of doing things. For example, rather than just deploying one of the few hundred blogging applications out there, I’ve written my own using Django. It’s not because I have a masochist mind, but because I find it fun, exciting and challenging. Based on that, I can basically summarise my professional (IT and programming) needs as: geeky, fun and exciting. Others, come second (yes, that includes remuneration and benefits). I’ll jump on to anything that is interesting and challenging. With that out of the way, lets continue.

I’ve been building front office trading applications for a good part of 2.5 years now (straight out of college). All of it in Java. No J2EE, just all in good ol’ plain J2SE. In a short span of time, I’ve managed to use so many Java technologies - Hibernate, Jetty, Tomcat, JBoss (we never used it as a J2EE container), Log4j, Slf4j, commons-*, etc. I’ve learnt how to write performant code, to think twice on how a JVM might compile this code, and how JIT might enhance it. I’ve learnt to plan and code very quickly as well. Summing all of these up, I need an excellent tool for programming to ensure that I spend all my time solving the problem at hand, rather than solving the problems of the tool.

I had used Eclipse in college, albeit sparingly. It was OK, and I thought that IBM did do a great job in initiating it. Then I graduated and started at my first job. The team had a standard on using IntelliJ, and for the first time in my life, I started using it. I saw how team members around me were using it and I picked up some shortcuts and tips on how to code quickly by leveraging IntelliJ features. At some point I saw this one guy use IntelliJ and he was literally killing it. Till that point, I have never seen so much code being generated in such a short time, and it was useful code! Not templated rubbish and stuff that you’d add to an API “because someone might need it in the future”. He was really productive. So, I did what I think has changed the way that I code: I copied him (shamelessly)! I observed and learnt what he was doing, and why. How his thoughts flowed while coding and how he tied that in with his tool - IntelliJ. Safe to say - I learnt more about IT and programming in my first 4 months of my job than 4 years in college.

From then on, I did not look back on Eclipse at all for Java. I even bought a personal license for IntelliJ. It was one of the most productive times in my professional career. I took ownership of the team sometime early 2007, and was advocating IntelliJ to everyone in the firm. Everyone got about doing their work, and maybe once in a while had a tiff with IntelliJ, but that’s about it. Best part of all was that it was fun coding with IntelliJ. It does what I’m expecting it to do, and quickly at that. Refactoring is a sheer pleasure as well.

Towards the end of last year, I had a bit of a problem. One of my servers had 2GB of physical RAM, and I needed to chuck in 10-20 JVMs for one of my personal projects, and that just won’t scale well. FYI, a busy running JVM does take quite a lot of heap space. So, I started looking at Python as a light weight alternative. I really like Python as a language, and am advocating its use in building low latency trading apps (tied in with the use of Psyco). The only problem was that there wasn’t an IntelliJ equivalent for Python. All the IDEs just sucked! I wanted to be able to kill an IDE and spew out just as much code as I did when programming Java with IntelliJ.

This was when I started using Eclipse heavily. I settled with PyDev with Extensions and it’s actually not too bad compared to the other Python IDEs out there. Take away all Eclipse’s nuisance, the plugin is pretty polished. It has code completion, some refactoring, satisfactory code browsing and as a whole it was OK. I started to convert most of my Java personal projects to Python, though not at the level of productivity that I had desired. IntelliJ 8 is due to have good Python support (including debugging). If that’s satisfactory, I’m ditching Eclipse for my personal

At this point, I was using IntelliJ at work, though I did not code much for a year. I did build prototypes, but most of my time was spent in managing the team and running the show. I used Eclipse outside work for Python. In effect, I ended up spending most of my coding time in Eclipse.

At the beginning of this year, I moved firms and am back to coding full time. At this new place, the mandate is to use Eclipse. What a shocker it was! My productivity almost halved. What took me 30 minutes to complete in IntelliJ took an hour in Eclipse, due to its clunky refactoring, code browsing, searching and interface. At this point I realised what the problem with Eclipse was: its just trying to satisfy too many people. It’s trying to be the mother of all IDEs and support every bloody language in the world. In my opinion, IntelliJ have perfected this - for a long time, they’ve focused primarily on Java. They’ve done an amazing job, and at the moment, just replicating their success to other languages. Being unhappy with coding Java in Eclipse, I went about in the firm asking why there aren’t many IntelliJ users - the main reason: cost! Apparently, the cost to benefit ratio of IntelliJ was appaling.

I am not entirely sure how they conducted their research, but in my humble opinion, there is almost no way that you can make a statement like that. While IntelliJ costs money, you quickly recover that cost from the individuals higher contribution levels. In the big picture, its an extremely small cost ($599 per enterprise license) compared with the other costs of keeping a developer seated in an office. You have overheads, admin costs and other misc things to worry about, which really makes the one off $599 miniscule. In fact, I think Eclipse actually costs more - the time spent working with the tool, instead of the problem at hand has an internal cost. There is no way in Eclipse to get about doing a big refactor of a few code bases without changing perspectives (most common for me is switching between Java and Team Synchronisation). The lower levels of productivity have more costs associated to it. What about repercussions of delivering late? Reputational risk? I can just carry on and on about the extra costs that comes with Eclipse. Plenty of folks in management who decide on Eclipse over IntelliJ just don’t realise that the $0 on Eclipse is not a true $0. At the same time, the $599 for IntelliJ is not a true $599 - there are additional costs with using IntelliJ as well, but in the big picture in hiring and keeping a developer in office, its amounts to something really small. The benefits from using IntelliJ are pretty evident - it’s so much simpler to use, and developers tend to spend more time on the problems at hand rather than on the IDE itself. How did they carry our the cost-benefit analysis? I can only assume that they took the cost of Eclipse at a flat $0, which really does not reflect reality.

So, here I am. For the past 4 months, during my day job I am using Eclipse for Java and at home using Eclipse for Python, until this morning when I added a tutorial section to XP-Dev.com (which is still in Java using the amazing Wicket framework) and fired up IntelliJ for the first time. I added some code here and there, and only took a few minutes to add the section in and deploy it out. I was so relieved and excited to use IntelliJ, that I just had to rant about it and how Eclipse has been picked as a standard Java IDE in many organisations due to costs.

I am waiting eagerly for Python support to improve in IntelliJ, and then I can start using it again for my personal projects. On the work front - I never give up without a fight. I will carry on advocating IntelliJ for the right reasons, even if it’s all about the costs. I do want to put back the fun in coding at the workplace! I do want to get the firm (or at least my immediate team members) on to higher levels of productivity.

del.icio.us:IntelliJ IDEA vs Eclipse  digg:IntelliJ IDEA vs Eclipse  spurl:IntelliJ IDEA vs Eclipse  wists:IntelliJ IDEA vs Eclipse  simpy:IntelliJ IDEA vs Eclipse  newsvine:IntelliJ IDEA vs Eclipse  blinklist:IntelliJ IDEA vs Eclipse  furl:IntelliJ IDEA vs Eclipse  reddit:IntelliJ IDEA vs Eclipse  fark:IntelliJ IDEA vs Eclipse  blogmarks:IntelliJ IDEA vs Eclipse  Y!:IntelliJ IDEA vs Eclipse  smarking:IntelliJ IDEA vs Eclipse  magnolia:IntelliJ IDEA vs Eclipse  segnalo:IntelliJ IDEA vs Eclipse  gifttagging:IntelliJ IDEA vs Eclipse

Related Posts:

Dynamic vs Strong Typed Languages

Monday, February 18th, 2008

BTW, I’ve had some programming languages re-direction in the past few months.

Hardcore programming for me started a while back doing a project in Java during my college days. What I mean by “hardcore” is not generating a lot of code, but instead taking a step back and evaluating a programming language for what it offers - it’s pros and cons. I really found it difficult to make sense out of Java - there was plenty of boiler plate code that needs to be written to do anything. A good example is having a class with read-only members (very very useful for things like configurations). There is no easy way to ensure that anyone using your class is prohibited from changing the members post generation. The quickest (and it’s not that quick at all) is to make your members private and use getters. Now, imagine a class with a couple of hundred members and nothing but vi/vim as an editor - see what I mean ?

Following that, I began being a big fan of PHP due to it’s dynamic typing. in fact, this was so liberating from strong type languages, I used PHP for every single thing! BTW, PHP does not solve the problem with Java mentioned above. Then I found myself in the situation where I ended up doing a lot of reflection and function of functions, and other highly dynamic structures, which is what one would do with a dynamic language. The problem was that it was very difficult to decide what a variable was holds at any one point, and I ended up going back into writing more boiler plate to check types during runtime (as PHP’s compile time checks are not so strict).

At this point I graduated and had just begun working at an Investment Bank as a full time Java developer. BTW, if anyone is wondering, the level of programming skills that you have when coming out of college is appalling compared to what is needed for building Front Office trading systems. My advice for all those students pursuing a CS/Info Sys degree: learn how to solve problems and think critically. But thats another story.

I started using a lot of Java, and I mean A LOT - to the point where I used to have nightmares about NullPointerExceptions (this is just a joke BTW - I am sad, just not that sad). And guess what ? I started falling in love with Java again. Compared to the time in college where I was complaining about boiler plate, the difference was IntelliJ (an IDE for Java). I found that IntelliJ generated all the boiler plate for you. This was an amazing step forward. Here I was happy with all the strong typing that comes with Java and an amazing tool that did all the boiler plate. For example problem with Java above, IntelliJ solves in a few keystrokes - Alt+Insert, then select “Getters” and pick all the members. Moreover, I discovered reflection and generics in Java, which is extremely powerful in getting type-safety and some essence of a dynamic language (provided you know what you’re doing, as you can shoot yourself in the foot if you don’t!).

So, I was back being an advocate of strong typed languages, but on one condition - have the right tools at your disposal. Lately, I’m back to using dynamic languages. I’ve been having some very good thoughts on Python, and how it’s such a cleaner and refreshing approach to dynamic languages compared to PHP, without the behemoth resource usage of a full virtual machine like Java.

del.icio.us:Dynamic vs Strong Typed Languages  digg:Dynamic vs Strong Typed Languages  spurl:Dynamic vs Strong Typed Languages  wists:Dynamic vs Strong Typed Languages  simpy:Dynamic vs Strong Typed Languages  newsvine:Dynamic vs Strong Typed Languages  blinklist:Dynamic vs Strong Typed Languages  furl:Dynamic vs Strong Typed Languages  reddit:Dynamic vs Strong Typed Languages  fark:Dynamic vs Strong Typed Languages  blogmarks:Dynamic vs Strong Typed Languages  Y!:Dynamic vs Strong Typed Languages  smarking:Dynamic vs Strong Typed Languages  magnolia:Dynamic vs Strong Typed Languages  segnalo:Dynamic vs Strong Typed Languages  gifttagging:Dynamic vs Strong Typed Languages

Related Posts: