I've been working in Smallalk and Seaside for quite a while now, but something I haven't quite gotten around to yet is trying to hook Squeak up to a database in a manner that I think could actually scale for a professional project. Now, I mean directly hook it up, so far, professionally, I've been using it against web services written in .Net against Microsoft SQL Server, which scales just fine, but leaves me still working in .Net, and I'd much rather work in pure Smalltalk.

Object Databases

I've tried several object databases, GOODS, Magma, and OmniBase, and while interesting experiences, I find them not quite acceptable for various reasons. OmniBase is file based, and has odd semantics that make hooking it up to multiple images and programming web apps against it difficult.

GOODS is very low level and bare bones, it works great, but you have to pre-index all your data, it has no query capabilities beyond what you provide in your object model, which can make performance quite horrible unless you know exactly what you're doing and make very strict choices about how your data is stored. GOODS is also a one man show, so I'm not thrilled by the support I'd have available, were I trying to do something serious with it, though it works great for hobby and prototype programming.

Magma has queries, and is very similar to GOODS as far as ease of use goes but like GOODS, it's a one man show, and I just wouldn't feel comfortable doing anything truly serious on a one man show kind of database. This, for Squeak at least, seems to rule out object databases, for me anyway, though I hear Gemstone is going to support Seaside. I'm hopeful, for Gemstone is truly an enterprise ready object database, it's just vaporware at this point, nothing production ready.

All of them seem rather slow when it comes to bulk inserts, and there are various solutions and workarounds depending on which version of Squeak you're running, but a guy can only jump through so many hoops before he says "fuck it". I've hit that point more than a few times when working with larger datasets and trying to do bulk inserts or queries.

Now, don't get me wrong, Goods, Magma, and OmniBase are great products, and I'm sure have their uses, they're just not something I'd throw up to my boss and say "hey, let's use this for this big upcoming project", because it's hard enough throwing Squeak at them and having to support that decision over something like .Net which everyone already knows how to use, let alone taking away their familiar relational databases. I'd actually prefer something like Gemstone, time will tell if that preference pans out.

Relational Databases

So, on to relational databases. Squeak has ODBC support, but it's single threaded and blocks the VM when querying, so while it works for demos and low traffic apps against pretty much any database, I wouldn't try anything too big with it; it just can't scale. Blocking the whole VM, every time you run a query, just leaves me feeling a bit dirty and not too proud of whatever I just wrote.

Squeak basically supports two popular relational databases that I know of, natively, MySQL and PostgreSQL. Now, I use MySql for this blog, so I have some experience managing it, and I'm just not a big fan, compared to Microsoft SQL Server, which I work with professionally daily, MySQL just sucks, but PostgreSQL is a different story, I'm quite impressed with the latest release, which looks and runs very nice on Windows servers and has a nice admin tool.

MySQL is IMHO not much better than Microsoft Access, it's not an enterprise database. PostgreSQL, I think is much more comparable to SqlServer and Oracle and could be used for any size app. I have much more faith in its abilities and it has some cool features like table inheritance, which to an object bigot like myself, just makes me think relational databases aren't totally void of innovation.

Now if I can just talk my DBA into giving up Sql Server, ummm... yea, not gonna happen, but I've got a side project coming up that'll be totally green field development, no legacy database to worry about, hence my renewed interest in PostgreSQL, my new database of choice with Squeak.

Getting Started

So I installed the latest PostgreSQL, installed the PostgreSQL Client for Squeak from SqueakMap, then the GLORP port from SqueakMap, and gave it a shot.

I was immediately confronted with a nasty error that reminded me why I gave up last time I tried PostgreSQL. Something about the PostgreSQL driver's state machine not being valid, luckily enough time had passed that a few minutes Googling turned up a simple answer this time, unlike the last.

PostgreSQL installs with MD5 connection encryption turned on, which Squeak doesn't support out of the box. There are two fixes, either install the Cryptography package from SqueakMap, or turn encryption in PostgreSQL to "password" with a simple configuration change to the pg_hba.conf. I chose the latter, as its default install only accepts local connections anyway I'm not too concerned with encryption.

PostgreSQL fires up and runs without a problem, GLORP tests all run fine, so now I just have to learn GLORP and how to map my objects into PostgreSQL, but that, is going to have to be another story. I'm going to map the simple blog in Seaside into a PostgreSQL database to learn GLORP, and I'll post that code once I figure it out. I've done a bit already, and so far, I'm quite happy with GLORP.