First dynamically balancing walking robot

I find this sort of thing really exciting: Trevor Blackwell's 'Dexter' robot finally walks!. There's a video and everything!

From Paul Graham's post:

There are of course [other] biped robots that walk. The Honda Asimo is the best known. But the Asimo doesn't balance dynamically. Its walk is preprogrammed; if you had it walk twice across the same space, it would put its feet down in exactly the same place the second time. And of course the floor has to be hard and flat. Dynamically balancing—the way we walk—is much harder. It looks fairly smooth when we do it, but it's really a controlled fall. At any given moment you have to think (or at least, your body does) about which direction you're falling, and put your foot down in exactly the right place to push you in the direction you want to go.

Multithreading links

First up, Ridiculous Fish's article on shared-memory multithreading makes a good case for why testing often isn't likely to find mt bugs.

This is one of those 'how deep does the rabbit-hole go?' kind of posts, and is well worth a read. The characterisation of modern CPUs being vastly optimised for single-threaded code is one I hadn't really considered, and I certainly hadn't realized how much more stringent memory read ordering on X86 was compared to other CPU architectures. This means that MT code running fine on multiproc intel boxes may not behave well on other architectures.

Then a followup re-adjusting newbies to the complexities of using memory barriers for synchronisation.

Finally a small one quantifying the speed impact of cache line bounces.

To me these all add reason to think carefully before employing shared-state multithreading as a central theme in your next architecture.

Scheme development environment

I recently had my work laptop nicked while I was in paris, so I've had to reconstruct my linux development environment on another laptop. That reminded me that I intended to document this stuff since I had to dig around a bit for it when I first picked up scheme a few months ago.

Things I use:

  • Gambit scheme
  • The main reason I've stuck with this is termite, but I've also found the mailing list friendly and helpful (and full of much bigger brains than mine). Gambit can also compile static C binaries that run on windows - that's important if you're going to write code in an esoteric environment like scheme. It also has a decent FFI which allows you to embed C code in with the scheme - tres cool, especially when you're writing performance critical code.
  • Emacs
  • You have to use this if you're doing lisp development. Personally I use emacs for development in any language, including Java. Steve Yegge wrote: "Emacs is to Eclipse as a light saber is to a blaster - but a blaster is a lot easier for anyone to pick up and use.". Nuff said. I tend to have two frames open - one with the gambit repl in it and the other to do the actually coding. For people that aren't in the know, the lisp development experience is slightly different to most languages: you basically have a process running (called the REPL) and inject blocks of code into it. This makes the development cycle turnaround super-fast and it becomes a bit frustrating when you go back to waiting for compile cycles in other languages. The various emacs scheme modes provide key presses for sending various regions of code to the repl, the most useful being the current definition (i.e. function) and the last expression.
  • Quack.el
  • Quack has lots of features that make editing scheme much easier. My favourite is automatically converting the word 'lambda' into a single greek lambda character (a-la DR scheme). In addition to making the code smaller, having greek letters all over the place makes me feel pretty hard-core (which is obviously very important).
  • E-tags
  • Emacs tags isn't a patch on what bicyclerepairman provides when I'm writing python, but it does enough to make navigating code relatively hassle free, plus it works with every language you can think of. Basically it parses files and creates an index of all the definitions so that you can jump to the definition of a symbol and back in a single key chord.
  • GNU Info
  • It's handy to have all the documentation in info format because then you can use emacs to jump to the apropriate docs when you need them without having to switch to browser etc.. E.g. this function maps [f1] to jump to the r5rs docs for whatever the cursor is currently pointing at. (with thanks to Bill Clementson for this).
    (add-hook 'scheme-mode-hook
          (lambda ()
            (define-key scheme-mode-map [f1]
              '(lambda ()
             (interactive)
             (ignore-errors
               (let ((symbol (thing-at-point 'symbol)))
                 (info "(r5rs)")
                 (Info-index symbol)))))))
    
    (N.B. quack has a feature to auto-open web based docs into emacs while you're coding, but I work offline so much that I don't use this much)
  • A unit testing framework.
  • I didn't really get on with any of the ones I tried, so I wrote a simple DSL myself (took about half a day after I'd figured out how syntax-case macros work). Ideally I want to end up using something like Nat's Protest system, which chucks out documentation as a side effect of testing. A Scheme DSL should be a good fit for this style, since you can name tests using strings rather than having to document with function names. For the time being though it provides just enough to get me testing (and also served to teach me a few things about macros, which is good.)

Is there anything missing?

Transactional Memory is the wrong path to concurrency

I'm on a sleepy late train home from London to Birmingham (trying to avoid the snow and inevitable rail problems tomorrow). This woke me up:

Patrick Logan says STM "...would be the most tragic turn imaginable for programming in the 21st century."

Very wrong. And it is scaring me how shiny this thingy looks in so many people's eyes right now. I don't think it will be so long before this shows up in Java and C#.

Blimey, that's gonna cause a bit of a ruckus.

(Update: Yep - the comments have started)

The path from specificity to usefulness

I tried to comment on Seth's post, but I think the comments on his blog are a bit broken at the moment (the capcha question wasn't rendering, so I couldn't answer it!). I guess I'll trackback instead:

The path from specificity to usefulness that Seth describes was exactly the trip I took attempting to implement semantic web approaches at work to assist with managing IT operations info (which was stored in various silos). I started off with RDF and built a store which used some OWL rules to connect the data from the various sources. This proved cumbersome and difficult - other people found it quite a hurdle trying to understand RDF, and the same URIs got used to mean subtly different things (e.g. IT application vs project).

After a year and a half of evolving the system the best solution ended up being to just index triples of words. Vaguer than URIs, but easier to harvest and match from databases. Since humans write the queries, it turned out that the vagueness wasn't a problem at all. Universal Specificity (such as is required by URIs/RDF) just doesn't seem to scale very well in my experience.

Wordpress permalink probs

Apologies to anybody that got a 404-not-found on my last post. It seems that sticking the word 'blog' in the subject causes the post permalink to fail on my wordpress setup. No idea why (and no time to investigate at the moment!) - I've fixed the previous post by hacking the permalink directly. (maybe it's the wordpress pixies telling me to upgrade)

Blogging and verbosity

As somebody who prizes brevity and usually starts with long blog posts and tries to distill them down into palatable chunks I raised an eyebrow at Yegge's post on the subject. Yegge advocates embracing the verbose.

I could use a good marketing name for this longer-is-better phenomenon too. The synopsis is that I think taking the time to write about something thoroughly gives it a greater (if slower) impact. Look at Gladwell's "The Tipping Point," or Surowiecki's "The Wisdom of Crowds." Either of their theses could have been succinctly expressed in a simple essay or paper, but would they have had the same global impact? I think not.

Then, by way of proof to the assertion, Yegge proceeds to meander through a seemingly disconnected set of ideas in humourous, eloquent wine-driven verbosity. He tackles blogging, agile rituals, firing your boss and becoming a superstar with barely a pause for breath. Of course the real secret to successful long-winded blogging is managing to remain entertaining while you spew.

BTW, if you haven't checked his post from way back on why you should blog, do so now! It contains lots of insights that were new and valuable to me when I first discovered it earlier this year, including one on the timeliness of ideas that is worth the reading effort on its own.