Nice guys finish last

November 15th, 2008 Open Source

By Andrew Smith

Whomever didn’t know that already? But knowing a fact without understanding the causes or implications can be pretty useless. So here is a summary of my wonderings of the last couple of weeks. For me to remember and you to enjoy.

All of this year I’ve persistently worked on one thing and have signed up to another. As a result I was able to take some risks, not needing to worry about what I’ll be doing in the next two years of my life.

I’ve decided this Mr Nice Guy thing isn’t working, cracked some heads, and got what I wanted. And that got me thinking – what was the point of being nice to begin with?

Shyness is a curse, and I’ll get into that some other time, but I want to say here that the curse of shyness doesn’t compel one to be nice. In fact the pain caused by being shy can just as well be channeled into being evil.

So I took the opposite of what I am as a potential goal, and tried to define it. What is evil, fndamentally? I couldn’t come up with an answer. I talked to a smart guy who studied the topic in some detail, and he suggested everyone is evil, which I thought about and decided noone is evil. Evil is not a fundamental characteristic of a person, it’s just a poor means to describe something else.

So if I don’t want to be nice, and there is no such thing as evil, what options do I have? For now – it’s still a mystery. But the few social norms I was still abiding by flew out the window recently, so if you didn’t like me before – beware, I just got worse.

Lost in the sticks

October 12th, 2008 Open Source

By Andrew Smith

It’s getting cold. In a few weeks it will be way too cold to ride my Vulcan 500, so I’m trying to make use of it as much as I can before I have to put it into storage for a half a year. Now it’s 2 AM and I just came back from a bit of an adventure.

I went north (as I usually do when going on a joyride) at about 22:00. North of Major Mac it’s quite pretty. And at night it’s nice because there isn’t much traffic.

I went North on Jane, turned east on some little street, and eventually ended up on Yonge Street. So far everything was great, though it was cold in some places (it’s strange how much the temperature ranges).

Then I turned back. Yonge street was boring, so I figured I should go back on Bathurst or Dufferin. I turned west somewhere, and then south on Bathurst. At least at the time I thought that was south, now I don’t know any more.

After a few minutes (didn’t pay attention to the time) I saw a sign saying the road’s ending in 5km. I thought that was strange, but there’s a lot of construction going on, and I always wanted to ride on a ‘closed’ road, just because a bike can handle more than a cage. So went on.

Hardly a minute later the pavement was gone. And a couple minutes later, the road did end. And though I couldn’t see much in the dark, I had a strong feeling this wasn’t a costruction type of ending, it was permanently closed.

I thought damn, I guess better turn back now, but that didn’t feel right. So I got off the bike and looked around. Past the 1-meter tall bump at the end there was a path going downhill. Not paved, but it looked decently smooth.

I got the bike on top of the bump and shone the high beam down into there. The dirt path had some grass on it by the bottom, but I saw some house lights not so far in the distance, so I figured what the hell, it will be just a bit bumpy and then I’ll be back on a real road.

And I rolled down. Very quickly the path I went on dissapeared, or at least turned in the wrong direction – so I had to go on the grass. That wasn’t so bad, I thought at the time. Then it really went down hill. I held the front brake and the front wheel was locked, but the bike was accelerating anyway. I couldn’t take my foot off the ground to use the rear brake, cause I would have lost the balance.

That should have given me an idea of what’s about to happen, but I wasn’t thinking yet. At the bottom of the hill I found a house, the lights I saw from the top. And I realised I’m not on a road, I’m on private property. Most likely a farmer, cause I could see a plowed field next to the house.

And again I said what the hell, the bike will get dirty, but it should be able to handle the stress, and I really want to get off these people’s property right now, so I directed it straight into the field. In less than a second the bike was stuck. It can go pretty far in a second, I think it was about 3 meters. The plowed land is impossible for a cruiser to go on, it’s too heavy. I had to rock it back and forth, and that worked for about a meter, then I had to go push the bike backwards from the front, and that worked for about a meter, then I almost gave up cause it became so hard, but I put some heart into it and it came back out.

At this point I’m pretty freaked out. I’m within 20-30m of a house, with the motorcycle engine roaring, and the high beams turning this way and that. Just imagine how freaked out you would be if that happend in your back yard (remember, this is the middle of nowhere, no neighbours, not the type of place where you’d dare come out and face an unwelcome biker). So I decided to go back the way I came.

