Assertions (by )

Assertions are a useful tool in defensive programming. If you're writing a bit of code that assumes some condition to be true, since that condition being true is a design constraint of your system so it can only possibly be untrue if there is a bug elsewhere in your code, then it can help to put an explicit assert of that condition before your code.

Read more »

First Class (by )

Once a week, I go to London for a few days, almost always by train. It costs £42 if I buy a ticket from the station on the day - or, if I book in advance at TheTrainLine, as little as £16. Tickets ordered in advance are cheaper, but it seems there is a limited allocation of each price grade - as the more popular routes quickly sell out of £8 each way tickets, then the next level up (£11.50), then the next level up (£18).

However, when I booked the tickets for last week, for the return journey on Saturday, only the £18 ones remained - but, unusually, there were still some £19.50 first class tickets left.

I'd never travelled first class before. So, I decided I'd give it a try. £1.50 isn't much to spend on an experiment.

And my conclusion is: first class equals a comfier seat and the offer of a free biscuit and tea or coffee.

Which, if I drank hot drinks, would definitely be worth the extra one fifty, at the going rate for such things.

As a non-hot-drinker, I think I about broke even with my experiment, but on a journey of more than an hour, the better seat would be well worth a similarly small price increase.

But travelling first class is nowhere near worth the more than doubling in price (£116 rather than £42) it costs if you buy your ticket on the day. That's a total ripoff.

Bench PSU made from an old PC power supply (by )

My first PC compatible was an actual PC. As in, the original IBM PC - not even an XT. It died a death, but I salvaged the power supply from it, with the nice red switch, to be a bench PSU for my electronics experiments:

An original IBM PC power supply

It supplies -12v, -5v, 0v, +5v, and +12v. Which served me well for some years, but these days, everything's 3.3v or 1.8v. And my termination setups - first wiring directly into the row of screw terminals on a breadboard, then later a bit of wood with metal strips nailed to it so I could attach croc-clips easily - all left something to be desired.

So I got busy and built this:

The bench power unit (switched off)

Complete with a power LED so I can see at a glance if it's live:

The bench power unit (switched on)

Inside it's quite simple. Most of the terminals are fed directly from the PSU via the black cable, but I added an extra wire for an earth connection to the chassis (which I checked was really earthed) for ESD wrist straps. I mounted 3.3v and 1.8v linear regulators on a bit of stripboard along with the LED and its series resistor, and hooked it into the 0v and +5v lines.

Inside the bench power unit

Job done. Now the last bit of major infrastructure I need set up is to get Ethernet into the lab so the PC I have in there for driving the dev boards can access the Internet and my version control system...

What’s neat about elegant languages (by )

Most people who like to use "unusual" non-mainstream language have to have a motivation for doing so. After all, there are reasons not to - a smaller user community, although that can be a good thing, means less libraries, less support for more unusual platforms, and less likelihood of your programming in that language ever earning you money.

When asked, most will say that they find programming in their chosen language easier, but it can be hard to explain why.

However, in a discussion in IRC recently, I think I may have captured part of it:

  • alaricsp: I do a lot of programming in various languages, and I tend to find that the amount of coolness I can do per line in Scheme is higher, and I get less bugs
  • alaricsp: As in, I decide to do something complex, sit down and write a hundred lines of scheme, try to run it and get lots of syntax errors due to typos, fix those, then it's semantically bug free about 75% of the time; and in the remaining 25% there's usually just one simple bug (last one was due to me getting confused with some boolean algebra over lists, doing an any? instead of an every? or something like that)
  • alaricsp: I start in implementation space and build up in thin layers to get to problem space
  • alaricsp: Cheap easy-to-use abstraction means it's cost-effective to have lots of thin layers
  • alaricsp: And thin layers are easier to think about, so less buggy

To which somebody else followed up:

  • sjamaan: Aye
  • sjamaan: I find the barrier to creating an abstraction in OO languages to be very high, for example
  • sjamaan: I actually sigh everytime I have to create a new class file!
  • sjamaan: Whereas I don't even think about creating a lambda
  • sjamaan: I just do it

Memory management (by )

A lot of the core infrastructure in a computer system - such as memory management - is somewhat overlooked for opportunities to improve things, because a vicious circle of conservatism sets in: we tune memory manages for systems that work like POSIX, and then stick with systems that work like POSIX since the memory management is so well-tuned...

So I set myself the task of designing, from scratch, an approach to memory management that's appropriate to an event-driven system based around a purely functional language with mutation expressed via unique typing.

It's far from complete, but here's a brain dump:

Read more »

WordPress Themes

Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales