Programming ≈ Fun

Why Lisp Did Not and Never Will Gain Enough Traction

After discovering awesome power of Ruby that was somewhat inspired by Lisp I could not help but wonder if Lisp is truly “Lambda the Ultimate” as they say.

First impressions

Some brilliant and smart people are writing essays about it, for example “Revenge of the Nerds” really got me hyped. It is a language that has or can have any feature any other language has (and then some). It came to my attention that 1(one) man was able to replicate most of the cool stuff from Haskell in 10000 lines of Lisp code. Wow!

Couple of alpha Lispers rolled their own OOP support like it was no biggie. Wow!

Seems like the sky’s the limit.

So what happend? I am not buying that syntax is making a difference. It’s strange on the first look, but since people managed to decipher Hittie language from staring at it for 10 or so years I think we as a human beings are capable of managing some parentheses.

Hitchhiker Guide for Multiselect

I wasted better part of last week on building my own multiselect control in Backbone.js. After some hard crashes I’ve decided to give existing plugins another twirl. Here is my overview:

jQuery UI Multiselect


jQuery UI Multiselect

Pros:

  • Mature
  • Drag & Drop is cool

Cons:

  • Crude search
  • Awkward to select (click works only on +, - signs)
  • Needs to load full data set

Why Should I Test?

Be brave

Photo credit: Wikipedia

It’s a fair question. Imagine you want to solve classical allocation problem where you need to divide sum on parts:

90/3 = [30, 30, 30]

Of course you need to accommodate for the rounding on two decimals:

100/3 = [33.33, 33.33, 33.34]

Few weeks ago I did a similar exercise as a part of coding kata. What I got was a small module under 30 LOC and with less than 5 lines methods. So it was pretty well refactored already with the TDD driving my design. That is certainly big part of writing test (organic design), but I don’t want to write about that in this post.

What to Test?

Testing

Photo credit: stopnlook flickr

Not testing at all is at one side of a spectrum, at the other end is testing everything. Those two are easy picks to rule out since the truth is almost always somewhere in between.

I remember reading about one physicist building his own supercomputer. When asked why he did that he said something like this:

I could have just given 2M dollars to IBM. They have a great team and they would build a great supercomputer. But this way I get more bang for a buck.

This is a major issue. Getting the most bang from your testing buck.

OLAP for the Masses

In the small database that contains about one million records the need for some reporting arose. Since the system will work for at least 5 more years I was reluctant to just “winging it with recapitulation tables and some SQL” approach.

The green pastures of OLAP have lured me long enough. My hopes where high, and my knowledge non existing. This is a tale of a man vs. the elements.

Let It Be

Lately pet peeve of mine is how to make small methods look more elegant. One idea was to use “indentation” for implicit end of small methods. Big problem with this is that this is only a wish. I was forced to just cram the method to one line and curse the destiny. For a while I was torn. I loved cramming small methods and hated the impact on readability it had.

Couple of days ago it came to my attention that you can use define_method to get a job done. If we start with this:

def stupid?
  @pretty ? "NO" : "YES"
end

Why Reddit Is Not Worth It?

This article will sum up my experiences with reddit and why I think it is not worth it to bother with. It all started this summer. Somebody has putted me on a HN and I went front page.

7k visitors was more that my tender brain could comprehend :)
I didn’t know it right away but in hindsight that put a “link-aggregate” bug in my brain. I am a long time occasional reddit reader. I know you are not exactly supposed to put you own stuff up there, but hey it’s not like it is really spamming. There is down vote button on the article so if it’s a dumb one it will get buried in 5 minutes. No harm done. Right?

It’s easy to say ‘don’t put your own stuff’. BUT when you have zero readers (like me) it’s easier said than done.

Ruby Oddities

Over the course of time I’ve noticed three peculiar Ruby behaviours. I am not saying these things are good or bad. They are a bit odd/unexpected, mostly neat and always good to know.

I Would Love to See This in Ruby

I like small methods. Small methods make comments unnecessary and allow me to describe algorithms in a way I will understand in couple of months when bug strikes. They allow me to develop domain and talk about domain in the code. There is just one thing bothering me:

The excessive presence of end keyword.
This is particularly bothersome for small methods.

Refactoring Exercise

I’ve just read an excellent article about refactoring rcat in Rubies in the Rough. If you are not subscribed you should be… I couldn’t resist to take a swing at it and refactor Display class since thats where most of the action is happening. In one line rcat is supposed to behave as Unix cat command for some basic cases.