New Programmers: You Are Not Learning to Be an Encyclopedia, You Are Learning to Be a Detective

I think one of the biggest misconceptions that people coming into programming for the first time have is that they need to know everything. Learners think they need to know all of the functions or methods and how many arguments they take and what their output is, etc. There is this idea that being a programmer means having an encyclopedic knowledge of the language and tools that you’re using.

This could not be farther from the truth. When you learn to code, you are not learning to be an encyclopedia. You are learning to be a detective. The most important thing for a programmer is not knowing how everything works, it’s knowing how to investigate. The important thing is being able to figure out how things work when you need them (or to figure out what’s going on in some part of your project, or where some error came from).

No one in the world knows how every part of Ruby works. No one needs to. The documentation will always be there. Perfect knowledge of Ruby is not important, and isn’t nearly as valuable as the ability to tinker with a particular piece of code to figure out what’s going on with it.

I recently helped a student figure out what the Ruby Array#zip method does. I didn’t remember myself, so I did what I would do if I were on my own: I opened up irb, made a couple of arrays, and called the zip method with them.

irb(main):016:0> array_1 = [1,2,3,4]
=> [1, 2, 3, 4]
irb(main):017:0> array_2 = ['a','b','c','d']
=> ["a", "b", "c", "d"]
irb(main):018:0> array_1.zip(array_2)
=> [[1, "a"], [2, "b"], [3, "c"], [4, "d"]]

Seeing the output, that was all we needed to do to understand it, and that reflex of immediately opening up a console and fiddling has served me better than any amount of memorization ever could. I didn’t need to know what zip did immediately, it took all of 15 seconds to figure it out.

When code gets even more complicated, this instinct becomes even more important. This fiddling is vital when learning specialized libraries like Nokogiri, for example, or when debugging complex applications whose code flow is not obvious. You’ll never know how everything works. There’s too much to know and it changes too fast. What you need to learn how to do, more than anything else, is to investigate; to fiddle until things make sense. That’s all.