Two points in learning to program
I feel like there are two big, “pivotal” realizations in my story so far of learning to program. While I’m sure not everyone moves from Haskell to Shen to R to Python before really feeling competent in a language, I have seen many peers grapple with them.
1. Separate your code and data. I think this would be more aptly stated as Think Abstractly, but that belies the immediacy that the first statement provides. Usually, you learn programming languages in order to do something very specific. I need to do X and that’d be infeasible in a GUI. I need to automate Y. So, it’s easy to think of your code as something tied directly to your data. But, the power of reuse and potability comes from constructing code that is has both “could do” and “can do.” That is to say, good code strikes a balance between turing tarpit and cruft for a code hoarder. Learning when and how to be abstract (and what abstractions from data are useful or are not) is a critical part of learning to program.
2. Code IS data. This is second for many reasons, and not in the least because all dichotomies between code and data start to get tricky quickly. Metaprogramming is important, and functional concepts are critical to higher-level programming, but you probably shouldn’t start out python workshops talking about decorators. However, once you start being able to generate code procedurally, the centrality of Separate your Code and Data becomes very clear: you want enough abstraction between code and data to make it easy to deploy the smallest amount of code over the largest amount of data.
While I could bore you with many stories about how my first experiences in Haskell made learning point 1 in Python very frustrating, I can tell you that my experiences in Haskell and Shen made learning point 2 in Python super nice. Python’s simplicity is, in many cases, it’s greatest strength. Splatting and decorators, as well as a few changes in python 3, make it even easier to manipulate pieces of code as arbitrary structures. And that, I think, is critical to learning to program.
imported from: yetanothergeographer