Avatar

Jason Kinner

Vcard Download vCard   what is this?
Rss_icon

Recent Activity


Filter by:
All
  • Programming With Cursors is Evil

    Cursors seem like a great idea. A cursor, for my non-programming friends, is like running your finger through a book as you’re reading it. It helps you keep your place and navigate a set of data. Imagine you’re making a recipe. It is really nice to keep your place in the recipe while you add some eggs to the mixer, for example. It makes it easy to walk step by step through whatever you’re reading. Of course, most recipes consist of two sets of data to navigate: a list of ingredients and the set of steps required to combine the ingredients to make your delicious treat. Have you ever gotten to the end of a recipe and discovered you skipped an ingredient? This is only one way cursors can mess with your lovingly crafted program.

    Cursors become truly evil the same way so many programming metaphors become evil. By allowing you to write where the cursor is. Let’s reverse the metaphor for a second. Suppose you have a recipe that you’re changing based on how the cook actually performs the steps. Using your finger, you move step by step as the cook performs the existing steps in the recipe. When the cook does something different from the step you’re expecting, you make some room and insert the additional things he does. Sounds as easy as using a word processor, doesn’t it?

    The problem is that few computer programs are so simple. Suppose now the cook just starts doing the steps in a different order. It’s now a much more complex task to make sure you’re tracking the steps in the recipe. Now think of a computer program doing something similar. Even a reasonably good programmer makes mistakes. They’re called bugs, and every single piece of software I have ever encountered has them. In the real world, let’s say you get distracted while the cook does something differently and you don’t notice. It doesn’t matter for this analogy whether you missed him doing something you expect or if you missed a new step. Now you’re out of sync. There are only two possible outcomes: you become back in sync (in the real world you can talk it out with the cook) or you experience a hopeless cascade of failures. “Did you ever add the cinnamon?”

    The evil that cursors represent is when you try to correct the problem, which requires the discovery of that one step that pushes you out of sync. The program that uses the cursor relies on the cursor to hold the state of the data, but the cursor relies on the rest of the program (the logic) always to agree with that state. Because there is no explicit connection between the cursor and the program, if they start to diverge on the perception of reality, it can be extremely difficult to discover where the divergence starts (which, by the way, is the only way to fix a bug like this). A complex recipe has on the order of 50 steps. A computer program has millions. It’s not hard to see the potential impact. So the next time you use a cursor (or anything like it), keep these dangers in mind and program defensively against them. Here are some techniques I used:

    • Enable debugging (logging, really) of your cursor state. When you change, move, insert, delete, make sure there’s a way to make sure the cursor is at least in a valid state. Don’t do the debugging in production, though. Better yet, make a system property or environment variable control whether it’s enabled. If you can track operations on your cursor, consider keeping an expected state handy in debug mode. Enable it at all times inside your IDE. This will help you recognize a problem during your build-test cycle.
    • Make sure each block of code that manipulates the cursor or the underlying data is consistent within itself. Unit testing is a great way to accomplish this in an automated fashion. I’m a fan of unit testing, especially when it can save literally days of debugging.
    • If you end up encountering a synchronization issue, make creative use of your debugger. Conditional breakpoints, evaluating expressions during debug time, and (if your debugger has it) historical playback can be extremely valuable. I set a breakpoint when a known synchronization error occurred. In my case, the error only presented itself after a write was made, so this step alone told me only that the error happened before I hit the breakpoint. It sure was a good start, though. Don’t be afraid to have complex conditionals, either. You’re debugging, so use any horsepower you need. It beats stepping through the whole program line-by-line.
  • A Few Reasons E-Book Readers Suck

    I’m a casual video game player, but I’ve played a lot of games in my day. My first video arcade experience was at the Asteroids machine in the Stop-n-Go. After that game filled my body with adrenaline, it was all over for me. The prospect that I could control a whole ship that was able to blow up asteroids in space with just a dial and a button was magical. Later, playing more complex games like Ultima IV, I realized that there could be richer experiences that required a few more buttons. In college, I was introduced the the MUD (Multi-User Dungeon), which I never really got into. More recently, I started playing World of Warcraft, which I consider the most successful MUD in the world today. Along the way, I have played many console games from first-person shooters (Halo to Ghost Recon), platform games (Super Mario World to Mirror’s Edge, which is just fantastic for this genre), and, to a lesser extend, Real-Time Strategy (RTS) games (I love Pikmin in this genre). Along the way, I came to a startling conclusion:

    Games can be too realistic.

    At a certain point, games that increase in realism achieve a level of realism that… well, it makes them actually real. Real in the sense that all the real-life frustration you might experience in, say, infiltrating a heavily-defended building or training for the military. Let me put it this way: I would never play Halo if I had to go through 6 week of training in-game to qualify to play the game. Part of the magic of video gaming is that it lets people do things they would never have a chance (or the time, or even the physical ability) to do in real life.

    If you’re still with me, you’re probably wondering what any of this has to do with E-Book Readers. I recently came across an article on a dual-screen E-Book Reader that says it will be “awesome”. Why? What is so awesome about using 60 years of accumulated technology to emulate 500 year-old book technology? Isn’t this akin to emulating basic training in a first-person shooter video game? Sure, a certain segment of the population (read: geeks) get thrilled at the prospect of running the Commodore 64 on their iPhones, but is that really the right approach?

    When it comes to consuming long-form media on a high-tech device, what is needed is a new approach. Instead of emulating 8-bit technology, how about inventing a whole new 64-bit technology? In my life, audio books (in combination with the iPhone, a technology platform I always have with me) radically changed the way I enjoyed books. For one, it enabled me to read for pleasure again. I find that I’m very rarely in a situation where I can drag a book along with me, much less sit down and use my two hands and two eyes to actually read it. This new-fangled technology enables me to enjoy a book in a way the original author probably never intended. A first-person shooter video game is vastly more enjoyable than having actual terrorists actually shoot assault rifles at me. Likewise, an audio book is vastly more convenient than an actual pulp book.

    So I ask, what advantage does an E-Book Reader have over a paper book? In my case, it’s actually worse. I don’t mind if I lose a $4.95 paperback book. I can drop it, dogear it, write in it, drop it, kick it, rub sand on it, prop a door open with it, hit my friend over the head with it to get his attention… Nothing I would do with two A4-sized pieces of LCD glass (okay, maybe prop a door open with it).

    This whole e-book reader craze is destined to be relegated to history as a stop-gap technology to help folks who can’t or won’t adapt to new media technologies. In a few years, it should blow over after the “gee whiz” factor has passed by. Either that, or it will be adapted, like audio book technology, to a new, more fertile environment, and it will be another 15-year overnight success.

    Update: Fake Steve Jobs and students at Princeton apparently agree with me. Glad I could help.

    Update: FSJ almost quotes me: “There is no point in moving to digital readers if we’re just going to do what we did on paper.” Here’s hoping RSJ feels the same and actually comes out with a decent tablet.


  • Gaming twitter-based services

    When people talk about their “culture”, they often mean their ethnicity, their religion, or the region where they grew up. As a child of the Internet, Internet culture is my culture. One frustrating aspect of Internet culture is the propensity for people to game systems, exploiting the properties of one (or several) person’s (people’s) work to serve their own ends.

    When I was checking out DM Fail (because, yes, I do have to watch trains wreck), I was really taken aback by how quickly the “service” devolved to shameless self-promotion. Then I was taken back… back to a time when people wrote short messages to your console screen, normally when you were trying to get some “real work” done (read: playing a MUD; for the uninitiated, that’s like World of Warcraft without the 3D graphics, and it’s much more addictive than it sounds). Back to a time in the Golden Era of the Internet, when the console didn’t always know that your backspace key was meant to delete the character just before your cursor. Instead, it would helpfully print the character code (^H) of the key. Thus was born such tongue-in-cheek gems as:

    That new blog post is so boring^H^H^H^H^H^Hinteresting!

    Now that I understand that my culture is alive and well, I’d like to declare that, thanks to DM Fail, “dm” is the new “^H”. Enjoy!


  • Android FAILs Hey, Android... Where's the beef?
  • Futurama and the Art of Programming If you’re reading my blog and you haven’t seen Futurama, watch an episode. For anyone who hasn’t seen it, here’s a brief synopsis: Our hero, Phillip J. Fry, pizza delivery guy, is delivering a pizza on New Year’s Eve 1999 when he inadvertently gets frozen for 1,000 years. He awakens in the year 3,000 and [...]
  • A Few Reasons E-Book Readers Suck This whole e-book reader craze is destined to be relegated to history as a stop-gap technology to help folks who can't or won't adapt to new media technologies.
  • A Word on Star Trek’s (2009) Poor Prop Choices The new Star Trek has some of the grit of Battlestar Galactica (the best Sci Fi drama since Farscape, IMHO) while maintaining the wholesome goodness of the original series and movies. But there was a problem...
  • Correcting Red Eye Using Preview.app on OS X Leopard When iPhoto lets you down removing red-eye, there are options!
  • Internet Will Eventually Be Remote Controlled I worked on a project in 2002 to build a “rich media server” for HP. At that time, I realized that content delivery is essentially an asymmetric activity, where the “command and control” channel needs to be much smaller than the content delivery channel. This was the original philosophy of ISDN phone lines, too, except [...]
  • Value and Profit Value: Customers would miss you when you're gone; Profit: Customers are willing to pay you to make sure you won't be missed
  • Cost, Reward, and Adoption My son thinks World of Warcraft tunes its new classes to be attractive to players so they can populate the world quickly to achieve game balance. Is Google doing the same with Location services?
Next page