Remember how good you are

January 12th, 2010 Safe For Seneca

By Andrew Smith

I’ve been reading about literate programming, and was reminded that most programmers don’t write comments in their code. Whether to write them or not is a question that’s asked all the time, in all circles – starting in school and all the way to teams of masters of the known universe like Linus (who I’m assuming is responsible for this).

In school I thought comments are good. I’ve seen a few people who felt the same change their mind once they started writing real software, and I was tempted to drop it myself, but I didn’t.

I’ve had the same arguments with myself that you’re thinking of now. Should I document design, exceptions, explain what complicated code does, go over the assumptions, etc.? This post is not about that, it’s about something I’ve realised a few days ago – a thought that may be slightly original.

Writing comments in my code makes me feel good. I’m not a design freek and my code goes through a couple of iterations before it’s even checked into version control, often followed by more restructuring when flaws are found. And then I write comments.

I look over a piece of code and think – what the hell is this doing, here? Oh – that’s to handle the weird case of an idiot unplugging the USB stick before it’s done. Comment. Man this function is long and hard to read. Several comments throughout telling a story (this being possible explains why it’s all in one function). Wow, at this moment I can actually grasp how the entire subsystem works – comments on top of the class and every function. Why is this a member variable and not a local one? Oh yeah, I remember – that’s bizarre but it works. Comment.

Did I manage to explain it? As I read my code I remember all the interesting, strange, unfortunate, and neat things I’ve done. And I write it down in plain english. I feel empowered when I can explain something that appears to be a terrible mess. I think this is why I still do write comments. And I know they’re useful because when I go back to my code a month later I can actually figure out what’s where using them.

Maybe it will work for you too?

APNG is still alive

January 11th, 2010 Open Source, Safe For Seneca

By Andrew Smith

I’ve been running my more-or-less regular backup of littlesvr.ca, and found that yet again the online APNG assembler data directory is the one taking most of the time. Turns out that even though I cleared it a few months ago there is over 4GB of PNG files in there (half of that – 5800 APNG files).

That’s really interesting – it means APNG usage has actually grown in the last year. Partly that might be explained by ongoing support in Firefox, but surely that’s not the only explanation. I don’t know what’s really driving the growth. I just know it isn’t me.

On the one hand it’s great that people took over (e.g. Max Stepin has been diligently maintaining the APNG patch for well over a year now) but on the other hand it’s sad that the project survived without me – I guess I wasn’t that important :)

I have been feeling sad about such things lately. I always do my best to bootstrap a project and then pass it on to someone else to maintain. This way I can keep doing new and exciting things while expanding the breadth of my knowledge and skills, and increasing the impact I have overall. But damn it’s depressing when I’m in between projects. I feel useless – not wanted and not needed.

Should I just accept that there is only so much one can do in a lifetime, and specialise in some irrelevant field? Become normal? What a dreadful thought.

Oh my god, don’t use plural forms

November 17th, 2009 Open Source, Safe For Seneca

By Andrew Smith

There is a magic thing called gettext. It’s magic because it allows some random Joe on the internet with no experience in programming to translate your application into his language. He does this by editing a .po file, then sends it to you, and you just include that file in your build system.

Ok there is some plumbing you need to enable that, but really it’s worth it.

In one of my applications I followed the advice in the gettext manual and used plural forms for messages. That is rather than saying “%d file(s)” the string had two forms: “%d file” (if %d is 1) and “%d files” (if %d is not one). This is specified in the po file like so:

“Plural-Forms: nplurals=2; plural= n!=1;\n”

msgid “%d file”
msgid_plural “%d files”
msgstr[0] “”
msgstr[1] “”

But of course different languages have different singular/plural rules. For example in Russian 0, 1, 2, and 5 have different plural forms. That means the russian translator has to figure out how this whole system works in order to translate strings with plural forms.

These translators are volunteers. That they do it at all is amazing. Having them read the gettext manual (which doesn’t have a lot of examples like it should) is disrespectful and unproductive. You will get fewer translations of not-as-good quality if you use plural forms.

I know, I learned this the hard way. One of my programs uses plural forms and another doesn’t. I have spent way too much time explaining to people how this works, and I am sure some of them ignored what I said and just gave me whatever compiles.

