StackOverflow

StackOverflow (aka “SO”) is the best site on the net for asking and answering questions about programming. Not about the job of programming (there is another site in the same family) but specific problems in “how do I do this” in programming. One of the ways it became good and stays good is that when you ask or answer a question, other people can vote your question or answer up (or down) and you gain (or lose) “reputation” points. (In the early days of the site, I tried to get people to call them “XP” as we called experience points back when I played Dungeons and Dragons, but to no avail.) The points aren’t good for anything in the real world (except they’ve sent me a couple of free t-shirts because of my work there), but we geeks prize being ranked, and so getting more reputation is a desirable thing. Plus you get some more rights and privileges at certain XP levels.

Because I was active in the beta of SO, and it was in beta at a time when I was bored out of my mind at work, I have pretty high reputation. In the first year of the site, I was in the top 15 users, and I think I’m still in the top 150 or so. But when I look over my past contributions, I see a bit of a pattern – most of my points come from one of two types of responses: “Fastest Gun In the West” (FGITW), where I was the first person to answer a fairly trivial problem like “how do I count how many items in an array in perl” and “Crusty Old Guy Imparting His Wisdom To the Newbies” where I try to impart some of what I’ve learned in over 25 years of working in good places and bad places and places that leave you so bored you spend all your time on SO. There aren’t enough of my answers where I actually took some time and effort to research something, write some example code and test it, or generally did something that somebody else couldn’t have done just as well. And in a way, I feel like it’s almost too late to change that – there are so many people on SO answering questions that unless you have something really specific where you just solved a very difficult problem you were having on something very obscure, somebody else is going to have the same answer as you.

So these days I try to resist the urge to answer the FGITW type questions. Instead I’ll put a comment after the question, and I’ll wait for the first couple of answers and see if I have anything to add, either in comments on the answers or by directly editing them (one of the privileges of high XP I mentioned earlier). I don’t care if I get points for them any more, I don’t want points for those sorts of answers. The other thing I do a lot of on the site these days is “patrolling” – looking for spam, stupid questions, joke answers, and the like, and voting to close them, voting them down or flagging them as spam or abuse, etc. I have considered running for the position of community moderator a few times, but in the last couple of elections they’ve demanded that you have done certain things on the Meta site, and I hate that place.

But of course, now that I’m trying to resist the urge to get meaningless XP for FGITW, I feel like everybody should have had the same revelation at the same time as me, so I have to resist the urge to tell people off for doing the same thing. I was actually prompted to make this blog post because I looked at a question a few hours ago, recognized it as a FGITW type question, and when I waited for answers, discovered that the first two were people like me, with +50K in XP. Hey, idiots, we know you’re smart, how about letting somebody who needs some XP have those points and do something to improve the site! It seems so obvious now that I’ve had the epiphany.

Stupid Perl Tricks

I’m certainly delving into some depths of Perl I’ve never touched before.

I need to lookup a record in one table using a subclass of DBIx::SearchBuilder::Record, and depending on what it says in the “table_name” column, look up a record in one of several other tables, each one of which has its own subclass of DBIx::SearchBuilder::Record. And after some delving on the internet, I was amazed to find out you could put the class name in a variable when you “new” it. Unfortunately you still need to “eval” the require statement.

my $mainRec =
RTx::FooProject::Record::MainTable->new($cfHandle);
$mainRec->LoadById($main_id);

# Ok, here comes the tricky part. Try to get figure out the class name
# from the table name
my $table_name = $mainRec->table_name;
$table_name =~ s/^dsu/DSU/i;
$table_name = ucfirst($table_name);
$table_name =~ s/_([a-z])/uc($1)/eg;
$table_name =~ s/s$//;

my $subRec;
{
no strict 'refs';
my $fullClass = "RTx::FooProject::Record::$table_name";
eval "require $fullClass";
$subRec = $fullClass->new($cfHandle);
$subRec->LoadByCol("main_id", $mainRec->id);
$self->SubTableRec($subRec);
}

I literally threw my hands in the air in exultation when it worked. And then was rather painfully reminded of my recent shoulder surgery.

Another sleepless night

I was having trouble sleeping. I thought it was because I have a sort of “rubbed raw” feeling in my arm pit. I got the same thing last time – because I can’t lift the arm, my arm pit doesn’t dry out properly and so it rubs painfully. But then I realized there was a lot of light coming from my office. And so I went to have a look, and sure enough my Linux box had crashed, frozen on boot, and so therefore the screen saver wasn’t shutting down the monitors properly.

