CD Baby rewrite in Postgres and Ruby, Baby!

by Derek Sivers

Related link: http://www.rubyonrails.org/



I know I've talked about it sporadically for a year now, (see past posts), but I've finally started my CD Baby rewrite.

BIG CHANGE #1 : PostgreSQL

I dabbled with PostgreSQL one night when I wasn't in the mood to do what I was supposed to be doing. I'd heard some people I respect rave about it, and since I really do love databases, I decided it was worth a few hours of my time. Holy Canoli! Its strictness solves most of my data corruption problems I've had with MySQL!

Example problems with CD Baby database in MySQL:

#1 - entries deleted from one table that were required by another.
Example: An album is deleted from our catalog, so now all the lineitems (customer purchases) of that album are left dangling with no matching identifier.

#2 - many invalid entries, especially many dates of "0000-00-00"
This one has gotten us into trouble with our digital distribution partners, whose much-smarter system throw up a big fat error when we stupidly report an album's release date as "0000-00-00"

#3 - no strict requiring of join-ids matching.
Example: someone mistakenly entering that an order belongs to customer #314981 when it should have been #319481, and there is no customer #314981. Database didn't complain so we didn't notice.

Yes of course with these and every other example we all say, "Yeah but your code should have prevented that." Thing is : in MOST places it does, but various little shell scripts and admin scripts can't check for every possible human error, so here I am with a constantly corrupt database.

This is where I *LOVE* the strictness that PostgreSQL makes easy. Yes I hear that MySQL InnoDB tables do the same thing, but I've already fallen in love with PostgreSQL, and switched.


BIG CHANGE #2 : RUBY, BABY!

Like a lost soul walkin' the earth, lookin' for spirituality, that stumbles upon the right church with the right people at the right time, I've found my niche with Ruby. Its little itty-bitty community attracts some brilliant "think different" types with a love for beautiful code that do this for love, not money.

I liked it immediately a year ago when I learned it while stuck in a cabin in Sweden. I stopped after some shell scripts though because its web-making features weren't up to snuff. Now, with Rails, there are a team of passionate geniuses contributing to this web-making framework daily. It's small enough that you can stay on top of it, and watch this framework get more and more powerful by the week. Improvements that are pragmatic not political. People using it to make effective websites, contributing to the shared framework around it as they go. Why not take advantage of all this brilliant work?

It took a lot to get me to switch from PHP, the only language I really know, to Ruby. I tell my non-computer friends, "It's like the week before sitting down to write a book, I decided to write it in Portuguese instead of English, because it'll be easier." It sounds crazy, but we'll see.

Bookmark/subscribe to my author page, here, at http://www.oreillynet.com/pub/au/1841 if you want to watch the almost-daily developments.

Please no flames about Python, PHP, Java, or MySQL. My choice to use Ruby + Postgres was due to my love of them, not hate of something else.


7 Comments

wbk
2005-01-22 20:56:51
you only knew php?
holy shit, no wonder it took you 90k lines of code! ;) this is the kind of crap that happens when web designers get uppity.


i'll definitely be keeping an eye on the daily updates. will you be writing something like "The Design and Implementation of CDBaby" when it's all said and done?

cvincent
2005-01-22 21:03:40
Ruby!
I've been adding languages to my repertoire lately, and I've been dying to find an excuse to learn Ruby. I've heard a lot about it.


I learned Python most recently, and it's been compared to Ruby. It's the most out-there language I've learned, with lots of features that most others don't have. Really cool, if you ask me.


Of course, I've grown very fluent with PHP. In the end, I might just take some of the concepts in the Ruby on Rails API and apply/rewrite them in PHP. Despite limitations and differences, I think I might like that.

gampid
2005-01-24 18:02:58
getting xal & bitsweat
Well, you picked two of the more productive and community focused developers of rails. I'm sure they'll do a great job on the project.
GavinRoy
2005-01-29 14:39:05
Congrats
Congrats on making the switch. Be sure to let us know how Rails works for you :)
johnpipi
2005-08-20 16:12:55
PHP on Trax
Well Ruby on Rails is very cool, but I've been programming PHP for years now and didn't have the time to switch and learn a new language and all our stuff is writen in PHP. So, I wrote a Clone in PHP called PHP on Trax. It has most of the same funcitonality as RoR and I tried to use the same syntax,etc as RoR. :) http://www.phpontrax.com.
RichardLynch
2005-10-20 10:28:21
you only knew php?
Actually, he's a musician that got uppity, not a web designer that got uppity.


Hell, one look at his minimalist, almost dada-ist, site tells you he waren't no web diziner! :-)


PS 90K of code for what his site actually DOES is not that bad a'tal.

eonibm
2005-12-18 14:38:15
You are smarter than you think!
Your choice of PostgreSQL is probably a good one in light of the fact that Oracle just bought (Sep 2005) Innobase OY, developers of the Innodb transaction engine that implements MySQL 5.0 advanced database features. The license that MySQL has for Innodb expires in 2006 and even though Oracle has announced that it wants a continuing relationship with MySQL I can't help but think that Oracle will stick to it's habit of putting the screws to anyone that stands in their way.