Big mistake. A cruiser is way too heavy to go up a steep hill covered with grass. I felt that and tried to go up at an angle, but eventually I had to turn all the way up, and the bike fell onto its left side. This was the first time I dropped the bike completely (since I bought it). I killed the engine, and started raising the bike. I’ve had to raise it half way once when I put it down with the stand up and that was easy, but this was really really hard. The bike wasn’t even horisontal, it was a bit upside down (I’m on a hill, remember?). So I tried this and that, and eventually just found the right angle and the right force to put it up.

Then, yes of course, it started rolling down the hill. Backwards. And the front brake didn’t work, just as it didn’t work earlier. But I managed to put my foot on the rear brake, and stopped it. Wooh.

Key, start, start, start? The engine wouldn’t start any more. God dammit. I was freaking out already, and this made it worse. What would I do, knock on these people’s front door at midnight and ask for help? I’d get the police in the best scenario, but more likely shot or stabbed (these are farmers, they must have guns).

Then I got an interesting idea – roll down hill in gear and start the bike as I’m doing that. And amazingly that worked. I was so relieved. In retrospect I think the gear wasn’t engaged so rolling downhill had nothing to do with it, but whatever.

Now I’m seriously worried, and very pissed. No more mister nice guy. I point the bike straight at the hill and go in full first. Yes, I was that stupid. It’s easy to say so in retrospect. When very cold, very tired, and worried to death your brain doesn’t work so well, trust me.

This time the bike fell on its right side. And trying to start it while in gear and rolling down hill didn’t work. Shit!

But now I noticed that the house I kept trying not to look at had 3 garage doors. Garage doors? Cars? Paved road? Yes indeed. So I rolled the bike all the way down the hill onto the road. At least now in the worst case I won’t need to leave the bike on its side in the grass.

Now I’m on a paved road, and reasonably sure that if the bike starts, I’ll be able to get out. That’s when I remembered that I smelled gas while lifting it the second time, and that reminded me of ‘flooded’, and how to deal with it. Key, clutch all the way in, full throttle, start. It started the first time like a charm.

I went towards the house first, found that was a dead end, and had the lights turned on on me (I think they were sensor-activated). Going to the other side I got out. I still had no idea where I was, but the way back home was straight-forward.

Now I’m wondering if I should figure out whose back yard I was in, and maybe call and apologise. I could maybe find it again. I’m guessing it was somewhere around Bathurst and Green La W, but that’s a really rough guess. I don’t think I’m going to bother.

But in the unlikely case that an inhabitant of the house reads this blog post, or someone who knows them does – I apologise. If I had any reason to believe that downhill was going into private property, I wouldn’t have even considered going there. And I must have messed up your lawn too. Mostly I hope I didn’t scare anybody, and for what it’s worth – I’m sorry if I did.

Open source projects can be full of it too

September 15th, 2008 Open Source, Safe For Seneca

By Andrew Smith

I work on the Canvas3D project, a Firefox extension. Actually I work on JavaScript that uses it, not the extension itself. So every now and then I need to download the thing, from addons.mozilla.org

And it’s bloody annoying. The addon is classified as ‘experimental’, which I assumed means that it’s not really ready for general use. For some reason addons on a.m.o. classified like this cannot be downloaded without logging in first.

I made an account once, and downloaded it with no trouble. That was quite a few months ago and I have long forgotten my credentials. Since then I’ve been using accounts from bugmenot, a great website for dealing with ‘register to download’ nonsense.

Last week none of the accounts from bugmenot worked on a.m.o. any more.

I even opened a bug, to try and get an explanation. That bug will end up (not unexpectedly) joining the thousands of other ignored bugs on bugzilla.

There are now two theories about why registration is required for experimental addons, one mine and one Gijs’s:

  1. Mozilla hired some marketing person who used to work for Microsoft, or some other nasty corporation, and that person feels that getting some more identity associated with users of the website can only be a good thing, and never mind that the users are getting pissed.
  2. Mozilla feels that the agreement users accept when registering somehow saves them from liability if the addon that gets downloaded screws the user up.

