14
You Can Learn How to Code (and You Probably Should)
When our summer intern Daniel first joined our lab at Cold Spring Harbor Laboratory, he seemed terrified of MATLAB.
And I can’t blame him — encountering a programming language in the wild is intimidating, especially when you sign up for a summer research program and they ask you to declare upfront whether you’re computational or not. Daniel was categorically not.
Daniel signed up for a biological neuroscience lab, so he was a bit surprised when he encountered code in almost every aspect our work. We used it to collect raw data, present stimuli, and analyze gigabytes of output. Even labs that aren’t labeled as computational labs often employ code for one reason or another.
So, I encouraged him to give coding a shot. I borrowed a copy of MATLAB for Neuroscientists, gave him a fairly straightforward task to code, and let him loose. I wasn’t really sure how to train him, but I knew one thing for sure: He could learn how to code if he wanted to.
Learning how to code
Like many neuroscientists, I never had a formal coding education. I didn’t take any computer science courses — they were encouraged but not strictly necessary. I’m a pretty common-use case: About a third of trained neuroscientists learned to code in graduate school without formal training. There are many renowned researchers who still didn’t know how to code. In neuroscientist Kay Tye’s words, “Not learning to code is my biggest educational regret.”1
So, many people agree that you should learn how to code, but what exactly does that mean? And which language?
These days, you can pretty easily learn how to code online. There are various massive open online courses (MOOCs) that are free and will give you an entry-level understanding of various popular programming languages. Some of these are self-guided, others will begin and end with specific dates. One downside about self-guided courses is that it can be hard to keep yourself on a schedule. I’d highly recommend finding a friend who is also interested and setting a schedule that you agree on. Many short courses can be completed over a holiday break or over the summer.
Many people wonder: What language should I learn? In neuroscience, Python, MATLAB, and R are all very common. Python and R are both completely free with really great communities of people around them who share code. MATLAB costs quite a bit of money, so it is not favored by folks who want data and code to be shared.2 For my students, I usually recommend that they start with Python because, at the moment, it seems like the language that is gaining the most traction in neuroscience. For fields that consistently work with bigger statistical models, R is also very common. The best thing you can do is start somewhere, because learning a second coding language will be significantly easier than learning your first.
If you’re joining a lab, you’ll likely want to work in the same code environment, so that you can build off of others’ analysis pipelines. During graduate school, I learned to code by adopting my lab mate’s code for my own purposes. I was given a whole body of code to analyze my data, and I needed to change a little bit of it in order to answer the questions I was interested in. I spent a lot of time teaching myself how to code by reading and editing other code. It was a lot of trial and error, and a lot of Google searches. It wasn’t until my postdoc that I began to consider myself a person who is proficient at coding.
Convincing yourself you can code
Unfortunately, our society has built up a lot of ideas about what it means to be a math and science person, and this can stand in the way of people’s interest in coding. Let’s talk a bit more about what it means to be a coder.
We tend to lump mathematical and coding skillsets into one larger (STEM) identity: the person who flies through rows of multiplication problems in grade school, excels on quantitative sections of standardized tests, and eventually becomes a coder. However, not everyone in neuroscience research identifies as math-y. According to E.O. Wilson, “Many of the most successful scientists in the world today are mathematically no more than semiliterate.”3 In fact, many scientists have internalized the idea that they’re “not a math person,” a phrase that is loaded with deep-seated beliefs about how intellectual ability works.
Entering science with a math background doesn’t immediately make you a better scientist any more than it necessarily will make you a better coder. More complex computational approaches certainly benefit from advanced mathematics backgrounds, but math experience doesn’t mean you automatically know how to code. Still, because we so strongly associate math, coding, and computation, many folks assume that coding is not for them.
For the past two decades, Carol Dweck and colleagues have been developing a body of research that encourages educators and parents to reconsider the way that we teach children, especially in mathematics. If you ask students and educators to reflect on what makes people good at math, you’ll find that some believe more strongly in fixed or innate abilities, whereas others believe that intellectual abilities are malleable and can be learned. Dweck coined the terms fixed and growth mindsets to describe our implicit beliefs about intellectual ability.4 The punchline for math and science education is startling: Students with growth mindsets perform better over time (even in organic chemistry).5
The story for computer science is similar. Our beliefs about whether computational abilities are fixed or malleable impact our sense of belonging, how we respond to difficulties, and ultimately, our achievement. In the United States, we have strong cultural ideas about what it means to be a person who can code. These beliefs are misguided and, frankly, wrong.6
One more time for the people in the back: You can code
If you’re new to neuroscience research, know this: You can be (and may need to be) a neuroscientist who uses code, math, and statistics to study the brain. Coding is a skill, just like learning how to play a sport or an instrument. You might feel like you’re making more mistakes than other people — you’re not. When I first encountered a coding challenge in graduate school, I was greeted with rows and rows of blaring red error messages. Years later, I still get errors, but I furrow my brow much, much less.