Eggshell of idioms

It is hard, but rewarding, to shine light on idioms. This has been my experience.

When I introduce someone to Ruby, I usually show off Ruby’s more flashy aspects, and compare it with the equivalent in Java, C# or C. Ruby’s approach to iteration never fails to evoke a response. I also show how Ruby’s various list-friendly methods can be chained together, with powerful results. People respond well to this demo. And why not. Ruby is cool!

Then I get into classes and methods. The brevity is refreshing, of course. But Ruby doesn’t have interfaces. And much popular object oriented thought today took root in statically typed languages such as C++, C# and Java. So when I’m done showing off Ruby’s classes, my subject takes the next logical step, and asks for Ruby’s take on interfaces.

But interfaces do not have to be in every language that has classes. This is the part where I can get quite verbose. It takes me time to explain dynamic dispatch, and the absence of interfaces. Why a duck can be a bird without implementing IBird, and indeed why IBird doesn’t have to exist.

The idiom here is the way that method dispatch works in well known statically typed languages.

There is an eggshell of static typing idioms that surrounds static typing languages. It includes approaches to inheritance, interfaces, iteration. Understanding Ruby forces the enquirer to question the eggshell of idioms, and break out of it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s