I don’t really know which one is more likely, each time I think of one of the possibilities it seems to be even more ridiculous than the other.

Mozilla has little use for that kind of marketing data, since selling it would destroy half its reputation, and as for the ‘agreement’ saving them from trouble, that’s pointless for so many reasons I won’t bother talking about it.

This is lame, and I am pissed. I’m gonna try and find some way to deal with the problem (probably just write down my credentials), but it’s a damned shame Mozilla is giving me this kind of bureaucratic, pointless trouble.

Why don’t people use version control?

July 24th, 2008 Safe For Seneca

By Andrew Smith

Ever since I read the subversion manual I’ve been really impressed with version control, and with subversion especially. Like any other student in CS I’ve had my fair share of “Where is the latest version of my assignment? Crap, it’s on my desktop at home and it’s due in two hours”. And subversion got rid of that problem for me.

A couple of times I did a 30-minute tutorial on subversion to a class of CS students. I did my best to emphasize how easy it is to use and how significant a problem it solves. I’m sure I convinced a few to use it, but not nearly as many as I should have.

I guess there are two significant reasons why students don’t bother with subversion:

1 – No time to learn it

Even though there are really just 5 commands one needs to know to make good use of it – it’s 5 commands the students don’t feel like learning.

One shouldn’t blame the poor students, they already have so much to learn, especially in the beginning of a program. They have to manage their time just like anybody else, and learning something that’s supposed to save them from trouble at some undefined point(s) in the future isn’t high on their list of priorities.

2 – No server

Most people aren’t as impressed as me with Linux servers and don’t have their own linux box they could use for a subversion server. And if they do they’re on Rogers or Bell and they’re not allowed to have a public server on that connection.

So even though the subversion server installation is possibly the easiest of any serious server, and creating a repository can be done in a 2-line shell script it’s really beyond the average student’s ability.

All this is quite unfortunate for many reasons, among them:

  • In the real world, unless a CS student ends up being a sysadmin or a webmaster – they’ll be required to know and use version control. The concepts of how version control works should be learned in school.
  • Graduate students work on years-long projects. Working on a piece of code for a year with no version control is wrong for so many reasons I won’t bother explaining it here.

I’m working on a solution for this problem. That’s all I’ll say for now (until I work out the logistics).

Excercise for the reader: figure out what I called this project (I registered the domain name as soon as I decided to take the project on).

An open letter to Susan Kadis

June 26th, 2008 Safe For Seneca

This is a letter I mailed to Suzan Kadis. She’s the MP for Thornhill, Ontario – where I live. It’s an issue I feel strongly about. You should write to your MP about bill C61 also – if your MP thinks their constituents don’t care, they won’t care either.

Verbatim copy follows.

26th June 2008

Mrs. Susan Kadis

House of Commons
Parliament Buildings
Ottawa, Ontario K1A 0A6

Dear Madam,

I am a constituent writing to you with concerns about Bill C61.

I am a software developer, and all changes in legislation regarding intellectual property affect me directly – not only as a consumer, but also as a creator. In the past years I have suffered from the rampant software piracy on the internet so please consider what I have to say in that context.

Firstly – the American-style legislation will do nothing to help creators get paid for their hard work. There is no evidence to suggest that in the USA (where they’ve had similar draconian laws for some years now) piracy is any less pervasive than it is in countries without such laws.

Secondly – I’ve heard one conservative MP say that downloading a song will not warrant a very large fine, but uploading a song will make the uploader liable for 20000$. This person is either lying or is completely ignorant about file sharing technologies used in this century. In most cases it is impossible to download a song without uploading it at the same time, thus the smaller limit to the fine will almost never apply.

Lastly – I have an ethical problem with such ridiculously large fines. As I said – I am a creator of digital goods, I don’t like when people make copies of my software with me seeing no extra revenue, but I refuse to ruin anyone’s life because of it. And if this bill passes – lives will be ruined, for example:

A person downloads 100 songs from the internet using some popular file sharing software. They get caught, refuse to settle, and the plaintiff’s lawyers pursue the maximum penalty – 20000$ per song. The person who downloaded 100 songs is now liable to pay two million dollars. The person has to sell their home, and spend 20 years of their life paying off the difference.

