Older blog entries for pedro (starting at number 58)

Remedial Coding: Never. Assume. Anything.

I have friends who are great programmers, technologists, and scientists because they have a really remarkable clarity of thought and methodicity that translates well into programming. Programming is easy for them because they naturally structure problems the way programs are written. I'm not one of those people. My talents are more intuitive than analytical. I tend to think out loud. But that kind of approach can get you into trouble when you're doing a kernel project with a 20-minute compile-test cycle.

Writing code is like playing Operation. Anyone can do it. (Ok, 4 and up due to the choking hazard.) The question is, how many times are you going to get electrocuted in the process? Core dumps, compilers, stack traces, debuggers and print statements will shock you every time you make a mistake -- just like that buzzer and red light. But eventually, you'll get all the little bones out of the patient -- it just might be ugly along the way.

Anyway, in the past, my "fly by the seat of your pants" approach has made my programming a little like playing Operation while riding in the back of a truck. The process is painful, the end result can really be a mess, and it takes 10 times longer than it should. I try to be halfway methodical, but that just ends up being a waste of time. So, I'm trying to replace these sloppy habits with useful, meaningful structure.

My first hard-earned lesson is this: don't assume anything. You know how they say, "Don't assume, it makes an ass out of you and me?" Well, when you're programming, and you assume things, it only makes an ass out of you. I do this all the time though. I'll be writing some code, and I'll see a function named "does_stuff()" that gets called, and I'll think to myself "Oh, I know what that does." And then I spend an hour debugging my code before I think, "I guess I better figure out what that little function does..." I call these things "grey boxes". They're like black boxes, except less scary. You think you understand them, which gives you a comforting yet false sense of understanding.

I know what you're thinking. You tell me, "But does_stuff() could be doing anything! How can I know what it actually does?" Well, I'd like to remind you that it is a PROGRAM executing on a COMPUTER. Chances are, its behavior is totally deterministic. You could take half a day peppering your code with print statements until it narrates its behavior to you in the Queen's English, or you could take 5 minutes to actually look at the function. You'll probably learn something useful. Yes, sometimes it's not worth going down every rabbit hole until you understand the context surrounding it... but at some point, you will need to know what it's doing. Otherwise, you're betting the correctness of your program on something you assumed to be true. And the more code you write around grey boxes, the harder it will be for you to figure out later. You might even forget that you assumed things to begin with!

Assuming things is more pernicious than simply guessing about what does_stuff() does. It's not just functions that abstract away behavior. Function pointers, the meaning of variables, macros, goto labels, structures, methods -- in short anything that is not explicit or obvious -- could be playing games with your head. Functions snicker at programmers who naively assume things about their behavior. So do yourself a favor. Any time you hear the voice in your head say "I think that does/means X..." take 5 minutes and figure out what it ACTUALLY does. You'll thank yourself later.

Syndicated 2009-06-19 02:14:19 from (l)andscape: (a)lien

Jek Porkins == Max Eckhardt from Batman (1989)

Maybe everybody else knew this, but William Hootkins, who played Jek Porkins in Star Wars (the heavyset rebel pilot what gets blown up) is also the actor who played Max Eckhardt (the heavyset corrupt cop) in Tim Burton's Batman. I always knew that Eckhardt seemed super familiar, but I could never place him before.

Syndicated 2009-06-17 08:20:37 from (l)andscape: (a)lien

Superman is a Methodist

Here's an interesting page about the canonical religions of several super heroes. It includes a listing of the evidence from canonical media and a discussion of the issues, character details, and reader comments.

I particularly liked this quote from Doug TenNapel (creator of Earthworm Jim):

"Ask any person about what they think about God and you will get an amazing story. It won't just be any old story either, it will likely cut straight to the core of who that person is. It's so bizarre to me that this most personal, dramatic, amazing story device is getting pressure to be removed by story-telling industries... including the supposedly progressive comics industry.

The fact that Superman was born and raised in Kansas by conservative farmers yet he never even talks about the Bible stinks to high hell to me. It's idiotic and it ends up making these characters less human instead of more. Superman has exactly dick to do with any "Smallville" I've ever been to. This is why I actually LOVED the Red Son Superman so much; they finally gave us a contrast of what would happen if Superman didn't carry Kansas in his worldview. More of this! Less of draining worldviews and philosophies out of comics! Especially worldviews that are considered "anti-comic" like certain conservative ones.

It is the pulp nature of comics that makes it such an incredibly powerful medium. I don't think you could get funding to make a Red Son Superman movie with a 250-million-dollar budget, but you could do a limited-run book series to explore a philosophy... no harm done."

Syndicated 2009-06-15 17:29:34 from (l)andscape: (a)lien

numbers separated by a letter?

So, I was changing my account password with an online finance site, and they had many rules for the new password. Most of them made obvious sense ("You can't use your username in the password"). But one of the rules was "You can't have numbers separated by a letter." So "asdf7hjkl" is OK, but "asd6f7hjkl" isn't. Does anyone have any idea why? The only thing I can think of is that they're trying to make it harder to enter hexadecimal values or character escapes into the form. Any ideas?

Syndicated 2009-06-09 03:45:35 from (l)andscape: (a)lien

en?tymology -- my two favorite things

I love both etymology and entymology.

Yesterday, I found this on the wall near our shower. It looked at first like a crack in the tile, or a dusty drip of caulking or spackle, which are numerous in our bathroom. But I took a closer look, and there was a little Alice In Wonderland-esque worm poking its head out of both ends of the case, which looked like a dirty pumpkin seed. Unbelievable! Turns out it is the larvae of a Case Making (or alternatively Bearing) Clothes Moth. I don't like the fact that we have clothing moths, but that thing was neat, if a little freaky.

Syndicated 2008-11-19 14:21:24 from (l)andscape: (a)lien

weird moments in the grocery store

So, I was at Ralph's the other day, and what came over the PA but the love theme from Bladerunner! That reminds me of the time that Mel, my late night cashier at Jewel in Chicago, said that sometimes in the middle of the night they play weird stuff like classical music and whatever because they think nobody's listening.

Syndicated 2008-10-23 16:43:40 from (l)andscape: (a)lien

masterpiece security theatre

This has been all over the Internet, but here's a great article about why the TSA screening, etc. is just designed to make you feel better and doesn't actually stop smart terrorists.

Syndicated 2008-10-17 14:56:54 from (l)andscape: (a)lien

i never should have written all those tank programs, or: life imitates art

This is an awesome story about some kids who wrote a "light cycles" program for an Apple IIgs. All was going well until the computer players decided to escape the game grid into system memory... (from clickolinko)

Syndicated 2008-10-10 00:18:06 from (l)andscape: (a)lien

750,000 jobs and 250 billion dollars?

I hate to parrot Slashdot, but this article from Ars Technica discusses the sources and legitimacy of the common figures used to support the further restriction and enforcement of copyright and other IP protections. It's a really good read.

In essence, the figures of 750,000 jobs and 250 billion dollars "lost to piracy" have been quoted and re-quoted for years in lobbying efforts, testimony, articles, and more in an effort to get tougher IP laws. Unfortunately, no one ever followed the breadcrumb trail back to the original source of the figures or did any simple reality testing of them until now... and the numbers don't really hold up to scrutiny. Do you like your government making laws based on flimsy statistics? I don't.

Syndicated 2008-10-09 21:28:25 from (l)andscape: (a)lien

49 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!