Thatsa lotta beer!

The statute of limitations is up on this by now, I think…

Back in the day, several ne’er-do-well CS students were enrolled in a certain CS150/151 class/lab, taught by a certain D. Ray with a certain M. Ghose as a lab TA. As the legend goes, they were bored in lab one day (having finished the ridiculously easy assignment in a few minutes, but not being allowed to leave early). They got the idea to put into practice their newfound knowledge of unsigned long integers (32 bits of nonnegative goodness, on those machines) by writing a technological take on the age-old “bottles of beer” song known and loathed by school-bus-drivers everywhere.

The technological take was to make the computers “sing” the verses of “Four billion bottles of beer on the wall” by writing the verses out to a disk. The code looked something* like the following:

#include <stdio.h>
int main(){
   unsigned long long beernum;
   for(beernum=4000000000;beernum>0;beernum–){
      printf(“%llu bottle”,beernum);
      if(beernum!=1) printf(“s”);
      printf(” of beer on the wall,\n”);
      printf(“%llu bottle”,beernum);
      if(beernum!=1) printf(“s”);
      printf(” of beer,\n”);
      printf(“Take one down,\n”);
      printf(“Pass it around,\n”);
      printf(“%llu bottle”,beernum-1);
      if(beernum!=2) printf(“s”);
      printf(” of beer on the wall…\n\n”);
      }
   return(0); //Outta beer, outta here!
   }

They finished writing it, so the story goes, just before the lab period ended, and set it in motion, telling their friend in the next section that it might be a good idea to save his work. Apparently the sysadmins hadn’t heard of disk quotas, because the drives rapidly filled up with the verses of what had to be the world’s longest song. According to aforementioned friend, one of the sysadmins ran into the lab about halfway through the next section, asking for certain students by name.

The interesting thing is, Moore’s Law being what it is, while such files might not fit in a user’s disk quota, they probably wouldn’t crash the server, either; at about 124 bytes per verse, the “song” would take up about 496GB (depending on whose definition of a GB you use.) This would actually fit on the free space on my 1-TB drive on my workstation at home (MSRP of just under a hundred bucks.)

Moore’s Law rocks.

* OK, so this isn’t the original code by a long ways — but it gives the flavor. The original:

  • was written in Pascal, not C;
  • wrote to the disk instead of standard I/O, and
  • probably didn’t have the fancy “bottle” / “bottles” code
Posted in Coding, Humor, Nostalgia | 1 Comment

Linus Has Spoken

I was reading a recent article (“Real Men program in C”) recently, and came across a link in the comments to Linus Torvalds’ opinion on the whole C-vs-C++ thing. Let’s just say he doesn’t mince words. (This is an excerpt, but it captures the flavor of the original post.)

What Linus said.

C++ is a horrible language. It’s made more horrible by the fact that a lot of substandard programmers use it, to the point where it’s much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said “to piss you off”, but it’s actually true. I’ve come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn’t come and screw up any project I’m involved with.

C++ leads to really really bad design choices. You invariably start using the “nice” library features of the language like STL and Boost and other total and utter crap, that may “help” you program, but causes:

– infinite amounts of pain when they don’t work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it’s not even funny)

– inefficient abstracted programming models where two years down the road you notice that some abstraction wasn’t very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don’t screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don’t screw things up with any idiotic “object model” crap.

Posted in Coding, Humor | 1 Comment

Random Thought Of The Day

I wanna know:

Why does Windows’ Task Manager list the size of the “System Idle Process” as nonzero? Also, why is it different, on different computers? My desktop apparently takes 16K of memory to do absolutely nothing, while my laptop (memory hog that it apparently is) takes 28K to do just as much nothing-per-second.

Now, I know 16K or 28K is a drop in the bucket these days — my laptop has 2GB of memory and my desktop has 3GB* — but honestly, why should doing nothing be anything more than a line or two of assembly?

* Yeah, 3GB. Not only does the 32-bit version of WinXP not always play nicely with 4GB of memory, but Core i7 processors have three memory pipelines, rather than the more understandable two or four. (Maybe Intel decided they liked Google’s “Don’t be evil” and decided to go with “Don’t be normal” or something. I dunno.) At any rate, Core i7s like their memory in threes. Go figure.

Posted in Coding, Humor, System Administration | 1 Comment

A step in the right direction

Well, that would explain it…

The reason that the quadruped robot was doing the “funky chicken” instead of walking smoothly was mostly due to a major bug in the gait angle calculations. The angle of the leg is the sum of the “shoulder” and “knee” joint angles — but the angle commands to the knee servos weren’t taking the shoulder angles into account. This caused a really inefficient, jerking motion, rather than the relatively smooth gait that was intended.

Oops.

It’s fixed now (and has a new chassis and circuit board). The video shows it moving more-or-less in a straight line, but with a few modifications to the gait tables, it can turn, at least in shallow circles.

Next on the list:

  • Rubber tips for the feet
  • Improvements to the turning routines
  • Turn-in-place functionality
  • Reverse (basically, just run the gait tables in reverse order)
  • Wireless control
  • A second microcontroller to handle control and communications

Posted in Coding, Digital, PIC Microcontrollers, Robotics, SIGMA Walking Robot | 1 Comment