A few days ago I got a little overzealous in removing old kernels, and since then every time the update process has installed new stuff it’s given me a failure message about running lilo. (Yes, I still use lilo rather than grub because when I first installed this system you couldn’t use grub with a software raid and lvm2 – one of these days I’m going to have to reinstall just to correct that and a few other nagging problems)

I realized that if that was the cause of the problem, I was going to have to boot with a live or rescue CD and remount everything, chroot to it, and fix the lilo problems and run the lilo installer command. So the first thing I tried was downloading the “Ubuntu Rescue Remix”, burning a CD with it, and booting with it. I discovered the hard way that the “Rescue Remix” is a i686 kernel, which means I can’t chroot to my amd64 install and expect to run commands. Oops.

Next I started to download the latest Ubuntu CD. Chrome said I had 27 minutes remaining, so while I waited I dug out the previous Ubuntu CD, and booted with that. I had to “apt-get install lvm2” and “apt-get install mdadm”, but afterwards I was able to “mdadm –assemble” both software RAIDs, and mount the lvm2 partitions under /mnt. I chrooted to /mnt, and ran “lilo”. First problem was that the boot drive was specified using /dev/disk/by-id/…., which it didn’t like in the chroot environment, so I changed that to /dev/sda. Then it complained about the “Linux.old”, so I commented that out. With both of those changes made, lilo installed without any further errors, and when I rebooted everything came up fine.

I’m just manually restarting all my nightly backups which normally happen during the time the computer was down, and then I’m going to try to get an hour or two sleep.

Forth? Why Forth?

Had a dream last night, in which the programming language Forth played a big role. Which is a bit of a puzzlement because I’ve never learned to program in Forth. There was a time when Forth was tagged as the next big thing and every computer magazine had articles about it, but that was around the time when commercial software started advertising “written in C for speed” and an interpreted language like Forth didn’t have a chance. I believe Forth became the core of PostScript.

The first thing I remember from the dream is seeing two small computers with a wire connecting their ‘pin 1’s. Somebody asked the Forth guru why they were connected, and I said “I know that, it’s so their clocks are in sync” and I said something about events on rising edges. I have no idea what that’s about – I’ve never done anything that low level. Evidently my dream self has been taking electrical engineering courses.

Later I was talking to the guru in front of three real train tracks, and every time a train went by a single alphanumeric letter above the track lit up. I wonder if that is some dream reference to the famous Tech Model Railway Club, but I really only know about them from the Jargon File. I wonder if they used Forth?

Later the guru was showing me about ports to respond to external events and control things like lights and heat in a house. I distinctly remember a panel showing four room mates and an indicator of whether they were using Forth to control their thermostats or not.

Anyway, it seems odd to me to be dreaming about a programming language I’ve never used, and low level hardware stuff I’ve never done. Not sure if that’s a subconscious reflection of my recent surgery, or trying to do object oriented programming in Perl.

Perl and IDEs

From about 1987 to about 4 or 5 years ago, I did all my software development using vi (and later gvim), ctags, and all the Unix command line tools. But towards the end of my time at Kodak, I got the Eclipse religion, at least as far as doing Java. Sure, I dislike having to move my hands away from the keys to move the cursor around all the time, but the code completion, integrated debugging and all that other good stuff won me over. The ability to click on an existing method call and see the javadoc for the method and to hit F3 and be taken to the actual code was a game changer for me. So much better than ctags. But for non-Java, whether shell scripts at work or perl at home, I still relied on gvim and the other command line tools.

But I’m about to start a huge and long term perl project, a large part of which is trying to learn all I can about an existing open source code base. So I wanted to see if an IDE would give me an advantage in terms of moving around the code I’m trying to learn. I installed the EPIC plugin for Eclipse, and also a dedicated perl IDE called “Padre”, and noodled around on both, and so far I’m forced to conclude that neither of them are as useful in perl as Eclipse is in Java. The biggest missing feature seems to be that F3 gets me the wrong function or method declaration most of the time. I don’t know why, possibly the typing system in perl is too weak for the sort of analysis and introspection that Eclipse does in Java.

So I think I’m going to be back to doing gvim and ctags and find and grep and perldoc and all the other fun stuff.