I urge you and all the Libreral party to oppose this bill. It is not based on Canadian values and does not serve Canadian content creators.

Yours truly,

Andrew Smith

83 Novella Road,
Concord, Ontario
L4K 5K6

The worst thing a browser can do

June 24th, 2008 Open Source, Safe For Seneca

By Andrew Smith

You know what is the worst thing that a web browser can do? I just learned what – lose bookmarks. Not just the favicons, not just the order, not even the URLs – lose all the bookmarks completely. This is what Firefox 3 did.

As part of the upgrade I made sure to recreate the profile (who knows what kinds of crap an upgrade might cause) so it was a fresh install. About a week later – my bookmarks are gone:

No bookmarks

In case you need a translation – that’s the bookmarks menu with no bookmarks in it.

So what do I do? I go to my profile folder, see a folder there called ‘bookmarkbackups’. Pretty quickly I figure out that this can be restored using the bookmarks manager. So I do that, and my bookmarks are back. I may have lost one or two new ones, but disaster has been averted.

Two days later, the same shit happens again. Only this time I was busy doing real work and didn’t bother to restore the bookmarks right away. I think that was a mistake.

It seems there’s some sort of rotation going on in ‘bookmarkbackups’, the kind of mindless rotation for any kind of backup – “Since you haven’t complained, I will assume that you like the bookmarks the way they are, I will delete the oldest backup and replace it with what I have now”. And guess what I end up with? That’s right, no backup.

There is a something in the backup folder called bookmarks-2008-06-23.json, but firefox won’t restore from it, claiming “Impossible de traiter le fichier de sauvegarde.” – that’s roughly “Corrupted backup file”. Great.

The story’s ending isn’t all bad. Just after the upgrade I got the urge to backup my profile folder, and I did. So my bookmarks are still recoverable. But I’ll be damned if I’m using Firefox 3.0 as my main browser again. Maybe this is just one little bug and they’ll fix it, but maybe not..

The sad thing is I’ve watched this movie before – a great product being lost because of a lack of resources. Seamonkey was killed, Thunderbird is getting killed, I wonder if Firefox for Linux is next.

The tale of a number of somethings

June 20th, 2008 Uncategorized

By Andrew Smith

Yesterday I wanted to find my MP to write to him/her about the conservative’s planed changes to copyright legislation. All I know about politics where I live is that my former MPP was an italian liberal and the current MPP is a conservative jew. Not much to go on, but at least I have an address, so how hard could it be to find out? Real hard. Let me tell you about the beginning of that journey.

I live on a very peculiar street corner – Dufferin and Rutherford. It’s peculiar because it’s not at all clear what city it’s in. It is right in between 3, or 4, or 5 cities, or towns, or municipalities, or regions whatever you call them.. Yes I’m actually not sure where I live. And the fact that I don’t know what a riding is, and how it’s mapped to the something that I live in makes things worse. Then what makes things even worse is that I’m not sure MPs and MPPs share the exact same regions or not.

Here’s what I thought I knew about this intersection (all roughly, with the Dufferin/Rutherford corner reference):

  • NNE – Richmond Hill
  • NW – Vaughan
  • N/S – Concord
  • NWW – Maple

To my annoyance the MPs and MPPs for Vaughan and Richmond Hill are liberals. Mind, I actually like that – but I know that my MPP is a conservative so I must be looking in the wrong place. Concord and Maple weren’t even in any of the tables I looked at.

Completely by mistake and almost out of desperation I looked at Thornhill. MP – liberal Susan Kadis, and she has a map of her riding on her website! What do you know, my corner of the intersection is in Thornhill. I had no idea, I thought Thornhill was way down on Steeles and east of Youge. Well I was half right – half of it is.

After that it was easy. I quickly found about my former, well liked and very experienced liberal MPP Maurizio Bevilacqua; and the current, new kid on the block conservative Peter Shurman. My search is over.

But honestly I still don’t know where I live. More than once I had my postal code resolve to Concord. I know that my garbage collection is managed by Vaughan, and I get the Vaughan local paper. Richmond Hill is so close I can’t honestly discount the possibility, and I often see Maple on maps when looking for where I live. Now Thornhill? If that’s where I lived for two years, how is it that I’ve never heard of or read about it? Lame.

