Category Archives: General

Catch-all category

General

The difficulty of describing bugs in code

I’m working with someone to fix a bug in some code. I want him to be able to actually do the fix, and in the process, learn more about the code base. He’s taking over a project from me that I’ve been working on in isolation for a year or so, so the priority is on shifting the knowledge from my head to his rather than immediately fixing the bug.

I think I have a fix (which I developed in the process of trying to explain the code), but just handing it over wouldn’t achieve the goal of giving him the deeper understanding of the code that he needs going forward (I still offered him the option; we’ll see what he thinks). The fix only affects about three lines of code, and it probably would have taken me about 45 minutes to find and fix myself. But explaining the whole context of the code, and precisely how it was that I screwed up in the first place, that’s a lot more work. I spent 3 hours trying to document the meaning of one relevant variable, and I still feel like I didn’t do a great job of it. It will be at least another couple hours of work to describe exactly how I fixed the bug, if he wants to hear it.

This might be one of those cases where he’d be better off refactoring the code. Sometimes people use refactoring as a way to gain deeper understanding of the code, as well as making it easier to understand in the future. In this case, for example, I wrote a function called adjust-rowspan-vec, which probably should have been named update-rowspan-vec-for-next-row. Though the name rowspan-vec in itself is not all that clear, but ugh, it’s hard to find a good name for that one; maybe data-for-cells-which-span-rows-and-are-currently-in-flight-so-that-we-can-track-where-to-insert-dummy-cells-as-we-scan-down-the-input-rows, or something. So, yeah, probably needs a refactoring, just so that we can better wrap our heads around whatever concept I was trying to express with rowspan-vec.

It’s hard to describe the concepts in use in the code even if it was working properly, but to describe my partially-broken mental model when I wrote the incorrect code would add another level of complexity. I think I could do it, though, and it’s awesome that human languages have the ability to express such deep weirdness.

[And just to vent a little more, none of this is made any easier by the fact that the code in question is in a functional language, which means we’re using immutable variables and two levels of recursion rather than mutable variables and loops. Nor is it made easier by my lack of confidence in communicating in English with someone whose first language is not English…]

General

Vias and edges

Jayson was asking on Twitter whether anyone knew where to get pins like the ones on Basic Stamps. I wasn’t able to help him, but I did have fun looking around at the catalogs of Mill-Max, TE Connectivity, Interplex, and Keystone. There are a damn lot of connectivity solutions out there!

Sparkfun did have a couple interesting forum threads about these, here and here, and at Mill-Max, I found something close (though that doesn’t lead to any small-quantity distributors).

Anyway, when I was looking at the Basic Stamp, it popped into my mind that maybe one could save some hassle in doing home prototyping of 2-layer PCBs if one could route vias out to the edge of the board and use clips at the edges, rather than drilling and using rivets, wires soldered on both sides, etc. But then I realized that such a scheme is like trying to lay out your graph on a sphere rather than a plane, which leads to no advantage, as is well-known in topology. Topology is good for something, eh?

Thinking along those lines, though, makes me wonder about other methods that might yield some advantage. For example, route out a hole in the middle of the board and clip traces on those edges and you’ve got yourself a torus, which does (I think) get you more flexibility. It might be fun to do an investigation of graph embeddings in a variety of physically-realizable connection schemes, with an eye toward finding some method that is easy for a home prototypist given some small catalog of techniques and pre-manufactured connectors. There’s probably some paper written by Euler when he was 7 that lays this all out, so I suppose I should hit the library and brush up on my topology…

General

Soup

After reading The Milo Criterion, I was reminded of a thought I had a while ago:

it’s one thing to say “oh, that soup i just made from some random ingredients turned out really well.”. it’s another thing to throw up the recipe on your blog and let people put it together themselves. it’s yet another thing, though, for the entrepreneur to turn that into a can of soup that millions of people can buy for $0.99 as just another option in the soup aisle.

After I wrote that, I had a feeling that there was something odd about my use of the word ‘entrepreneur’ there. I think it’s that the average entrepreneur wants to think that their product is so radical that it wouldn’t fit in the soup aisle. It has to be in an end-cap display with a space cleared out around it so that people fainting from joy won’t hit their heads on shelves.

Maybe your thing is so radical it can’t rightly be called soup any more. But there’s quite a bit of marketing power in being on the shelf next to the soup, such that a customer in the soup aisle can use existing decision processes to decide on your product. If it really is a significant departure from soup, customers will tell you (and others) that, and they’ll work with you to define a new category. That’s probably a lot easier than trying to define that category ahead of time and then drag people there with you.

General

Rescaling the economies of scale

