An image that shows chemistry coding

When I started my chemistry undergraduate degree, a computer programming course wasn’t a requirement, so most students didn’t take one. Instead, my colleagues and I relied on coursework software applications that required quantitative analysis. And although we could have deviated from software tools and written code for our calculations, we were unfamiliar with computer programming; it wasn’t one of the skills our chemistry toolkit included. Performing data analysis with my lab partners late into the night had to fix spreadsheet errors, not debug code. But if we had programming experience like our fellow students studying physics or engineering, we could have handled laboratory data more effectively and performed quantitative analysis.

In graduate school, some students wrote code for their research – it became essential for my PhD in theoretical chemistry. Still, it was limited to those in highly quantitative fields, mainly physical and analytical chemistry. My colleagues’ experiences as students were like mine. No one had completed programming training, and those who now wrote code for their research were self-taught.

My PhD supervisor helped me program by recommending a programming language and offering informal assignments. Through this approach, I’ve learned to code with a goal in mind and have found resources to address problems as needed, rather than aimlessly learning a language. After some practice, I gained confidence in my ability to write code that would produce reasonable results (at least after debugging) and switched to another language for my research.

Automated solutions

I realized that all PhD students could benefit from using code, not just a few subjects. Everyone must at least extract data from files and perform analysis. It was certainly possible to complete these tasks without code. Still, many were cumbersome (especially if repeated over 5-6 years) and could have been automated.

Chemistry, like all sciences, is becoming more and more digital. Electronic laboratory notebooks and databases of chemical properties are examples of digital tools for chemistry. Digitization enables progress by making information more accessible and promoting more transparent data handling practices. And while many digital tools don’t require coding, digitization can be more win-win as chemists learn to write code. For example, information from digital chemical properties databases is extracted more efficiently with code that captures the results according to user-defined criteria than with a manual search. Likewise, accessing laboratory data is easier with digital records and code than with handwritten notebooks.

As digital tools become more prevalent in chemistry, coding can help maximize their usefulness. And while many universities are adapting their degrees to include computer programming as part of the chemistry curriculum, those who have already graduated should also consider adding code learning to their chemistry toolkit. This isn’t as difficult as it sounds, because chemists already have the reasoning and problem-solving skills necessary to become effective programmers.

Off-the-shelf software may not be enough to address unique research problems. The same goes for standard laboratory equipment. In the latter case, chemists are adept at preparing atypical solutions to laboratory challenges. Writing code similarly enables chemists to create custom solutions that go beyond the capabilities of software tools. So if chemists are willing to build custom devices, why are you shy away from writing code?


If you want to try coding, first choose a simple task and write down how you did it. Then choose a programming language and download everything needed to run your code. Consult the learning resources to help you write code for each step of the process (see box); Then run the code and make sure it gives accurate results.

Since learning to program is challenging at first, choosing a frequently repeated task ensures that the time invested in writing the code is well worth it. Sorting a data set to extract and display a smaller portion is an example of a suitable task, especially when performed on a routine basis. The steps involved can include reading data stored in files, finding data that matches a criterion, and generating a chart. In addition, writing code in a widely used language makes it easier to communicate with others and increases the chances of finding a friendly colleague to help them. Hopefully, after following the steps above, you can complete a task that would normally take several minutes (or more) in a fraction of that time.

Adding programming skills to the chemistry toolkit can enable chemists to handle data and use digital resources more effectively. Chemists can learn the basics and write code for their routine work without formal training – I hope you try it out.

Learning aids

Code Academy (

Interactive coding tutorials in a number of programming languages. Work your way through a tutorial or check out the language-specific cheat sheets.

WITH OpenCourseWare (

Introductory courses in programming at university level with video lectures, scripts and assignments.

Overflow of packets (

A question-and-answer website for programming. Ask your own question or view questions / answers on related topics.

Language-specific documentation pages

These usually provide detailed information on language-specific topics with examples.


Please enter your comment!
Please enter your name here