Debug in your head, not in the browser

As I continue to play with Pico-8 to make games, I’ve found myself in places where I can code but do not have access to the console so I can compile. The result has been to simply code “blind” and then patch up all the errors when I get home to compile.

The thing is, there aren’t many errors.

I don’t say that to toot my horn, I say that because I’ve found that the necessity of having to debug in my head has made me a better and more efficient coder. Amazing what you can learn by having to reread your own code over and over. Just like when playing the games on Pico-8, having to start over and over means you get really good.

It made me realize that we rely on our browser+console way too much. When I’m writing up a web site or app, I’ll throw down a few lines and then refresh the browser to check my work…even when it’s something trivial that I know is already correct. It’s not because I’m not confident, it’s because the ability to instantly debug is there — it’s almost like muscle memory at this point — type, save, refresh, repeat.

Just knowing that you can instantly test and debug lines of code as your write them makes you rely on that a bit too much. It’s an enabler. It might only take a couple seconds, but think about all the times you type+save+refresh throughout your day and add all that up. And think about how your brain is switching modes each of those steps…from creation mode to debug mode and back…it’s easy to come off the rails and not feel like you’re getting much done.

Writing tons of code and then debugging in bulk sounds dreadfully inefficient. But I honestly feel like doing so has resulted in faster results, less bugs and more personal satisfaction.

If nothing else, it makes you review your own code constantly, which means you learn the in’s and out’s very quickly. I’ve found you also pick up on new concepts and method faster because you’re always reviewing them in your head.

Habits are hard to break but I’m going to attempt to code blind more often. Just sit and write until it’s done, then load it up and patch the holes. If my theory holds true, there will be fewer and fewer holes every time…hopefully.