Part of the keyboard clique

Entries categorized as ‘Programming’

I managed to compile ruby-mysql

June 28, 2008 · Leave a Comment

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.http://rubyforge.org/pipermail/instantrails-developers/2006-January/000027.html

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
make install

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

Categories: Programming
Tagged:

Conversational Ruby

June 26, 2008 · Leave a Comment

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.

Categories: Programming
Tagged:

Eggshell of idioms

June 26, 2008 · Leave a Comment

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.

Categories: Programming
Tagged:

Emacs and Lisp

May 16, 2008 · Leave a Comment

I enjoyed reading this report on Lisp | Emacs: Advanced Codemunging: A Report from the Trenches

Categories: Programming
Tagged: ,

The ideal requirement to code ratio

March 22, 2007 · Leave a Comment

Requirement:code as 1:1

As a software developer, I have often fallen into the trap of trying to design a “powerful” framework that satisfies all my wants. I would often end up trying to solve food, clothing and shelter, when what I really needed was a simple templating system.

But in any software project, the requirement to code ratio must be 1:1, only as much code to satisfy the requirement as absolutely necessary.

With this sudden clarity has come resolution. Frameworkitis no more.

Categories: Programming