I wish they’d just call the whole thing the Greater North York or something. That may sound vague but at least I’d know what it is.

How to open your spec but not lose to competitors

May 17th, 2008 Open Source, Safe For Seneca

By Andrew Smith

I’ve recently learned that Adobe has opened the Flash spec. Which, from an open source user’s point of view is really cool. But then I put on my competitor hat and started thinking of making a Flash editor.

I won’t bore you with the technical details, of which there are lots (and no it’s not likely I will actually go ahead with the project). These words are better spent on something else – the business case for opening the spec.

The swf_file_format_spec_v9.pdf file from Adobe’s site is a very detailed description of the file format, including things such as illustrations, notes and warnings, and version history (going waaay back). And the answer to my riddle is in the file name – see if you can spot it?

It’s absolutely brilliant.

No? Ok, I’ll tell you – it’s the v9. You see – 9 is the version of the player currently in use. It’s been released some 2 years ago. And 10 is coming out this summer I am led to believe.

What do you think Adobe has been doing to Flash for the last two years? You can be damn sure they didn’t put it on the shelf, and they’ve been developing it heavily. And I’m also sure SWF is not the kind of spec that’s developed before the implementation. Most likely in the last two years Adobe has been implementig as many features as they could, and this summer they will brand the result Flash 10, document it, and release the documentation.

Now think about it from a competitor’s point of view. Assuming you can’t develop software much faster than Adobe (which is very likely), and even though you don’t have to spend any time on research and other things related to developing a new spec: you will not be able to release a product that can be competitive with Flash for at least one year after a new version of Flash is released.

So considering that the release cycle is 2 years, you will have an inferior product 50% of the time, even if you do your very best.

This isn’t intended to be a rant against Adobe. Like I said at the start of the post – them opening the spec is great for users, and it’s great for open source developers (who can live happily with a 1 year feature lag).

It’s just that having thought of ways to be open yet stay competitive for a long time, I know how hard/impossible it is. I am very impressed with what Adobe’s doing. Good job!

Why managed code is slow

April 8th, 2008 Safe For Seneca

By Andrew Smith

I’ll pick on Java but this should apply to other languages too. I’m just afraid that due to circumstances beyond my controll I’ll end up writing Java code this year – that’s what got me thinking of this.

All Java applications I ever used (web or local) were dreadfully slow and used way too much memory. Yet any report I read about a performance benchmark of Java vs C claimed that it’s just as fast or faster. I dismissed those reports as written by fanboys and thus irrelevant, but always wondered – how do they pass all the benchmarks, yet feel so slow when I use them?

I think I figured it out, at least part of it. Let’s see if I can express it.

C programmers have a fundamental understanding of how much resources of what kind any given call uses. There is nothing between most system calls and the kernel that executes them, and there is only a driver (a.k.a. the kernel) between some system calls and the hardware.

I will probably never read the implementation of write() for any filesystem, but I think I understand what it does: call a function in the kernel, have the request queued up, if there is a cache look in it, move the hard disk head and read from the platter.

And having used it a thousand times I know how it performs in various circumstances. Small or large blocks vs number of repeated calls, in a loop, in a function, mixed with read()s, etc.

Look at the same scenario for Java. It’s bad enough that there are 25 classes with OutputStream in the name, but even something simple like java.io.OutputStream::write() – noone really knows how it works. Does that just pass the request the system call? Does it iterate through the array of bytes calling a function each time? Does it serialize the data?

When bringing these things up around Java fans, you get a response like:

  1. “that’s what’s great about Java, you don’t need to know, it just works”, or, less likely:
  2. “experienced Java developers learn that too in time”

There’s also denial, but for simplicity’s sake I’ll pretend those people don’t exist.

The first excuse is used in 80 percent of the cases, and is 80% responsible for the problem. If you write a line of code that’s a call to a most basic function provided by the programming language and you have no idea how it works, it’s impossible to optimise your code, you just have to trust the runtime to figure it out.

And then comes the experience. Say you do learn as much about java.io.OutputStream::write() as I have learned from experience about write(). What you know is at best 50% likely to apply to java.io.PipedOutputStream::write(), and 25% likely to apply to BufferedOutputStream::write(). Whereas my knowledge about write() will apply to any write() no matter what device, as long as I have a trivial understranding of how that device works.