And believe me figuring this out isn’t easy. I mentioned the russian example – honestly I have no idea what the rules are exactly (who ever thinks of these things?) and I speak russian, and I maintain the application. How can I ask Joe random to understand this?

There you go. Use plural forms at your own peril. The gettext manual lies, plural forms are not a good thing and the problems they cause are bigger than the one problem they solve. I have just got a new translation, and guess what – the two strings with plural forms are untranslated. So I have to get a headache explaining this yet again, while kicking myself in the head for buying into the gettext dogma.

So this is why they top-post

November 5th, 2009 Safe For Seneca, Uncategorized

By Andrew Smith

In newsgroups and many mailing lists top-posting (putting your reply above the text you’re replying to) is a big no-no. You’ll get flamed even if what you say is very useful, constructive, and nice. I’ve never quite understood the zealotry, but I figured: whatever, it sort of makes sense – someone says something, and then you reply to it.

But in regular email I have noticed many, many people write their reply at the top of the message. Until recently I had no idea why.

Last week I got a Blackberry. It’s a nice device, but it has a really small screen compared to a computer. When you open an email on a smartphone, you want to read what matters (the reply in most cases) right away. Scrolling to where the reply begins is painful and very time consuming.

Hm, I nearly posted something educational rather than inflamatory on my blog.. Now if I can just find a way to write blog posts from my Blackberry I may actually post more than once per month. And don’t give me that retarded Twitter crap.

Easy but impossible way to get rid of spam

October 14th, 2009 Safe For Seneca, Uncategorized

By Andrew Smith

I’ve been pondering how one may be able to get rid of spam. Not just what comes into my mailbox, but most spam everywhere. And I found such a simple solution it’s amazing I haven’t heard of it before. But of course it will never happen, so that probably explains it.

Spammers rely on that sending even extremely large volumes of spam is nearly free. It takes some effort to find a nice relay and/or create a small botnet, but following that every message a spammer sends is free. I don’t have the statistics handy, but the ‘positive’ response to spam is something like one for every hundred thousand messages sent.

Now imagine it cost five cents to deliver an email. That means to send 100k of messages the spammer would have to pay 5000$, which would make the business not feasible. How easy a solution is that!

And yeah, I know – gmail filters all the spam for you, and the wrong infrastructure is there, and some people would actually mind paying 5 cents to send an email, but I think it’s a great idea anyway, even though it is unlikely to happen in this form in my lifetime.

Slackware 13 knows how I feel

September 15th, 2009 Open Source, Safe For Seneca

By Andrew Smith

Here’s a stupid post, it’s been a while. I’ve upgraded Slackware from 12.2 to 13.0 and now it is messing with me. Believe it or not the stupid thing knows when I’m annoyed and pisses me off even more. Here’s how it works:

Sometimes my pointer starts jumping all around the screen, for no good reason. That’s not entirely unexpected, I have a crappy wireless mouse – but sometimes it gets on my nerves. When it does the first thing I do is stop moving and breathing, to see if it moves on its own or it goes nutz. No, it doesn’t do anything when I freeze.

So I take it easy, and use the mouse for a few seconds normally – but then it starts messing with me again. I slam my hand on the table, put a firm hand on top of the mouse, and deliberatly move it down – and it’s like it dares me to slide it all the way off the table, the pointer keeps jerking back up. Repeat, same thing.

Hardware problem? I thought so too, and replaced the wireless USB mouse with a wired PS2 mouse. Same problem.

You’ll never guess what it was. Turns out Slackware 13 treats my Microsoft Sidewinder steering wheel as a mouse. So when I press the pedals, it moves the mouse. When I deliberatly move the mouse down I at the same time (without thinking) press the gas pedal, which moves the pointer back up. Great stuff :)

Stop giving out my email address you twats

July 29th, 2009 Uncategorized

By Andrew Smith

Some people don’t get this, and they’ll never read this blog post, and there are too many of them to contact individually, so this is just me complaining with no purpose.

When I give you my email address – I give you my address. I only give it to people because I have no desire to filter spam manually, and I have an even lesser desire to have automation delete important mail.

It’s ok if you share it with someone who would like to get in touch with me. It’s not ok to put it into any website that’s not a webmail. I recently got an invitation to facebook. Now facebook knows my address, and I have a feeling some place somewhere it publishes it, or it gives it out to third-party marketers. Or maybe facebook is unusually nice, but you get my point. Do you know what happens as soon as an email address is available in plain text on a public website? I get start getting spam, that’s what.