I’d like to work on rescaling the economies of scale. Let me start with a brief look at what’s meant by ‘economies of scale’. This is very simplified, and we could talk for days about different nuances and exceptions and such, and if you want to start that conversation, I’m up for it. But this model will suffice for me to explain what I mean by ‘rescaling’.

For any given product, we can find a number of ways to manufacture it. (A rubber ball can be fashioned by hand-kneading and rolling a bit of rubber, or by injection molding.) For each method of manufacture, we can separate costs into two buckets: setup and per-unit costs. (Hand-rolling balls has basically zero setup costs but pretty high unit costs, injection molding has high setup costs but quite a bit lower unit costs.) These costs mean that for any given product, there are a number of regimes, under each of which a particular manufacturing method is most economical.

So, at its simplest, the concept of rescaling the economies of scale means using the same ingenuity we use in devising those different methods of manufacture to improve upon the tools which are part of those methods, as well. We figured out how to make rubber balls cheaper by using injection molding, now let’s figure out how to make setting up molds for new products cheaper, too.

And of course, we do that. At least, whenever a production process is not completely vertically integrated, and the product is under competitive stress, then there are separate firms making tools for the process, and they are subject to competitive pressure to reduce their prices. The successful ball maker will seek and find cheaper alternative vendors for the mold making process.

So, not necessarily a radical idea, looked at that way. It might be a little more radical to say that my reason for wanting to rescale things is so that smaller producers are empowered to use more sophisticated production methods for smaller batches. To shrink the gap between the concepts of ‘prototype’ and ‘small production run’. To help bring the promise of mass customization to fruition. To allow more people to scratch their own itches. To give more little ideas a chance to come to life without having to appease the mighty powers of capital. OK, that last one is probably skirting radical, so I’ll stop there for now.

General

I am a magazine subscriber

I just subscribed to a new, paper, magazine (Circuit Cellar, if you wanna know). This is odd, because I don’t much like paper*, especially with ephemeral content like magazines.

But I think I know why I did. Paper magazines, after I’m ‘done reading’ them, become totems. Of what I was, or want to be, or want to do. But like any such totems, they can sorta disappear into the background of my perception after they’ve laid around the floor for a few days. Magazines, though, come again fresh every month, on someone else’s schedule. So I think I got the subscription mainly to help establish habits that I want to establish.

Or, whatever. I probably don’t actually know why I do things.

(* The fact that I have a couple thousand pounds of books does not contradict the assertion that I don’t much like paper. Deal with that as you must.)

General

AVR Raven

If you recently bought an AVR Raven, and you were horrified to discover that the AVR Wireless Studio includes USB drivers that only work in Windows XP SP2 and previous, it may help you to know that you can get better drivers installed by installing AVR Studio, after which you can return to AVR Wireless Studio to do something with your expensive little dev kit.

General

Product/inquiry

Here’s a nice example of how a product spurred an inquiry by a customer which results in interesting answers that excite the product designers and improve the product and design understanding of the whole community:
iCufflinks improved battery life code hacking….

Not that you were necessarily looking for that. I happened to be thinking about just this sort of thing a minute before I saw this post, so to me, it’s an answer to a question…

General

Work/stress

For a while I’ve thought that I needed to reduce the amount of work I do in order to be more satisfied. And I’ve got a pretty good setup in that regard, as I’m working well less than full-time and on my own schedule.

I think I need to point out that I don’t spend my time outside work just soaking in radiation on the couch. I wouldn’t have thought to mention it, except I heard that someone asked that when they heard about my workstyle. I guess I just assume that anyone who has found a way to free up their time would spend a lot of it reading, designing, walking, philosophizing …

So I guess my recent discovery that what I want is _more_ work, just less stress, is not a big revelation. It’s probably more a terminological shift than anything. Other ways to state my intention would be that I want less job and more work; stress without the distress; to get paid a little for the playing around that I do that some people would call work; to find ways to apply my lust for learning to applications that others can benefit from… something like that.

Which is why I have to start a company. Not yet gonna give up the current consulting gigs that give me a semi-steady income, because the last thing I want is to design a system for pushing my stress levels into the stratosphere, all the while knowing that I did it to myself, just because I have to generate significant income quickly. I’m going to develop my company in parallel with my consulting. I’m sure things will dovetail nicely as I progress.

I’m spending a little time seeking out people who seem to have similar ideas in mind for creating their best work. I’ll try to write up some of the conversations I have; just spoke to the owner of a small book store here in Ames and learned a few things…

General

MythTV, Ubuntu Natty, WinTV HVR-950Q analog, Mac Mini

