Showing posts with label ruby-on-rails. Show all posts
Showing posts with label ruby-on-rails. Show all posts

Saturday, January 8, 2011

Grails, IDEs and productivity

Disclaimer

The following opinion might do you harm, offend you or your colleagues or might seem like a talk of a crazy man. Below way of proceeding with daily job is just one of many, probably as many as there are developers out there.

You have been warned!

It all started a long time ago

A long time ago there was Turbo Pascal. It had (as for those old times) an amazing IDE where you could write and debug code and if you made a typo the IDE would tell you immediately that you made a mistake. It had yet another property: it was blazing fast even on those old PCs.

Microsoft VisualStudio, Delphi and Java IDEs

After some time the era of graphical user interfaces kicked in. Environment for programmers started to grow and grow and grow... Especially those for Java. What they brought to the table was supposedly productivity enhancements. One would code faster by use of wizards, code completion, squiggly lines and other "gooye" goodness...

Everything comes for a price

Since those IDEs at the very beginning were quite simple they started fast. PCs were getting faster and faster every year so even if the startup time was around 20 seconds it'd still not be a problem because the next year it'd be down to 3-4 seconds and life would be good again.
The only problem with that was that the next year's release had even longer startup time and this tendency didn't seem to stop until today.

Rational developer point of view

Imagine a situation where all you need is to change 2 lines of code, run the tests and be done with it. What would it take to do this in an IDE like Eclipse or NetBeans and how would this look like when using a less sophisticated tool like let's say TextMate.

Eclipse

Ok, so let's start Eclipse. It's actually a good thing it starts so long because I can go and make myself a coffee before it's ready to work. Oh! but wait! Starting is not everything! Since those brainiacs that created Eclipse thought that it's actually better to delay loading stuff you don't need at first it is actually not only the startup time but you need to add to this a long long time for every window to pop up the first time. Not to mention that the PC I'm running on is quite a powerful one (2 64 bit cores @ 2.8GHz each, fast HDD, lots of ultra fast RAM) Well, most games (and those were the applications that demanded the most of hardware) work like a charm.
Code completion, the biggest hype of all the features in modern IDEs, seems to work only with dull, very formal languages. There's a reason for that: dynamic languages tend to change the behavior of existing code in runtime so there's no way to properly predict what will happen in this particular place in code.
Take Ruby or Groovy for example. Eclipse is doing a pretty good job in giving you hints on what's available but it still is not powerful enough to support some of the nice features like Mixins for example.

NetBeans 6.9.1

The story with that one is exactly the same as Eclipse but worse. Imagine to wait for over 40 seconds just for the list to appear so that you can choose what you want to call. NIGHTMARE!!!

Visual Web Developer 2010

One nice thing about this IDE is that it is focused on one task, and one task only: building web applications. To that end there's no Windows Forms designer built in to slow down the IDE when I don't need it. There's also this one and only (best of breed my friends) JavaScript editor that recognizes extension patterns in many libraries (like ExtJS or jQuery) and provides intelli-sense for them. Let me tell you: it's a F1 car to work with JS!
Unfortunately many of the other things from Eclipse and NetBeans still apply. Startup time is longer and longer with every version and PCs just don't catch up with it.

The worst nightmare: Delphi

Imagine saying that Eclipse, or even NetBeans, starts in no time by comparison. The Delphi 2009 startup time was around 1.5 minutes!!! I mean come on, guys! What were you thinking when you allowed such a piece of crap to see the light of the day?

TextMate to the rescue

These days it is very common for the actual tooling support to come together with a particular library. Take Ruby on Rails or Grails for example. All you need to do is to install the thing and have an editor with contextual text highlighting so that you can see better what's going on. Hell, you can even code directly in the browser!
I took TextMate as a general-purpose example but the same holds true for most of the other plain text editors. Vi, Vim, Emacs (ok, that one is a hardcore one :)), Gedit, Midnight Commander's editor, Far Manager 2 with Colorer plugin... You name it! And like I mentioned before, the code completion itself once you're productive in a platform will only slow you down.
You might say: and what about debugging? Well, as the good uncle Bob said "you don't! what you should do is to create unit tests to see if it all works as expected". But that's a topic for a completely different post...

