Monday, October 20, 2008

The tribulations of Setting up a Goldfish Tank

After spending the last three weeks setting up a goldfish tank I have to endorse the opinion that you should steer away from the generic pet stores. And I mean completely.

Chances are the staff haven't a clue, and management couldn't care less, even if they are cheaper. Before I knew this I went down to the local generic store to buy the basic materials, a tank, a filter etc. I fooled myself into thinking I'd pay less by buying basic glass tank, and compeltly failed to factor in the price of a filter and a light. Even on this score It's hard to tell if I came out ahead or behind.

At every jucture I asked if item x was suitable for a cold freshwater aquarium. Turns out the gravel I brought wasn't, it buffered the water and drove up the Ph, so much so that I couldn't make it budge from a reading of 7.5 no matter how much ph down I put in.

So I spent half a day replacing the gravel, with the stuff I got from an aquarium shop. Unlike the generic pet store these guys will not sell you a fish without testing a water sample first. When I complained about the buffering the first thing the Guy said to me was, you have white gravel don't you? And yes I did.

So I went back to the pet store and asked for a refund on the gravel, No can't do that, Not responsible. The manager says in a I've got your money and I couldn't care less tone. Half way through the conversation after telling me how all his gravel comes from the same place he admits that the ph problems occurs, but stress that its not his responsibility, as its prepackaged. He says the black gravel can be even worse. Still after all this the only thing he offers is to replace it with another bag from the same place. Then turns his back on me to go and get money out of another customer.

Needles to say I was ticked off (yes self censorship is going on here). Still I have new gravel and the ph is dropping towards where it's supposed to be, and I have learnt a lesson. Now all I have to do is find an alternate place to buy replacement pads for my filter, as I don't plan to give that particular shop any more of my money.

I have half a mind to make a complaint to fair trading, would I be wasting their time on an item which cost $16.00 though?

PS while fantails at the Pet shop were $1.50 cheaper even I could see the difference in quality. The fish I got from the Aquarium shop are shiny, with bright orange and gold scales. The ones at the Pet shop meanwhile don't look shiny at all, and have pale dull colours. If the fish weren't a different quality to begin with, clearly the petshop is doing something wrong to them.

Thursday, October 16, 2008

PicoLisp in a chroot

Picolisp has a nifty feature where you can include inline c code, and it will be automatically compiled for you, and just work.

Unfortunately I'm on a 64 system, and pico dosn't at the moment compile under 64 bit. Now I'm told that if I install the right things and tweak the right options I can get 32 bit binaries to compile anyway. But that involves modifying the upstream source and I don't like doing that, unless I plan to submit a patch.

In this case It seemed somewhat pointless. So I though I'd try setting pico up in a chrooted environment. I came accross the following post on the matter: Installing apps in a 32-bit chroot in AMD64 Debian systems.

I followed most of step 1, with the following exceptions:
  • I skipped step 1.3 (decided not to mess with my main gcc instalation.
  • Installed gcc, and build-essentials into the chroot. (also locals and less which didn't get installed by default.
  • Installed dchroot into my real system ( I think this is soemthing the tutorial does later).
  • Compiled picolisp in the chroot enviroment and installed it to /usr/local/
  • Added some scripts to my real path which would execute picolisp and psh in the chroot.


All in all it was a surprisingly easy process and at the end of it I have a fully functional picoLisp. which is accessible form anywhere. even the scripting is easy.


!#/bin/bash
dchroot --preserve-environment <> "$@"


This lets me run pico the same way weather I'm in the chroot or in the main system. And there are no gremlins. I started a picolisp server in the chroot, started firefox (I mean Iceweasel) in the main system, and everything worked, even the ondemand compilation of c from inside pico.

Partially I did this because I wanted to learn how to do it, and now that I have a 32 bit chroot I'll probably move my IceWeasel into it and install flash.

Hmm, I wonder which I'll see first, 64 bit PicoLisp or 64bit Flash? I have it on good authority that they are both in development.

Monday, October 13, 2008

Programming is not that different.

It seems I'm not the only one who thinks programming is
just anther form of composition.

Applying Strunk and White to programming - absolutely inspired (I wish I'd through of it first).

I have seen a few places aregue that Design Patterns, as they are commonly used, are a complete missinterpreatation of A Pattern Language by Christopher Alexander.

Just two examples of how Programming is not that different from everything else. And why Extreme Programming is a step too far.

Sunday, October 12, 2008

PIcolisp Cookbook

One thing which picoLisp needs is a Cookbook. A set of recepies on how to use its quite rich set of primitives to solve particular problems. Currently most of this information is somewhat implicit in the Reference docs. And requires making some big inferences after considering which sets of functions have links to each other.

All of the built in functions are documented, what is missing at the moment however is the various idioms for using them in practice. Thankfully you can usually get a prompt answer on the mailing List.

I came acrose one such are the other day. I was trying to break a circular list, built by fifo, into a plain list. In Common Lisp I'd do this with set. so I tried it to no avail. In Pico (set (cdr A) NIL) actually sets the 2nd element of the lsit A to nil.

It turns out that to set the cdr portion of a cell I want a function called con. My first reaction to that was ... well that's annoying. But then I got to thinking that its not actually a bad thing. Essentially we have to setting functions which are subtly different.

set
: is used for setting values, and con is used for manipulating structure. Yes things get a little confusing if you use cells to build a tree structure where both the car and cdr contain pointers to other cells. That aside I when reading code I can assume that calls to set will change values but not alter the underlyign datastructures, while calls to con will alter structure.

The more I think about it the more I like this distinction. It adds something usful to the code. In the end the only thing which tripped me up was documentation. The Picolisp docs are good as far as they go, but missing a few bits.

Alex, the maintainer of PicoLisp, seems somewhat reluctant to make the official documentation more verbose. Well we may have to agree to disagree on that one. But there has been talk of building a picoLisp wiki (powered by picoLisp). And this may go some way to adding the Cookbook style reference that appears to be needed.