Archive for the ‘Programming’ Category

robots make stupid mistakes exciting!

Thursday, October 23rd, 2008

I don’t write much here about work/school, but I thought I’d share a little anecdote to give all of you a taste of how I spend my days.

Dividing by zero is a common mistake in programming.  You’ve got some variable, and you forget to take into account that it might sometimes be zero, and you try to divide something by it.  Often the result is “NaN” (not a number), and that result can get propagated through your program, causing something to break and not work like it’s supposed to.  In regular programming this is no big deal…if your program doesn’t work like you expect you start printing out the values of variables, you see “NaN” where you expected something like, say, 0.1, and then you track it back through the code to figure out where you’re dividing by zero and fix it.

But if the program is for controlling, say, the joints in a robot’s arm it gets a little more exciting.  Instead of your program just reporting a nonsensical result in a window on the screen, what happens is that instead of a slow, smooth movement like you expected, your $50,000 robot goes apeshit and flings its arm into some crazy pretzel shape as fast as the motors will go, and you have to leap up and hit the big red button that shuts everything down and hope that nothing was damaged.  That’s what happened to me yesterday.

O’Reilly Maker

Thursday, March 27th, 2008

Readers who are programmers are no doubt familiar with the ubiquitous O’Reilly books. Now you can make your own.

O’Reilly Grad School

Foster Follow-up

Saturday, March 15th, 2008

You know how I was excited about the Democrats winning IL-14, adding one more Democrat to the House? As it was put on dKos: This is why we work our asses off to elect Democrats: In his first day in the House, Foster provided the decisive vote allowing the Dems to pass the ethics bill that creates an independent oversight committee.

Also, less seriously: As I was aware but didn’t think to remark on until a friend linked on Facebook to this CNET blog article, Foster is possibly the first congressman who can code. In assembly. And Fortran and Visual Basic. He hacked get-out-the-vote software for Rep Patrick Murphy’s ‘06 campaign. Hooray for scientists and engineers in Congress!

why I don’t like Java

Friday, October 12th, 2007

So I’m preparing to write a program in Java for the first time in years, ’cause most of my students are using Java. No programming language (that I know of) is perfect, but after several years of Python there are some things about Java that bug me right off the bat:

  • no default values for parameters in methods. If you want to leave out an argument, you need to rewrite the whole method.
  • you have to have a class MyClass { public static void Main(String[] args) {} } to get anything done. Incidentally, this makes Java a terrible language to teach as a first programming language: it’s 3/4 of the way through the semester before students understand what all of that incantation means.
  • each class has to be in its own file, no matter how related it is to another class
  • its verbosity. I’m not sure just how much of this is due to convention rather than the language itself per se, but it just takes so many damn characters to do anything.

I’m sure there are good things about Java, too. There are arguments to be made for strong typing and explicit access control. But…