That’s the rest of 20% of the problem – the belief that you can actually be experienced enough in Java to understand its inners as well as you could uderstand C. Noone has that kind of time! Perhaps some Java language developers, though being hired by an enterprise to create a product for the enterprise, I really doubt that even the implementers need to know. After all Sun and the like never made a secret out of this – safety over speed, ease over understanding; it’s just not a priority.

And to compound the problem – your call to java.io.OutputStream::write() is not guaranteed to work at the same speed on different versions of the runtime (remember it’s the runtime executing your code, not the hardware). So the same program could behave drastically differently on Java 1.4 and Java 5.

Yes you have a similar problem in C where performance depends on the implementation in the kernel (thus the kernel version), but with a runtime you have the kernel version problems and the runtime version problems on top – they don’t cancel each other out :)

One curious note – I have even less experience writing C# than writing Java, but from the user’s point of view C# doesn’t seem to have the same performance troubles. I do wonder why. It could be just better code optimised to death for the operating system, or it could just be that most of the libraries it uses are DLLs loaded by windows when it boots. That’s something else to think about.

Anyway – I’m not a C fanatic like the Java fanboys I mentioned. I will use a different language when it will do a better job. But one factor that’s almost universally important in software problems is performance, and Java will have a hard time scoring high on that scale.

To sleep with javascript

March 21st, 2008 Safe For Seneca

By Andrew Smith

All proper programming languages I can think of have a real simple function – sleep(). It suspends the execution of your program for a time. This is what I wanted to do. Having no choice but to use javascript in this case, I went around looking for what the sleep() function is called in this dreadful language.

Turns out there is none. There is only setTimeout() and setInterval(). Either will call a function after a time, but in between your code will continue to execute.

All I could find on the internet is a bunch of solutions to this problem involving an infinite loop. That, for I hope obvious reasons, was not acceptable for me.

I considered using `yield` but that doesn’t work for some reason in my version of the current firefox trunk. I did the javascript version thing, but then none of the javascript I had (yield or not) would work at all.

So I grumbled for a couple of hours and finally figured out a solution so my stuff still works as I want it, and all that’s lost is readability. I’ll share this beast with you all in case you ever run into the same problem.

This is what I wanted done in the first place, overly simplfied (lack of whitespace courtesy of wordpress):

function wish(i, j)
{
var k = i + j;

for(var m = 0; m < 10; m++)
{
// start doing something outside of my control

sleep(5000); // sleep for 5 seconds

// check the results of the something

alert(k + “, ” + m + results);
}
}

Like I said, it’s overly simplified. There’s no need to bring 3D and benchmarks into this example.

Since setInterval() is all I have to work with, that’s what I’ll use. The tricks to address my concerns are:

  1. Make a global function that will take the (i, j) parameters and have it call another function (real()) that doesn’t take any parameters
  2. Copy the parameters to wish() into glabal variables
  3. Where the sleep() would be have a setInterval(‘real()’, 5000) instead
  4. Copy all the local variables in real() to global variables before the setInterval()
  5. Add a condition so real() will know whether it should continue from where it left off or start from the beginning.

A lot of work, but the other option is to not do it at all.. Here’s what it now looks like:

var gI;
var gJ;

function wish(i, j)
{
gI = i;
gJ = j;
real();
}

var gK;
var gM = 0;
var didSleep = false;

function real()
{
if (didSleep)
{
// check the results of the something
alert(gK + “, ” + (gM – 1) + results);
}
else
{
gK = gI + gJ;
}

for(m = gM; m < 10; m++)
{
// start doing something outside of my control

gK = k;
gM = m + 1;
didSleep = true;
setInterval(“real()”, 5000);
return;
}
}

That’s pretty disgusting. I’d blame the people who came up with javascript if it wasn’t for the fact that javascript was never designed to be a proper language. Javascript was made for people one level above HTML, which is far, far from real programming and it served those people well.

Instead I blame the people responsible for the javascript hype. Both the fanboys who don’t know any better but their strength is in numbers; and the programmers who sell their time/ideas by proclaiming that AJAX is the only way to go. I even blame google a little for making the two useful javascript applications in the world.

I’ll say it again – disgusting.