Afraid of code? Don’t be

A student approached me over email recently, wondering if I was proposing any master thesis projects he could work on. In his mail, he’d left a disclaimer that he wasn’t a good programmer. I assumed it was one of those cases where the student was indeed capable, but decided to be modest about his abilities.

When we met, I walked him through the problems I was working on and explained a handful of potential master thesis topics I’d sliced out of this space that he could give a shot.

Even though he had no prior experience in distributed systems or the cloud computing arena, I felt he was able to comprehend me quite well, asking rather intelligent questions along the way. Around 15 minutes into our discussion, he asked me what it would entail to go about these projects.

I answered with something along the lines of: “Profiling a bunch of systems, and of course, reading and modifying the source code of at least one of them.”

The student seemed rather discomforted by my response. He immediately reiterated  that he’s not a very good programmer, and that if the project involved a lot of coding, he won’t be able to deliver on time. At this point, I pulled out my Obi-Wan hat and explained to him that being comfortable with programming is inevitable, especially considering the fact that he will be awarded a masters degree in Computer Science once he completes his thesis. I could tell that he wanted to be good at this, but was afraid of not being able to match up to the challenge.

This got me thinking. Haven’t we all been here before? What did we do to overcome our fear of code?

So here’s my personal take on overcoming this fear.

You need to start somewhere

Cliché yes? Yet, it seems to be lost on a lot of students.

See your first major programming task, be it a thesis project, a course project, your first job, or even a self-planned weekend project, as a rite of passage.

Writing software is an art. And as with any kind of art form, it takes sweat and discipline to be good at it.

There’s only so much you can learn through reading books, going through tutorials and solving exercises that will serve as a substitute for actual experience. More often than not in your career, you’ll end up having to read, modify, or maintain code that others have written. The sooner you’re exposed to the innards of dealing with such a situation, the better. So start somewhere!

The first time’s the hardest

Let’s say your project involves building atop an existing code-base (open-source or otherwise). How do you tame the beast?

It’s often as simple as:

  • Acquiring the pre-requisite domain knowledge
  • Identifying the exact components you need to deal with
  • Hacking away

Acquiring necessary domain knowledge

Of course, before you can hack on a piece of code, you need to have some sense of what the code should be doing. It’s practically impossible to dive into a large code-base without any context whatsoever and manage to understand what’s going on. For instance, attempting to hack a Linux WiFi driver without having any clue of what the WiFi MAC/PHY functions are would be an exercise in masochism. If, however, you knew the concerned protocols, things will make more sense to you.

And guess what? You already have or will have to build up this domain knowledge anyway, like when you’re about to embark on a masters thesis.

Identifying the components you need to deal with

A mature open-source project is usually accompanied with really good developer documentation, which will have important information about the code’s architecture and some hints about the the key code paths.

Make a pass through the documentation and have a look at the source tree of the project. The directory hierarchy is usually quite revealing of the code structure. Also, grep through the source files for  keywords pertaining to the components you’re looking for.

Soon enough, you’ll be able to identify the subset of source files you’ll need to tamper with.

Hacking away

I usually begin by instrumenting the code with simple logging statements to get an idea of what’s happening under the hood. Now start introducing your modifications little by little. Re-run the code to see if your modifications work. If possible, use a debugger and stack traces to understand what code paths are being taken internally. Rinse and repeat till you’re done.

With enough time and effort, you should eventually tame the code.

Stand on the shoulders of giants

Key to any form of learning is to make diligent use of the experience of those who’ve traveled the same roads before you. In the programming world, reading code that others have written is an easy way to accomplish this. Better yet, try to contribute patches and have the experts themselves review your code for you. Bear in mind that you will make mistakes, but that’s part of the journey.

In my case, my first non-trivial code patch to an open-source project was this one. Notice how many mistakes I’m making along the way, and how many iterations it took before the patch was finally committed (and how patient the maintainers were!).

Wrapping up

The path to become a better developer is exciting, deeply empowering, and incredibly humbling.

Of course, to experience all of that, it’s imperative that you gulp away all that self-doubt and embark on the path first. So don’t fear code.

In Soviet Russia, code fears you!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s