Red Echo

November 12, 2009

I have just about finished putting together a basic module system for Radian, which will allow programs to span multiple source files. Designing this system was more difficult than I had anticipated; the module system says a lot about developer workflow, so I had to think pretty far ahead about the things I expect people to do with this language and the ways they will likely want to do it.

The module system came about because I want to start building a standard utility library, and in order to do that the compiler needs to link a program together from multiple source files. I want to have some semi-automatic mechanism for linking against the standard library, but it seemed more sensible to build that on top of a generic linking mechanism than to start with the special case and generalize it.

Lessons learned from experiences with other languages:

  • Modules should not be able to define global identifiers. A client program can always import a qualified symbol into its unqualified namespace, but there’s no way to prevent imported global identifiers from conflicting with each other.
  • Source files should import dependencies explicitly. Interpretation of a source file should not depend on any external context, like a project file, an environment variable, or the contents of some shared directory.
  • Support modules should be initialized and finalized explicitly, in the main program, so that the programmer can control the dependency order.
  • The structure of the program should be visible in the filesystem. Don’t trip people up by introducing a parallel-but-different structural hierarchy.
  • Makefiles are evil. The language must allow the programmer to describe the program in such a way that the compiler can identify all of its parts and build a finished executable in one step.

The system I’ve built works like this. You invoke Radian on a program file; this is equivalent to the “main” function in C. This program file may import module files, which may in turn import other module files, using the import statement:

import foo

This statement declares the name “foo”, representing the contents of the file “foo.radian”, which the compiler expects to find in the same directory as the client file. Imports are simply placeholders, to be resolved at link time, so circular references are not a problem.

The Radian compiler treats the contents of an imported module file as the body of an object declaration. The top-level functions and other declarations in the file become the members of the imported object. A source file cannot simultaneously be a program and a module, since only a program file gets the implicit “io” variable allowing interaction with the rest of the system.

That’s all I’ve built for now. As far as the standard library goes, I think I’ll throw an implicit “radian” import into the top-level namespace of every file. All of the standard utilities will be members of this namespace – much like “std” in C++. This will allow me to extend the standard library in future versions without introducing name conflicts. To make this more convenient, I want to extend the import statement, like Python but in a more sensible order:

import stack from radian

This would define a new item named “stack”, equal to “radian.stack”; you could extend the “from” expression arbitrarily to handle deeper nesting. You wouldn’t have to have imported the “from” identifier on its own; you could import only the item you wanted and leave the rest of the package unimported.

Proceeding onward, I expect that you’ll be able to treat subdirectories as modules – if you had a subdirectory “foo” next to your program file, containing a module file named “bar.radian”, you could import it like this:


# get access to the module file only, resulting in 'bar'
import bar from foo
# import the whole directory, resulting in 'foo.bar'
import foo

I’ll need to design a package system as well, but that is still some distance ahead. It’ll probably look something like python’s packages, which remind me of Mac OS X bundles. I am fairly well convinced that the convenience of a standard central package directory is outweighed by the configuration hassles and dependency tracking issues, so I think I will require packages to be included in the project folder. If people want to keep a central repository of useful libraries, or several such repositories, they can always make a softlink/alias into the project folder.

November 7, 2009

Performing at Seacompression


November 5, 2009

music workstation


I am playing at Seacompression!

Michael H. called up last night, wanting to know if I was interested in the opening slot at Seacompression. Well, heck yeah! Seattle’s biggest burner party, hundreds of people and a huge PA system? No way am I turning that down. So I’ll be playing from 7 PM til 7:45 this Saturday, the 7th. Seacompression is going to be in Hangar 30 at Sand Point (aka Magnuson Park); tickets are $20 presale, $30 at the door.

Yeah, it’s early, so I’m not expecting a huge crowd – but man, this is exciting. Come see me play! I can’t wait to crank it up and try to make you dance.

One improvement I made when redesigning my music machine was to add a compressor, right at the end of the signal chain, to help manage the overall dynamics. It happened to be that one-in-ten craigslist item that simply didn’t work, so I’ve been getting along without it, but the replacement arrived yesterday and I’m really glad I stuck with the idea.

