“I don’t have time to learn it.” We’ve all said it — some of us are still saying it. Many dream of being more data savvy, and so resolve to learn R (or Python, or C or whatever programming language is currently trending). But when it comes down to it, who has time to pick up an entirely new programming language from scratch?
Unfortunately, nothing written here will make you a coding whizz overnight, but most coders acknowledge that getting started is the hardest part. If you want to learn but don’t know how, here are a few tricks that have helped me.
1. Set goals that will immediately help your daily life. I’ve always been interested in programming. I know that being an experienced programmer will make a lot of things much easier. But no matter how good my intentions, I cannot will myself to spend all my spare time on self-improvement.
Instead, the things I’ve learnt have come about because I needed to get something done, fast. When I started preparing figures for publication, I learnt how to use ggplot2, a data-visualization package in R. When I needed to write a 200-page thesis, I learnt about the wonders of the LaTeX typesetting system. Command-line tools (for example, awk and sed) helped me to quickly manipulate large tables and text files. Jupyter notebooks allowed me to keep detailed notes and perform exploratory analysis by testing chunks of Python code. Compute clusters gave me the ability to run thousands of computationally intensive jobs in parallel. Instead of learning for the sake of it, you should set goals that will immediately prove useful.
2. Don’t try to learn everything at once. Likewise, don’t get intimidated by the prospect of learning a whole new language. You don’t need to learn all of R — you just need to know enough to complete the specific task that you’ve set yourself, and then the next one, and so on. You will find that the language’s syntax will get easier with time, and you can always refer to the reference material. The fastest way to learn is to jump straight in and start playing around.
3. Separate problems into achievable chunks. Programming is all about problem-solving. Think about what you want to achieve, and write down a series of steps that will get you to your goal. Then, all you need to do is work out each step and stitch them together. Your first solution doesn’t need to be elegant or all-encompassing; it just needs to work well enough for you to move on to the next step.
4. Don’t be afraid to break things. The quickest way to discover how something works is to break it and then try to fix it. Set up a workspace with test files, download some code snippets and try changing one line at a time. Print the output each time. Then, once it makes sense to you, try to write it in a different way, or using a different language.
Sometimes, you’ll break things you don’t want to break: we’ve all been there. Accidentally deleting all the files from an important folder is basically a rite of passage in some operating systems. It’s OK. You’ll make mistakes and learn from them. The worst mistakes tend to leave the biggest impressions, so you’ll probably never make them again.
5. Learn about version control. You want to make sure that your truly important files and scripts are backed up. That does not mean saving them with various titles and dates on unnamed USB drives. Version-control systems exist precisely so that you don’t have to worry about remembering every change you make to source code or documents. I’m a big fan of Git — because with five basic commands and no expert knowledge, I’ve been able to use it happily for years.
6. Ask other developers. I often think I’d be a better programmer if I didn’t have the global knowledge of the masses at my fingertips. But so far, I’ve never had a coding-related problem that I couldn’t eventually solve using online programming communities, such as Stack Overflow or Biostars. Most of the time, someone has already asked my exact question on an online forum.
7. Never repeat anything more than once. Good programmers are hard-working; great programmers are lazy. So lazy, in fact, that they refuse to repeat menial tasks. Need to rearrange columns in a spreadsheet? A computer can do that for you. Need to repeat an analysis and redo all your figures? An automated pipeline will have that done in no time. You might think it’s quicker to do it manually, especially because you don’t need to think about it or learn something new. And for a lot of things, that might be true. But the next time you repeat that same task, stop and think: do you want to do it a third time?
8. Schedule ‘learning time’ into your week. In my PhD lab, we had a Tuesday morning ritual. Between 9 a.m. and 10 a.m., we would practise programming in the Go language by working through problems on the Rosalind platform, designed for those learning bioinformatics. Afterwards, we would all have coffee. Anyone who skipped the hacking session had to buy coffee for everyone else. In this way, we worked together towards a common goal of becoming better programmers (and, inadvertently, caffeine addicts).
Since then, all of us have moved labs or countries. But such regular learning time has remained an essential part of my weekly routine. Each week, I set aside an hour to learn something new. Sometimes it’s how to use a new R package. Sometimes it’s a cool new software tool I’ve seen on Twitter and have been meaning to try. Sometimes I work in a group; sometimes it’s just me. No matter how busy I am, my learning time keeps me sane and ensures slow but steady progress.
9. Go to local workshops and meet-ups. Many universities and companies provide introductory workshops for common programming languages and techniques. These are often worth going to, even if you’re not a beginner: you’ll meet fellow coders and can bring your own questions to ask the demonstrators. A lot of scientists also get together to program, brunch and network, so be sure to check out your local Meetup groups.
10. Start today. If you’re reading this, you might already have learnt something new. If you want to learn more, here are some excellent resources to get you started.
• Codecademy: Good for learning the basics of widely used languages (for example, Python).
• R Tutorial: An introduction to common R-use cases.
• LinuxCommand.org: Great website on basic use of the command line.
• Coppola Lab Bioinformatics Training Resources: An incredibly comprehensive guide for all things bioinformatics.
• Explainshell.com: Useful website for learning shell commands.
• xkcd: A safe haven for when everything stops working.
This is an article from the Nature Careers Community, a place for Nature readers to share their professional experiences and advice. Guest posts are encouraged. You can get in touch with the editor at email@example.com.