I have disposable addresses – asmithXX and I bounce the number whenever the ammount of spam becomes unbearable. It does happen. my asmith15 (which is published all over the net on mailing list archives and such) now gets 200 spam messages a day, I stopped reading it completely.

Why do you have to fuck up the one address that doesn’t have a number, the one address that cannot be changed unless I change my name? You insensitive pricks.

Yes no kidding – I feel strongly about this. But no, this isn’t the only thing bothering me right now. Expect another post once I figure out how I can express my dissapointment without giving out any details I would rather keep to myself.

KDE now GPL3 only, wants to scap my contribution?

June 9th, 2009 Open Source, Safe For Seneca

By Andrew Smith

I got an email from someone who appears to be helping KDE out with switching their licences. I guess at some point the guys decided that nothing in KDE shall be licenced GPLv2 only, and that’s the request I got – change the licence to “GPL2 or 3″ or “GPL2 or later”.

Here are a couple of links describing the process:

http://techbase.kde.org/Policies/Licensing_Policy
http://techbase.kde.org/Projects/KDE_Relicensing

I’m not surprised to see only people names listed on the second page, no project names. I wonder how much software KDE plans to scrap just because of some overly idealistic dudes with big beards decided the new GPL is much better and must be incompatible with the old GPL.

My piece of code in there is bkisofs – a library for reading and writing ISO files which is being used by Ark (the KDE archive manager). The integration was not my doing, I only helped – but the library itself is mine. KDE won’t explode the funcionality is removed from Ark.

I haven’t replied to the request yet. On the one hand I don’t care if it’s licenced GPL2 or 3, the changes I recall don’t affect this particular software. On the other hand – I am opposed to the GPL3 as a matter of principle, and I don’t like bending over or getting strong-armed into doing things with my volunteer time.

And if I allow this, that will count as a contribution to GPL3 zealotry.

I’ll go review the GPL3 some time in the next few days. If anyone still reads my blog and has ideas one way or the other – please share.

Niagara to Vaughan on a bike, at night

May 25th, 2009 Uncategorized

By Andrew Smith

Sunday was a nice day, and at about 17:00 I decided to go for a ride to Niagara. Everything went ok on the way there, things look nice in the spring. Got to go onto the hill that you can see south of the QEW, always wanted to do that.

Then it started to get dark. And before I know it some idiot turns left in front of me. Luckily he saw me in time and stopped turning, and I’ve slowed down enough so even if he didn’t stop I’d have been ok, but what the hell, is he blind?

A few seconds later I decided to check my headlight. Turned on the high-beam, nothing. Pulled over and sure enough the bulb is dead.

I’m 200km away from home, with not even enough cash for a motel room (and I have to go to work in the morning anyway), what do I do? I decide to try it – I rode home all the way, between 21:00 and midnight.

It didn’t take me long to decide that the QEW is the only way to go. It’s not that much faster than the smaller roads, but at least there aren’t any intersections, so I just had to watch the lane changes.

That turned out to be reasonably easy. Stayed in the middle lane most of the way – it was the slowest one so noone bothered to change into it, and I stayed behind other cars. It got a bit freaky at times where the QEW isn’t lit up – I could barely see the road.

In the end I got home with no incidents. Probably didn’t get pulled over because the cops couldn’t see me :)

Mad marking

February 15th, 2009 Open Source

By Andrew Smith

I’m marking the first assignment for the data structures and algorithms course. Two problems – a painful but well-defined majority element and the other a linked list. I’m reading this code and I’m getting a headache. I need to take a break every 30 minutes, it’s so hard.

The problem is I’m looking at the code and I know that it can’t possibly work. But it does. I try creating a scenario where it will fail as I expect it should, I fiddle with the memory arrangement on the stack, but the bloody things work anyway.

I know the right way to do it, but who says what I think is the right way really is? I’m not going to take marks off for thinking out of the box, even if that’s just evidence of not paying attention in class.

While it’s extremely unlikely that these weird ways to solve problems are any good in the real world, where other people have to read your code – I’ve read enough code in my life to know that whether it works is the ultimate quality metric, and readability is but an illusion.

Back to work.