Practically all the music you hear has been passed through a compressor: you can make as loud a noise as you want when you are playing an acoustic instrument, but there is an upper limit when you are playing through a PA system, and exceeding that limit will create distortion. The problem is that music can be very “peaky”, especially dance music: the loud bits, like kick-drum hits, are very much louder than the quiet bits. Turning the overall level down far enough to avoid distortion leaves the body of the mix sounding quiet and anemic. The solution is to compress the dynamic range, reducing the difference between the loudest and the quietest parts of the signal: this is the job a compressor does.

So why is this important for my music machine? When a DJ spins a record, they’re reproducing a signal that has already been compressed during the recording/mixing process. The DJ can set a nice hot level for the overall sound and rest assured that the peaks have already been tamed. I don’t have this luxury: since I’m making music from scratch, I have to manage levels by hand as I go, and I generally have to leave the overall level lower to make up for the peaks. This is fine for ambient and downtempo stuff, but when I try to play louder, thumpier, more uptempo music, I end up doing a lot of work riding the level knobs without having much to show for it.

The compressor, then, lets me delegate one more tedious job to a happy little robot, yielding a clean, consistent, punchy sound. And it works! I fired it up this morning and spent a few minutes playing before work. Drums, hats, bass, lead, pad, arp – build ’em up, break ’em down, crank it, back off – the sound stayed nice and full and clean. Yes! This is exactly what I wanted.

November 4, 2009

This essay certainly contradicts the prevailing wisdom, but it makes some reasonable points. It’s OK Not to Write Unit Tests:

I’m not saying that all unit tests are worthless, nor that you should never write one ever again. But I am suggesting that you take a good hard look at the time you’re spending and ask yourself what benefit you are really deriving.

What I’m saying is that it’s okay if you don’t write unit tests for everything. You probably have already suspected this for a long time, but now you know. I don’t want you to feel guilty about it any more.

Test what can fail. Test stuff that’s easy to test. But don’t beat yourself up trying to get 100% code coverage. 100% code coverage doesn’t mean all that much, anyhow.

November 3, 2009

Awesome: a visit to the imaginary town of Argleton, which shows up clearly on Google Maps despite not actually existing. Current best theory is that it was inserted by Google’s data provider as the equivalent of a trap street.

The possibility of actually visiting an imaginary place seemed irresistible. In terms of my journey, not to go there would be a dereliction of duty, like saying ‘I could have made a detour to Rock Candy Mountain’ or ‘Tir-nan-Og’, ‘but I decided to press on directly to Maghull instead’. So today I decided to make the expedition – from the world we know to a fictitious and uncertain place.

Reaching non-existent lands can be accomplished in many ways, but I decided to use Google itself to navigate to this one. After all, they invented it.

October 31, 2009

Hive Mind Halloween


I had no costume inspiration of my own this year, so I decided to join Alison’s crew of bumblebees. I wanted something I could comfortably dance in: thus, my concept was “disco bee”. I cut two yards each of black and yellow metallic stretch material into five-inch strips, then stitched them back together, alternating colors to make stripes. From this I cut out a pair of pants, making each leg from a single piece so I wouldn’t have to match the stripes along an outside seam. I fitted the legs, made the yoke and waistband, adjusted it to fit comfortably, stitched it all together – then discovered I had left no way to actually get into my own pants! Frustration!

Time for a dinner break, with Ava, over at Jeff and Nika’s place. Nika happened to have a spare zipper, so I used a sharpie to turn it black, then stitched it in: hey-ya, the pants are done. I made a pair of sleeves from the remaining fabric, attached front and back with strips of elastic. I finished off the look with an abstract set of wings, repeating the striped look with layers of black and yellow fringe, stitched along the underside of each sleeve and across the shoulders. Top it off with a pair of springy antennae, and I was ready to go – 11:15 PM is a splendid time to leave for a late-night party!

