On learning to code

When I began grad school, I didn’t know a bit of code. I had never made a computer say “Hello, world” before.

I did know, though, that coding was really important, especially as sequencing got easier and easier. I intentionally chose a project that would force me to learn. The day I  joined my lab, my adviser handed me a book entitled Learning Python. I dove in and read lots about strings, lists, loops, and if statements. I could do small exercises. I was getting confident.

Then I actually needed to write code to analyze my own data, and I had no idea what to do. It was just like I had a read a textbook on a foreign language, then needed to write an essay without any further instruction. I knew some vocabulary and grammar, but I hadn’t quite figured out structure or how to put pieces together.

Thankfully, other people gave me some of their code to help me figure things out. It was like someone else gave me their essay in this foreign language and told me it was okay to copy it, then alter parts of it for my needs, and still call it my essay.

I have improved greatly over the past few years. I’ve also branched out a bit to learning Unix and R. I’ve still not taking any formal classes on coding beyond a short workshop, though, and I’m starting to realize I skipped over some fundamentals along the way. I know how to use while loops, but somehow I never figured out for loops. I hear dictionaries are pretty powerful. Now that I know some of what I’m doing, maybe I’ll go read that Python book again and learn more from it.

I feel like at this point I’ve tried learned from reading a text book and doing immersion learning, but the people I was immersed with speak with some idiosyncrasies. It certainly gets the message across, but perhaps not as elegantly as possible.

How about others? How have you learned to code? Any advice for how I can improve further?


4 thoughts on “On learning to code

  1. I love your essay in a foreign language analogy!
    I learned to code through classes in high school and college (mostly college), and then a bit more during projects in college and grad school–though maybe those have mostly involved understanding, using, altering, and sometimes debugging others’ code. My one piece of advice: I think it is very hard to learn coding unless you are using what you learn as you go. So if you’re learning just for the sake of general improvement (as opposed to for an immediate application), I recommend finding a book with coding exercises and making sure to actually do them. Also, there are apparently some college programming courses online you could work through if you wanted–I know Mike was doing this recently with a course that I actually took in person in undergrad!

  2. I first started learning how to code when I was real young and playing text-based multi-player games on the internet. The program I used let you make little triggers and macros for things (i.e. if the game told you your hero was hungry, you could make a trigger that commanded your hero to eat some ham). Because I got exposed to the way computers “did stuff” at such a young age, it was pretty easy for me to go on to pick up C++ in high school. Once I had that under my belt I could noodle my way through any other object-oriented programming language with relative ease.
    When I am trying to learn a new language, I do exercises on Project Euler* (and look at other people’s answers in the same language) to get a feel for how things are done traditionally. Reading other solutions is a great way to learn about unique aspects of languages that might make certain problems easier to solve.
    In my opinion, it is totally okay to write code in an idiosyncratic way if somebody/you can look at it 3 weeks later and understand what you were up to. To me, the most important thing (assuming the code works as intended) is that it is easy to understand whats happening by looking at it.
    * I just googled it to get a link, and Project Euler appears to be temporarily down 😦 It was a beloved programming resource so I’m sure it will be back up and/or forked shortly.

  3. This sounds a lot like my own experience, including the foreign language analogy!
    I did take a couple of introductory courses in Python when I was a senior in college. One of them was a pass/fail 1 credit CS course, and I found that really useful for giving me an idea of the scope of the language without putting a lot of pressure on me. It seems like a lot of larger universities offer these kinds of courses year-round!
    In terms of actually putting everything together, having a project I was invested in was key for me. It keeps you from losing motivation, and it forces you to you experiment. That, and having a few experienced programmers around who could help me troubleshoot and tell me things like “yeah, you can’t put a continue there” or “it’s much more efficient to do it this way”.
    If no one is available to help, http://stackoverflow.com/ has answers to tons of basic through advanced questions.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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