Monthly Archives: June 2008

I managed to compile ruby-mysql

I’m using MySQL Ver 14.12 Distrib 5.0.21 for Win32 (ia32), mysql-ruby 2.7.6, msys 1.0, gcc 3.4.5.

It took a bit of googling before I stumbled across this link.

This link prompted me to peek at extconf.rb. I quickly realized that the script was unable to recognize my platform. It was expecting windows to be mswin32, whereas my compiler was reporting i386-mingw32. That’s on line 3, which says:
if /mswin32/ =~ RUBY_PLATFORM

I modified it to:
if /i386-mingw32/ =~ RUBY_PLATFORM

I invoked the script using:
ruby extconf.rb –with-mysql-lib=”C:\Program Files\MySQL\MySQL Server 5.0\lib\opt” –with-mysql-include=”C:\Program Files\MySQL\MySQL Server 5.0\include”
make install

All went well, and a mysql database script on my machine worked!

Conversational Ruby

I often use Ruby to open conversations:
* It’s easy to write short, quick Ruby code that works,
* It’s readable enough even for new people,
* It’s easy enough to pick up that new people can take my code and run with it,
* It’s expressive,
* It’s fun to write code in.

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.