The bumblebee project came out really well; there were at least 30 of us, enough that people clearly understood there was something going on. Shawn and Barry came dressed as bee-keepers. Hive Mind always has a lot of really elaborate costumes, and I felt good to be wearing something unique and polished. The party was so crowded, in fact, that I spent the first hour just standing in the hallway talking to friends as they passed by! It wasn’t until 2 AM that the crowds had thinned enough that I felt like dancing. But, hey, it was time-change night, so we got an extra hour of party in and I rocked out until 5 AM. It was a good night.

October 27, 2009

I’ve started poking around at connecting Radian to LLVM. The current backend translates the flowgraph to a linear intermediate code, then translates the LIC instructions to C source code, then passes that through gcc to get machine code. I’m not sure whether to leave the LIC pass in place, then convert to LLVM instead of C source code, or to emit LLVM IR from Radian’s data flow graph. The significant semantic difference is that LLVM IR includes type information, which is implicit in LIC.

While I think about this, I’m playing around with using Church encoding for booleans. Instead of including a “boolean” data type with two predefined values which represent true and false, then implementing a “branch” operation which chooses between two values based on a boolean value, true and false themselves become the implementation of the branching operation. It’s as though they were defined like this:

function true(thenclause, elseclause) = thenclause
function false(thenclause, elseclause) = elseclause

If you have a reference to one of these functions, you can use the function itself to perform the branch: you just call the boolean value, passing in the option you want to use for “true” and the option you want to use for “false”, and it returns the one that matches the boolean’s value.

This wouldn’t be appropriate in every language, but in a functional language like Radian the only thing you can do with a boolean value is to select which of two expressions you want to use. It makes sense to do away with the custom “branch” instruction and just use function invocation.

October 23, 2009

I cleaned up my serger and re-threaded it the other day, then spent a couple of hours making up a long-sleeved T-shirt. The collar came out wrong, again, as it has each time I’ve tried to make a crew-neck with knit fabric. The fabric always stretches out and the collar ends up enormous and floppy. I don’t get it. I can make all kinds of other collars but the crew-neck eludes me. It was good serger practice, though. Re-threading the machine takes all of two minutes now, and I am starting to understand how the tension controls work.

Radian, of course, is my other big free time project. I have a simple Hello World running now, and that means it is probably time to abandon my temporary C-source-code backend and start using LLVM. I’ve finished as much of the front-end language support as I’ll need for now, and it’s probably time to shift my focus toward the runtime environment. I need to build an IO interface, a garbage collector, and the core function library; using C as an intermediate step is just a hindrance here.

October 21, 2009

You can publish a Git repository on any old web server, without needing a special git daemon, using a command called ‘git-update-server-info’. This would be useful if you wanted to publish some code but lacked the ability to offer any old user an ssh login, perhaps because you are using a hosting service instead of running your own server. Here are a couple of how-to guides:
git-server for the poor: git-update-server-info, rsync, and remote repository
How to publish a Git repository
SourceForge FAQ for Git development

It is also possible to create a patch file with git which you can send via email. I am thinking about setting up an auto-build-verify system that checks a dedicated email inbox, downloads patch files, builds them on a temporary branch, runs a validation suite, and either pushes the changes up to another repository or sends back an email describing the errors that occurred.

We were working toward a system like that just before I left Real Software, using Buildbot. It was a big improvement over the ad-hoc practices we’d always used before, but it was still a reactive notifier rather than an active filter. You checked in code first, then the buildbot would run its tests to see whether you broke anything. It was much better than hearing about it from one’s irritated colleagues a day or two later, but still too fragile.

It was much harder to break the build at Microsoft, where no change could be committed until it included a new test suite and had been shown to pass every existing test. This was unfortunately a completely manual process and thus extremely time-consuming, but it did create an unusual degree of confidence in the checkins, when they finally did happen.

Grunt work is a waste of human time: that’s what robots are for. I want to send my code off to the build system whenever I think it’s ready, let it do the repetitive validation, and then either pass the code on to the development trunk or let me know what went wrong. If I screw up, I’ll have a chance to fix it before I waste anyone else’s time dealing with the problem, and I’ll know that code I pull from the trunk will always work as far as the test suite is concerned.

Home pages for some interesting programming languages:

