October 2008 Archives

Oct 26

On simple APIs

I wrote about my effort to learn sockets programming properly. For two weeks, every day, I wrote a simple socket server in C, from memory as much as possible.

It paid off this last week at work, when I finished a draft of a proxy server that sits between an existing server and a Flash client. A proxy is both a server and a client, so all my new skills were used, albeit in C# not C. The nice thing about sockets is that the API is fairly standard for all technologies - Unix and Windows have similar C API's, and all higher level languages simply wrap around them.

I'm so glad I learned the C first, since the standard API is lean. There are about 6 - 8 functions to learn to use.

Had I attacked this issue starting with C#, I'm certain I would have failed. The "user-friendly" wrappers contain a lot of distracting material. Furthermore, the MSDN documentation for class members always includes a program that does eight things, instead of being distilled down to the one thing I want to do.

So, here's to the distillation of problems down to their simplest atoms. I'll take bind(), accept(), and send() over SocketInformation, SocketInformationOptions, SocketFlags, and SocketOptionName any day.


Posted by Erik | Permanent link

Oct 19

Maker Faire 2008

How much fun is the Maker Faire? My 5-year-old had as much fun as I did, making it a perfect father-daughter geek outing.

I missed the Arduino talk, which is doubly-sad since I really need a kick in the pants to take mine out of the box and use it.


Robot carnage


Tesla coils play the "Dr. Who" theme. Inhaling the ozone in the top row, my kiddo said "It smells sweet, Daddy." Good girl.


Saying hi to R2-D2


Decorating a Day-of-the-Dead head


A self-amplifying art-bike adorned with music box players


The "Austin Bike Zoo" had its full menagerie


The rattlesnake bike


Posted by Erik | Permanent link

Oct 12

Writing portable apps under Gentoo

For a previous C project for work, I developed a Windows app on Linux. The clunky workflow:

  • Write the entire app in Linux, being careful to use only the C Standard Library.
  • Move the source onto a Windows box.
  • Using Eclipse,CDT, and MinGW, coerce a working build.
  • If cross-platform changes were needed, make the edits twice.

You can imagine this workflow is unsustainable for projects larger than my little console app. Fortunately, I'm now set up to do the whole shebang on my Gentoo box, using MinGW and Wine. Tonight, I've compiled and run a Windows-specific app completely from Linux.

Gentoo makes this setup easy, although it's probably a bigger production than it needs to be. I simply followed Gentoo's MinGW HOWTO to the letter, and had no issues.

By big production, I mean that instead of providing a quick-and-dirty Windows-specific solution, they've gone after the entire problem of cross-compiling for any architecture, with a single, enormous "CrossDev platform". One day, I'm sure I'll see the benefit of this framework. Among other things, it's meant to simplify the cross-compilation of dependencies (say, a UI library).

I haven't yet accomplished a full Autotools build that can compile a Linux or Windows app based on a configure script flag. It's high on my list, to be sure.

I'm completely stoked at the idea of compiling native apps for all major platforms. I don't want to be religious about portability. I just know that some programming problems aren't that hard if you plan the solution from the start.

Any cross-compiling devs out there? What experiences have you had?


Posted by Erik | Permanent link

Oct 05

Cruft and the joy of a New Install

I rebuild my machine once a year, with a fresh OS installation. I did this as a Windows user, and now under Linux too. Some reasons for this:

  • I like the performance of stripped down machine, and the "new car smell" of a clean box is a cheap thrill.
  • It's the only way I've found to solve the cruft problem.
  • Installing Gentoo is a great way to learn about OS bootstrapping, and kernel configuration.
  • I can put off real work for many hours.

To facilitate this vanity, I've got several partitions:

  • / on 10G
  • /usr on 10G
  • /home on 15G
  • 15G - temp or spare
  • 50G for data - code projects, movies, etc.

Installing a new Gentoo on the spare partition means that I can transiton asynchronously, with my old install still runnable until I'm comfortable "flipping the switch".

The problem of Cruft

No OS has solved the problem of Cruft buildup, and I'm not sure it's solvable. Cruft takes several forms:

  1. Package-managed software installed but no longer used.
  2. Package-managed software with side-by-side upgrades. Think of the JVM - I have to upgrade to 1.6, but now 1.4 and 1.5 are still on the disk.
  3. Software installed outside of the package-management system.
  4. User data (/home, /usr/src, etc)

Old software

Yes, software can be uninstalled, but is it really? If my package manager installs 10 library dependencies to a program, and then I uninstall the program, the 10 libraries remain. Gentoo provides a "dependency cleansing" command, but it carries enough warnings that I'm loathe to use it, and rightly so. What if it detects that a library isn't used, but really it's used by something I installed outside of the package manager? I've broken my software.

A new install removes all this uncertainty, and I get the latest version of everything too.

User data

Sure, I could go through every file in /home and evaluate its worth. But I won't. Treat that data like the stuff in your garage - box it up (an archive/reference partition), and after a year or so of not looking at it, haul it to the curb.

Feeling fresh

I haven't rebuilt my wife's Windows box for five years. Logging in, I'm haunted by a slow performance, a nearly full disk, and every programmer's dread - my old code! (If it doesn't hurt to look at your own five-year-old code, then you've stopped learning). Computing on that machine isn't, and couldn't be, enjoyable.

The final solution

Thanks for letting me rationalize the hours I spend re-inatalling my OS periodically. I look forward, in a month or so, to having a completely new machine, with nothing on it except what I use today. Remember to always keep a spare partition for just such an occasion.

I always get funny looks when I confess this compulsion. Are there others like me out there, who get off on a clean install? Please leave a commont, I'd like to hear your experiences.


Posted by Erik | Permanent link