This one took a while to figure out.

I bought a USB TV tuner, even though I have a perfectly good PCI one, because I want to replace my big loud server machine with an old Mac Mini refitted with some more storage and a new OS. Oh, I should tell the story of the Mac Mini first.

So, as mentioned above, I have a nice working server machine with (analog NTSC cable) DVR capability thanks to my WinTV HVR-1600 PCI card and the excellent work of the LinuxTV, MythTV, and IVTV people (and, surely, the credits could roll on forever, but I’ll be brief).

But it’s too noisy. I realized that the Mac Mini was quiet and could probably take on the various duties of my server machine, simple as they are, if only I had DVR. USB TV tuners must be as good as PCI ones these days, right? That’s true to a point: the HVR-950Q can record all the same stuff (NTSC, ATSC, ClearQAM, OTA/cable, etc.), but I didn’t realize until I bought it that it doesn’t do MPEG2 encoding on-board like the HVR-1600 does. Ah well, the little processor in the Mini (mid-2007 model with 1.83GHz Core 2 Duo) should be able to handle that.

So I pushed ahead: utilizing guides from around the internet, I popped the Mini open and gave it 4GB of RAM (collected from an old laptop) and a 500GB HD (which I had as a spare for a little RAID box that is currently unused because of _its_ fan noise, which is a story for another day). Along the way I had to replace the stupid connector for the HD temperature sensor that stupid broke because I inadvertently yanked the stupid wire out (thanks for your sacrifice, girlfriend’s old trash laptop!). Then I installed Ubuntu Natty server 64-bit on it, which was a convoluted process. But worthwhile, because now I have a nice, somewhat capable Linux server that’s quite small and quiet. I don’t care that much about being able to run OSX, though I can still do that if necessary by plugging the old drive into the box through USB, and, yeah, I’ll probably end up buying another OSX box some day for some reason, because I just have the sort of life that requires me to run a lot of OSs.

Anyway, now I have everything in line to do the DVR thang with my quiety hardware. A test run recording something with mencoder worked, and only used 40% of one CPU core, so the little processor can handle the video encoding well enough. But MythTV refused to work with the 950Q, and I’m _not_ going to give up all the goodness of MythTV and MythWeb.

Forum/blog posts by users and even a driver writer/all-around 950Q-debugging-all-star declared victory with this hardware; one even specifically mentioned a Mac Mini. The MythTV logs, even at maximum verbosity, failed to uncover the root cause (spoiler alert: the failure point in this case is not logged, even though similar failures around it are). Poring over more posts and more logs, trying out dozens of settings changes, playing with alternate encoders, reading through code, etc. added up to more hours than I really should have spent with this, especially since I was getting nowhere.

Finally I broke down and pulled out gdb to see if I could debug into the heart of this thing. Luckily, the Ubuntu packagers included a package with debug symbols, so I was able to do pretty decent source-level debugging without having to recompile (spoiler: yet). Turns out that somewhere around kernel version 2.6.38, the old V4L1 header was removed (deprecated, no doubt), which caused problems for the Ubuntu people in packaging MythTV. They worked out a patch to separate out the V4L1 functionality from the V4L2 stuff, but they didn’t get it quite right for my case. A little, crucial, function called SetFormatV4L2 was defined as a dummy returning false (failure), but the driver for the 950Q is a V4L2 thing, so the recorder quietly died every time, quietly (remember how I said this particular failure mode is not logged?).

This being the open-source world, I was able to mimic the ifdef patterns that the MythBuntu people had applied elsewhere, so as to get the SetFormatV4L2 and DoV4L2 functions defined properly while still being able to compile without the V4L1 header. And, woot, it all works now. I posted a bug report to the MythBuntu team, so hopefully that’ll get fixed upstream before the next update to libmythtv hits my box.

In any case, thanks once again to open source and the bazillion people who inadvertently cooperated to ensure that I can time-shift Soul Quest Overdrive. Because, in the end, that’s really what it’s all about, isn’t it?

General

Cross-cutting concerns

Oh, the cross-cutting concerns. Working on optimizing the amount of downloading clients have to live with when the big ol’ Flex app is updated. Need to compute the build dependencies of the SWFs. But one of the SWFs depends on a set of Python components on the server, the list of which can only be computed by running a complicated algorithm that imports a bunch of modules, performs some introspection on them, compiles lists of… Like I said, it’s complicated.

Do I live with this and split out the algorithm to compute the dependencies for me, or do I try to restructure the generation process so that the dependencies become simple again? Or do I skip the whole dependency-calculation thing and run at it from the other end?

Such are the problems of the Steven.