Is it really all lost?

Ok, so let's give the IDEs some credit they deserve. I do use them, from time to time, when what I need is to do some refactoring, especially to rename classes in files. The process is just too cumbersome to do it manually. I've seen people do some pretty amazing things with Java code in Eclipse too. I guess at some point it becomes like a second skin for you... I prefer to go "naked" :)

Conclusion

When you go to see a doctor and tell him that when you bang your head against the wall then the head begins to hurt what he'll most probably say is "Don't do it". So if you'll ever find yourself complaining about the speed of your IDE try some alternate approach. You'll be amazed what productivity boost it will bring after just a few days of "getting used to". Remember: chemistry doesn't happen over night :)

Saturday, May 1, 2010

The Great Trio

Hi there,

I wanted to do a comparison of different MVC-based frameworks/application stacks flying around. I was looking lately at Ruby on Rails, Grails and ASP.NET MVC so this comparison is going to tackle those 3 guys.

I've deliberately left out pure Spring MVC, Monorail, all the statefull frameworks and other guys because I personally think they are so much not how like I'd like a framework to look like.

Let's start with Ruby on Rails.

1. Extremely nice, terse and concise language (+)
2. Very large user's group (+)
3. Easy to write CRUD-based applications (+)
4. Very testable (+)
5. Depends on the existence of a database (-, but it can be changed)
6. Tooling support OK (+)
7. Free IDE support is not so great (-)
8. Platform agnostic (when you take into account that you can deploy it virtually everywhere, for example on .NET, Java and pure Ruby interpreter it's mind bothering how far you can go with this guy) (+)

Let's quickly follow up with Grails.

1. The language is for sure better than Java but it still has this Java-feel I personally despise.
2. User's group not so large as in the case of RoR but still large enough (+)
3. Easier than with RoR when it comes to writing CRUD-based applications due to the dynamic scaffolding mechanism (++)
4. Very testable (+)
5. Does not depend on the existence of a database to execute but can use one if you'd like it to (+)
6. Tooling support OK (+)
7. Free IDE support is not so great (-)
8. Easy to deploy on any Java EE container so it runs everywhere (+)

And last but not least - ASP.NET MVC.

1. I love the language (+, yes, it's my personal preference). With the latest addition of "dynamic" keyword (and therefore ease of integration with dynamic languages) it's the most powerful language I've come across so far.
2. User's group is very limited by comparison to the other two. (-)
3. CRUD-based applications are definitely the strongest point of this framework but it's mainly due to the fact that it pushes you in no direction when it comes to database layer. You can choose whatever you want (for me it's a +)
4. Very testable (+)
5. Free IDE support (with tooling) is fantastic! (++)
6. Learning materials are through the roof! (+)
7. Deployable on .NET and Mono but not as broad as with the other two guys (-)

I guess when it comes to my personal preference I'd choose ASP.NET MVC before any of the other tools. However the plugin support in Grails and RoR is really amazing and one can accomplish a lot without writing even one single line of code which is an extreme productivity boost.

Have fun cuz that's all that matters!

Friday, April 30, 2010

Reloading lib/ classes in development

Hi,

I've finally found a solution for reloading classes found in rails' lib folder.


In Environment.rb: Add the path for the lib subdirectory where my module was stored, e.g.

config.load_paths += %W( #{RAILS_ROOT}/lib/item_setup )

In Development.rb: Add the name of my Module to the explicitly_unloadable_constants list, e.g.,

ActiveSupport::Dependencies.explicitly_unloadable_constants = 'NameOfMyModule'

If you have other modules you want to automatically reload, use the << explicitly_unloadable_constants array, e.g.,


ActiveSupport::Dependencies.explicitly_unloadable_constants << 'NameOfAnotherModule'

That's more less it.