Archive for February, 2008

IObit SmartDefrag — windows program to defrag drives

Saturday, February 23rd, 2008

For the last few months, I’ve been using IObit SmartDefrag. It is a freeware defrag program that keeps your drive running fast. Basically, you install it and it runs in the background, like a librarian silently alphabetising your book collection. Your machine can find and load files faster. Anyway, it feels like my machine has stayed fast, where I would have expected it to slow down over time. Anyway, it’s freeware, it seems to be reliable, and it’s kept my machine fast. Can’t go wrong.

Post to Twitter Tweet This Post

Stephen Fry, blogging and podcasting

Wednesday, February 20th, 2008

So, just in case you didn’t know about Mr Fry’s blog and new podcast — you’ve been told.

Post to Twitter Tweet This Post

Impractical, Uncommon Lisp.

Wednesday, February 13th, 2008

A friend of mine, Rob Ahrens, asked me how my learning of the programming language Lisp was going. I thought I’d respond in an open letter.

Um, Hi, Rob.

I have two previous posts on lisp, A programming language only a mother could love, and lisp, the beautiful hydra.

Childhood Nightmares

When I’ve had time, I’ve been attempting the problems in Project Euler. Euler lays out a series of ~200 mathsy programming puzzles, things like ‘find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed one million.’ I’m using them as a way of trying out the language. At my side, possibly the only decent beginner’s book, Practical Common Lisp. (It’s also free.)

So far, I’ve finished 2 problems. Hmm. I’m pretty sure I could have finished more of them, more quickly, in almost any other language.

That, I think, is at least in part that lisp doesn’t come naturally if you’re used to non-lisp languages, things that bear a resemblance to C or BASIC. I’m having to go right back to basics, learning to construct things in a new way. Here’s the code I used to solve problem 2;

(defun fibseq (max)
  (let ((result ())
        (n-1 1)
        (n-2 0)
        (term 0)
        (i 0))
    (loop
     (setf term (cond ((= i 0) 1)
                      ((= i 1) 1)
                      (T (+ n-1 n-2))))
     (setf n-2 n-1)
     (setf n-1 term)
     (setf i (1+ i))
     (when (> term max) (return))
     (push term result))
    (print result)
    result))

(defparameter allfib (fibseq 1000000))
(defparameter evenfib (remove-if-not #'evenp allfib))

; the answer!
(print (reduce #'+ evenfib))

I don’t print this here to demonstrate the clarity of lisp. In fact, the opposite. This looks like hell to me, at least right now. There is, no doubt, a far better way to do this. But I don’t know, and so I’m writing programs that are terribly inelegant. Nestled in the code above is a non-terminating loop with a break condition, because I couldn’t figure out how to do the equivalent of

while (n < 1000000)
{

Right now I feel like I did when I was ten, programming in BBC basic and using GOTOs. Hell, it knocks together working programs, right? But you don’t want to stay there too long. That feeling of childhood programming, though… there’s something compelling in it. Lisp tastes of nostalgia. Remember programming Logo? Or BASIC? Lisp is making me feel like that. At least for now.

Pretty soon, I hope to have mastered basic loops. Then I’ll be well on my way.

(setq subject (list ‘( ‘)))

Or, now I will talk about parentheses.

In my head, despite being entirely uncomfortable with while loops, I’m starting to see everything falling into a lisp syntax. The idea of just bracketing up your stuff into lists seems like a great first-draft syntax for everything — want to talk about data structures? write

(data
  (entity1 (attribute1 attribute2))
  (entity2 (attribute3 attriubte4)))

want to write pseudocode for a function call?

(func (param1 param2) ...)

want to write a todo list?

(do 
  (buy bread)
  (tidy (kitchen living-room bathroom))
  (get life))

Valentines day coming up?

 (get-count
     (make-list #'(lambda (i thee) 
                          (permute #'love i thee))))

Ok. Maybe not. (apologies to Elizabeth Browning there.)

But you get my point. I hope. Those brackets are just fine for everything. I’m starting to understand why hardcore lispers want to do everything in lisp. My brain is infected with brackets.

But for right now? I’m going to learn to do a for loop, and then we’ll see.

Post to Twitter Tweet This Post

Samurai Dog Armour

Monday, February 11th, 2008

samurai_dog_armor_1.jpg

Fun oddness; Samurai Dog Armour

This suit of dog armor — identified by antique Japanese armor dealer Toraba.Com as the only known and certified authentic example of its kind — is believed to have been created for the pet of a wealthy, high-ranking and presumably eccentric samurai or daimyo (feudal lord) in the mid to late Edo period (mid-18th to mid-19th century)

link

Post to Twitter Tweet This Post

The pleasure of single-tasking

Friday, February 8th, 2008

Over Christmas, I spent six and a half hours driving from York to Pembrokeshire, to stay with Clare’s parents. What should have been a hellish drive was significantly more pleasant than expected. I’m going to talk about why, and make a wider point about life hacks.

Long-distance driving, especially somewhere you’ve never been before, can often be nasty. You have to juggle several things at once – planning the route, controlling the car, talking to your passengers, etc — and you have time pressure, too. For me, this means stress.

Two things, I think, made the journey much more pleasant;

  1. I drove an automatic,
  2. I used GPS to navigate.

This offloaded several tasks from my brain; I no longer had to plan a route; everything was handed to me in simple-to-follow left/right/straight on choices, and if I made a mistake (which I did a couple of times) the GPS just routed round it, giving me a new route which got me there.

The automatic gearbox also made things easier. That part of my brain that would normally be making sure I was in the right gear was no longer occupied.

Life was simpler, so life was sweeter.

Joel, of the ‘Joel on Software’ site, uses the analogy of automatic transmissions when he talks about some benefits for programmers (scroll to ‘Automatic Transmission Wins the Day’). The wider point really is that freeing up your mind from one type of detail is like juggling with one fewer ball; it’s much, much easier.

So this is my wider point; anything fully automatic (I mean really and truly don’t-make-me-think automatic) makes your life less stressful.

The flipside, of course, is control. You always sacrifice a little control to the system. You lose precise throttle control in an automatic car. You lose control of exactly what stocks you own if you buy an index-tracker ISA.

I think this scares people, but really shouldn’t — this level of detail will probably tire you, stress you, and give very little benefit over the automatic method.

I’ll finish with a fantastic quote from Alfred North Whitehead, co- author of the Principia Mathematica;

It is a profoundly erroneous truism, repeated by all copy books and by eminent people when they are making speeches, that we should cultivate the habit of thinking of what we are doing. The precise opposite is the case. Civilization advances by extending the number of important operations which we can perform without thinking about them. Operations of thought are like calvary charges in a battle–they are strictly limited in number, they require fresh horses, and must only be made at decisive moments.

Post to Twitter Tweet This Post

It’s all text! — Firefox Add-on.

Wednesday, February 6th, 2008

I’ve just discovered ‘It’s all text!’, a firefox add-on that makes it easier to edit text on the web.

It’s a pretty simple idea; any textareas (those boxes used for composing email, writing forum posts, editing wikis, etc) get a little button;

It’s All Text Screenshot.

click the button and it’ll let you edit the same text in a proper text editor. When you save the file or close the editor, it copies all the text back into the web page.

All of this means it’s a lot easier to edit text on the web; especially useful for emails and, well, blog posts. ;)

Post to Twitter Tweet This Post