Monday, May 16, 2011

The ruby and java fightclub

As a person who has one foot firmly in java and another in ruby, I'm often in a situation where I try to have an objective conversation about the advantages and disadvantages between the the two. Unfortunately, both of these camps are not very objective about themselves and each other. Ruby guys seem to think that ruby is all sunshine and lollipops and java is spawn of satan and visa versa.

Find any java developer who knows nothing about ruby (or ruby on rails) and strike up a conversation about the advantages and disadvantages between the two. If they in any way care about programming, you will typically end up with a seriously heated discussion about: Performance, Scalability, Compiler Safety, Support, Maintainability, other stuff.

On the other side of the equation, I'm a bit at a loss because I've never met a ruby developer who didn't previously work as a java (or C) developer. Typically a new convert from java/whatever has all the zeal of a new religious convert and will spend lots of time explaining how "java guys just don't get it" without spending a whole lot of time trying to get those guys to "get it".

What seems to be missing is a set of people who are truly trying to understand the real differences between the languages and understand how and when they are most appropriate. After all, I KNOW that ruby is slower at runtime than java, I've tested and measured it, but for most of my applications it just doesn't matter. I've met very few web client users who care about the difference between a 500ms response and a 550ms response.
Moreover, I KNOW I can get high quality software written, tested, and shipped faster with ruby (and rails).

So my question is, has anyone every really objectively tried to quantify the advantages and disadvantages or is all the noise just camps of ruby and java fanbois who hurl insults at each other?

EDIT - Note, I thought I'd add some of online rhetoric that I've found on the subject (thanks google!)

cms wire from 2006... kinda ruby slanted.
this post gets extra points because it draw a similarity between learning java and learning Klingon.

Tuesday, May 10, 2011

Productivity, billable hours, and expert craftsmen

I read a great article about productivity and I think there is a side issue alluded to that needs to be addressed. A common problem is that the actual direct amount of time to do something is minuscule compared to the prep work necessary to be able to execute rapidly and effectively.

The story I'm reminded is something like this:

A man had a squeak in his floor and no matter what he tried to do he could not get rid of it. He finally called a master carpenter referred to him by a neighbor and explained the problem. The carpenter walked in, paced about the room for a minute, pulled out a hammer, hit the floor with it and the squeak disappeared.

The carpenter handed over the bill and the homeowner was livid: "Are you crazy? You want to charge me $100 for just hitting the floor with a hammer?"

Without missing a beat, the carpenter grabbed the bill, scribbled a few changes and handed it back. The bill now read:
Hitting floor with hammer:                      $2
Knowing where on the floor to hit the hammer:  $98

knowing where to hammer produces a lot of variations of this story but the overall theme is very important. Expert knowledge is a rare and valuable commodity and often falls into the category of "you get what you pay for". The trick is knowing when you need that expert and when a novice is good enough.

On the other side of the equation, experts shouldn't worry about charging high amounts for small amounts of time when appropriate. For example, imagine the carpenter above walked around for 10 hours tearing up the walls and otherwise making a mess and then subsequently fixed the squeak, but gave the owner a bill for $100 @ $10/hr.

Would this make the homeowner be happier?

EDIT - I had forgotten about the picasso version of this.. I'm not sure which I like better.

Monday, May 2, 2011

The difference between Scalability, Performance, Efficiency, and Concurrency explained

I thought I'd give some explanation of the difference between scalability, performance, Efficiency, and concurrency. To make things more accessible (and because I'm watching a cooking show on TV) I'm going to use a baking metaphor to help explain the differences. In our case, the system in question is baking cookies for consumers.

Scalability, is how well something responds to adding more resources. If we can double our capacity by doubling the number of resources, we've got linear scalability. In our baking example, if we add more ingredients, we can scale to a larger number of cookies. To contrast with our other metrics, this doesn't actually increase the performance of creating a single cookie (they still take 10 minutes to bake), and the efficiency is the same (we just have more capacity). We also cannot bake more cookies in a fixed time period, but over a larger time period we can produce more cookies.

Performance is how fast something can get done, usually best expressed for a single cycle of a single product. If our baker acquires a machine that reduces the amount of time to do a batch of cookies from 10 minutes to 5 minutes, we've increased our performance (reduced the cycle time). This technique has the advantage of increasing the efficiency, a single baker and all his supplies can actually bake more cookies in a shorter timeframe this configuration. This does NOT, however, increase the concurrency... a single baker with a single oven, even if it can bake the cookie in 5 minutes, can NOT bake double the number of cookie simultaneously. We should pay attention to the fact that scalability and concurrency are distinctly different, but related measures.

Efficiency is how parsimonious the process is with resources. If our baker only requires 1/2 the resources to bake the same quantity of cookies, this is more efficient. This doesn't mean that the baker can bake more cookies in the same amount of time, nor does it mean they will bake faster (usually it means the opposite), and it also doesn't mean that he can double the number of cookies simultaneously.

Concurrency is how much work can get done simultaneously. Adding a new baker and a new kitchen will double our concurrency. Obviously this doesn't impact the performance of creating a single cookie and it is 1/2 as efficient as a single baker. In addition, because we didn't actually double the ingredients, we cannot scale to create any more cookies overall.

An interesting problem with these qualities is that they often strongly influence each other (both positively and negatively). Many solutions that increase concurrency ALSO increase scalability. Worse yet, many solutions that increase scalability decrease performance and surprising to many, may also decrease concurrency.