Archive for September, 2007

Mnesia performance basics

Wednesday, September 26th, 2007

I thought I’d continue the whirlwind guide to Mnesia that I began in Getting started with Mnesia. I have no idea how many of the thousands of readers actually found the last part useful. At least one, judging by the comments, but more to the point it’s rather handy for me to write this stuff down as I’m flitting between various new (to me) things at the moment.

(more…)

Amazon - Just sell me the music

Tuesday, September 25th, 2007

Another “DRM-free” music seller arrives, and another disappointment - this time around it’s Amazon, who today launched the beta of their Amazon MP3 music store.

(more…)

When Erlang goes bad

Monday, September 24th, 2007

I had to post this, mainly for the entertainment value but also as a reminder to myself not to start playing with new stuff after a long hard day of ‘real’ development. I just needed a quick bit of code that starts out with a string of the form “inc=45,56,76,102&exc=10,11,15,98″ and spits out two lists of integers. I somehow ended up with this:

% On entry, A#arg.querydata is a string of the form "inc=n,n,n&exc=n,n,n
QueryArgs=string:tokens(A#arg.querydata,"&"),
QueryArgs2=lists:map(fun(T) -> string:tokens(T,"=") end,QueryArgs),
[[_|IncP]|_]=lists:filter(fun(T) -> [N|_Rest]=T,"inc"==N end,QueryArgs2),
[[_|ExcP]|_]=lists:filter(fun(T) -> [N|_Rest]=T,"exc"==N end,QueryArgs2),
IncS=string:tokens(lists:nth(1,IncP),","),
ExcS=string:tokens(lists:nth(1,ExcP),","),
Includes=lists:map(fun(T)->list_to_integer(T) end,IncS),
Excludes=lists:map(fun(T)->list_to_integer(T) end,ExcS).
% On exit, Includes=[n1,n2,...] and Excludes=[n1,n2,...]

Just as shocking as the code are the facts that a) it took me half an hour to make it work, and b) it actually works at all. Worse still, I don’t even need the code, since ultimately it will all be handled via JSON-RPC and not some nasty ad-hoc HTTP query processing - I just wanted to do a quick test in the meantime. The mission was accomplished, but surely there’s a far more elegant way to do the above. Unfortunately, I’m not going to find it today. I will be compelled to come back to it of course, and when I do I hope I can keep the lovely [[_|IncP]|_] part.

A plague of vermin

Sunday, September 23rd, 2007

We must have done something bad because someone or something has decided to unleash a plague of vermin on our garden.

(more…)

Assume Nothing - Control IDs in .NET

Saturday, September 22nd, 2007

This week I got caught out by a strange bit of .NET behaviour. Some background - controls in a dialog in Windows apps each have an ID by which they identify themselves to the parent dialog. This is used in notification messages, so for example when the selection changes in a ListBox, a message is sent to the parent saying so, with part of that message being the ID. The ID is generally assigned at design time, and thus is invariant, unlike the window handle. In my particular ListBox example, the message is:

(more…)

Parallel List Operations in Erlang

Thursday, September 20th, 2007

One of the first things that struck me when I was first browsing through the documentation for the Erlang lists module was the lack of support for parallelism. Functions such as lists:map are clearly prime candidates for this, although obviously you might sometimes require a serial implementation.

(more…)

Getting started with Mnesia

Wednesday, September 19th, 2007

Though Mnesia, Erlang’s “built-in” database, has a lot going for it, one area that definitely doesn’t stand out is the documentation so here is the whirlwind tour I could have used when getting started. I won’t dwell on any particular subject, so consider this a starting point for further research - the documentation is actually ok once you know what it is you’re looking for!

(more…)

Tagging - various approaches in CouchDB

Sunday, September 16th, 2007

I finished my last post by raising the issue that there are many ways to approach structuring data in CouchDB. The same applies to the standard RDBMS of course, but in that case the wrongs and rights are clearer even if that’s only because we’ve seen it all before.

On a related note, I get the impression a lot of people are jumping into CouchDB because they don’t like or can’t get their head around the RDBMS. That’s not a great surprise, since in many cases (mostly web apps) the RDBMS is being both misused, and in an application it’s not best suited for in the first place. My advice is this - if you “hate SQL” or “can’t get your head around it”, go back and figure it out, because there’s no doubt that the RDBMS is one of the finest and most well developed tools we have in software today. If you don’t see that, you probably aren’t best placed to make the decision about what kind of database is appropriate to your application, and worse still I predict you’ll end up having the exactly same kind of relationship with CouchDB.

(more…)

CouchDB vs Mnesia vs MySQL

Friday, September 14th, 2007

I’m still playing around with Mnesia and CouchDB as discussed in the previous posts, but one of the purposes of the test project I’m doing at the moment is to be able to compare various approaches. There doesn’t seem much point playing with new and exciting things without making a comparison with more tried and tested ways, which is my justification for importing this data a third time.

(more…)

A CouchDB GUI front end

Wednesday, September 12th, 2007

I decided to hack together a quick GUI front end for CouchDB to help with my tinkering around. Most people will probably groan and stop reading now, because I implemented it in C#/.NET. Although I’m not going to apologise for that, I do feel the need to justify it:

(more…)