Python: python.org
Perl: perl.org (does not appear to be an official home page, but this is close)
Ruby: ruby-lang.org
Scala: scala-lang.org
Clojure: clojure.org
Factor: factorcode.org
Haskell: haskell.org
Erlang: erlang.org
OCaml: caml.inria.fr

October 19, 2009

I finished the jacket on Saturday, in time to wear it out to Sara’s cocktail party. I just now had Ava snap a few photos of me wearing it so I could post one here, but for some reason I came out looking like I was in a really terrible mood, so I’ll have to get some more taken later. I’m fairly well contented with the results: it’s imperfect, of course, but I learned some things while making it that will undoubtedly serve me well in future projects, and I ended up with a garment that will easily accomplish its intended purpose.

October 18, 2009

New shelves: tidy sewing table


October 15, 2009

early autumn


October 14, 2009

That cold pretty much wiped me out all last week. I’m feeling fine now.

I haven’t finished the jacket yet. The pockets came out perfectly, but I made some pretty significant mistakes when laying out the lining and had to get some more material. I also decided to tear out the old collar and make a new one, and to take advantage of the pocket construction to fit some extra material into the hip seams. This took a lot of extra time but the jacket looks a lot better and fits more comfortably, so I think it was worthwhile. The jacket started as a sort of casual experiment but has become something I could wear regularly.

My new job is going fine. The company’s in crunch mode and everything is a bit chaotic, but I’m working away and not letting myself get too stressed out. It’s nice working at home again.

I’ve been putting a lot of my free time into Radian lately. I’ve built a simple object system, with member dispatch, inheritance, instance variables, and parameterized constructors. There are no mutator methods yet (all methods are “const”, in C++ terms), but it should be enough to build a primitive console-IO module. I expect I will have a working “Hello world” by the end of the month.

October 4, 2009

I came down with a cold Friday night, so I’ve been taking it easy this weekend. I mostly stayed in bed yesterday, though I did rouse myself for a few hours to play the opening set upstairs at Jason Baker’s party. I kept the tempo in line with my energy level – about 75-80 bpm – which seemed to work well for the upstairs room’s “sprawl out and relax” appeal. I didn’t last long after the set was over, though, and crawled into bed shortly after midnight.

Today I’ve been casually poking along at my current sewing project, the black & tan jacket. I’ve fussed around with some scrap denim making welt pockets for practice, and after I’ve brewed another cup of tea I’ll see about applying the technique. Perhaps after that’s done I’ll work on the lining.

The jacket has some fit issues: it’s narrower around the hips than I’d intended, the shoulders are a little tight, and the collar didn’t come out the way I’d planned. It’s a little disappointing, I’ll admit, but the goal of this project was more to get myself back in the practice of sewing than to construct a specific garment, and I’ve certainly learned some things in the process. Perhaps I’ll work out some way to adjust the fit, too.

October 1, 2009

The new jacket is coming along well. I have been making it up as I go rather than using a pattern, and though it looks somewhat more severe than I’d intended, it’s pretty much coming out according to plan: a hip-length, four-button jacket with a banded collar and a single vent, done in heavy canvas, black with tan details. It’ll be lined, and I’m planning a pair of welt pockets with flaps. I haven’t decided what to do with the cuffs yet – perhaps turned-back with contrasting fabric, perhaps a strap…

Depression as an adaptive trait

This Scientific American article suggests that depression is less a mental disorder than an adaptation for deep analytical thinking:

This analytical style of thought, of course, can be very productive. Each component is not as difficult, so the problem becomes more tractable. Indeed, when you are faced with a difficult problem, such as a math problem, feeling depressed is often a useful response that may help you analyze and solve it. For instance, in some of our research, we have found evidence that people who get more depressed while they are working on complex problems in an intelligence test tend to score higher on the test.

September 27, 2009

My bike came back from the playa with its chain loose enough and rear sprocket worn enough that it was no longer safe to ride. I parked it at the Rocket Factory and ordered a new chain and sprocket set. The parts finally arrived yesterday, so Adam and I met up over at the shop and spent a few hours working on the project. We didn’t finish – had trouble getting the rear sprocket off the hub – but once that’s done it should be no more than another two hours to finish up. I bought an O-ring chain this time, so perhaps it’ll last a bit longer than the last one did.

This evening I’m working on my first new piece of clothing since the jacket for MJ a year and a half ago. It’s a black and tan jacket, made of canvas with a light cotton lining. It’s nothing fancy but it feels good to be inspired to make clothes again.

September 25, 2009

home sweet home


September 23, 2009

I have this cute little netbook, an Asus EEE 1000h, which came with a semi-crippled variant of Xandros Linux. It worked fine since I could always drop into the terminal, and I eventually got enough additional packages installed to make it useful, but in the course of trying to install a more normal desktop interface I managed to wreck it – nothing ever works right the first time in Linux-world.

Yesterday I finally got around to installing Ubuntu netbook edition. Wow! It’s smooth, consistent, and doesn’t condescend to its users the way Asus’ custom Linux did. It’s not trying to be Windows or Mac OS, either; it’s just a nice, well-built system that suits the hardware perfectly. Definitely satisfied – ex

September 18, 2009

From the blog Psychology of Programming, these excerpts from a 1995 paper on object-oriented programming published in Human-Computer Interaction have some fascinating comments from cognitive psychology research as applied to programming language design:

In careful experiments, Gentner (1981; Gentner & France, 1988) showed that, when people are asked to repair a simple sentence with an anomalous subject-verb combination, they almost always change the verb and leave the noun as it is, independent of their relative positions. This suggests that people take the noun (i.e. the object) as the basic reference point. Models based on objects may be superior to models based on other primitives, such as behaviours.

September 16, 2009

Finished music machine (version 2)


Music machine inside


September 15, 2009

Mission One electric motorcycle (previously) has reached 150 mph during speed trials at Bonneville.

September 12, 2009

I’m back. The cube project was a great success. We’d never built the whole thing before, but we’d prototyped enough of its components to be confident, and indeed the whole thing worked. It was solved for the first time on Tuesday night, and again every night thereafter – difficult enough to be a challenge, but achievable enough to be tantalizing.

I didn’t actually want to be out in the desert this time around, so I had a few rough days after the construction work was done, but with help from some friends I eventually had a good time. Seven years is enough, however: I am never again taking a tent to the playa. If I go back – and it seems likely that I will, however I may feel right now – I’ll bring something to live in that is windproof, dustproof, lightproof, and tall enough I can stand upright.

It was really satisfying to be involved in one of the biggest, most recognizable art projects on the playa. We got a lot of media coverage and our project was one of the regular stops on the mutant-vehicle tour circuit. People loved it and wanted to tell us how much they loved it.

At the same time, it was hard to know how to feel about it. This is the first time I have been part of a large team project that actually succeeded. When I’ve been part of successful projects, I’ve been able to take pride in what I’ve accomplished, and when I’ve been part of large team projects, they’ve been heaving corporate disasters where I had no control over the outcome. How do you take pride in your small part of an accomplishment someone else was primarily responsible for? I don’t want to take credit for work other people did, but it feels like false modesty to take no credit at all. I don’t know how to think about this.

August 21, 2009

Project status updates:
– playa trike: got construction pretty far along only to discover a major design flaw in the steering geometry. Fixable, but clearly not happening in time for this year’s burn.
– DJ machine: lots of progress, nearly done, put aside til after the burn. All hardware mounted in the case, all power and MIDI routing finished, half the audio routing done. I need some longer 90-degree-connector patch cables.
– motorcycle: Found a brand-new lens cover at bikebandit.com and installed it in place of the patched-up one. Saddlebags arrived: need to invent some kind of mounting bracket for them.
– finally, at long last, finished tailoring Maja’s furry pink vest. Still need to attach and power the array of LEDs. The half a dozen mintyboost kits I ordered arrived; I’m going to skip the USB connector and set them up to produce 12V instead of 5V.

August 16, 2009

IMG_1301.JPG


August 15, 2009

Pat & Tanya’s wedding


August 14, 2009

IMG_1266.JPG


« Previous PageNext Page »