Credit: Golodenkov / iStock (via Getty)
Why Scientists Still Need to Learn Coding in the Age of AI
Just a few years ago, learning to code as a wet-lab clinician-scientist was frustrating. I would stare at a blinking cursor, search jargon-filled forums for clues about why a script had crashed, and spend hours looking for missing commas and mismatched parentheses. For scientists who bridge experimental observation and computational analysis, the barriers to entry were extremely high.
The arrival of advanced large language models (LLMs) and autonomous artificial-intelligence agents has changed the landscape. AI models can now build complex computational pipelines that might otherwise require days or weeks of troubleshooting. They can also generate statistical analyses and bespoke data visualizations within seconds.
So why learn to code?
In my opinion, the answer is still a resounding “yes” — but the way we learn must change. The bottleneck is no longer memorizing coding grammar and syntax. Instead, scientists must learn how to guide AI tools effectively, evaluate their results and refine them to answer scientific questions.
In many ways, early-career scientists are stepping into roles historically assigned to senior software engineers: overseeing, critiquing and improving work produced by automated assistants.
Here are four practical principles for using AI to support scientific coding while keeping analyses robust, reproducible and secure.
1. Think like a systems architect
When we began using AI for coding, we worried that the skills we had developed would quickly disappear. I had spent years learning how to combine datasets, generate numbers and perform statistical analyses. Using AI felt like cheating, even though the answers to many of my problems were already available online and the LLM was simply finding them faster.
Eventually, I realized that I did not need to remember the exact syntax for running hierarchical-clustering algorithms or creating pivot tables with Python’s pandas library, a collection of tools for data analysis. What mattered was knowing that these methods exist, understanding how they work and recognizing when they are appropriate.
Documentation remains useful for learning what different functions can do. But AI reduces the need to remember precisely how to make each function work.
By thinking like a systems architect, scientists can guide AI systems towards robust and reproducible solutions without becoming overwhelmed by syntactic details.
2. Build modular scientific pipelines
When an AI model can write hundreds of lines of code instantly, it is tempting to ask for one script that does everything: ingests raw data, cleans it, performs statistical analyses and produces a publication-ready figure.
That monolithic approach quickly proved weak and difficult to maintain. Troubleshooting one large script can become a nightmare. If a variable changes or an AI system hallucinates a step in the middle of an analysis, the entire pipeline can fail, leaving you to search through walls of code for the error.
Instead, we adopted modular programming. I asked the LLM to create small, discrete functions with a single purpose. One function ingests and formats raw data, another normalizes values, and a third generates a visual representation of the data.
Pipelines built from self-contained blocks are easier to debug than monolithic pipelines. If a transformation fails, you can isolate, investigate and fix the relevant function without putting the rest of the analysis at risk. Modular code can also be reused across projects, helping to build a personal library of reliable AI-generated tools.
3. Use a standardized data-science structure
AI makes it easier to write code, generate iterations and produce data outputs at speed. Inevitably, my project directory became an unnavigable collection of files with names such as analytics_final_v3_really_final.py.
During one project, I also discovered that I had accidentally overwritten a raw data file. Fortunately, I had a backup. The experience showed me the importance of organizing data-science projects properly.
Resources such as the Cookiecutter Data Science framework provide a structure for doing this.
In the AI era, using a consistent project framework is more than a coding best practice. It is an essential safeguard. A standardized structure separates input files, analysis scripts and outputs. In the Cookiecutter structure, raw primary data — such as sequence files and clinical spreadsheets — is kept in a strictly read-only folder. Active analysis scripts are stored separately, while outputs are collected in another location.
This separation reduces the risk that an AI-generated script will accidentally overwrite or corrupt the primary dataset.
4. Protect sensitive scientific and clinical data
Integrating AI into scientific workflows creates important ethical and regulatory risks. Public models may be trained using user input. If sensitive patient data is entered into a public, cloud-based LLM, that information could theoretically be exposed to another user elsewhere.
To reduce this risk, I learned to create dummy data. Before asking an AI system to write an analysis script, provide the column headers, expected data types — such as integer, string or floating-point — and the dimensions of the data table. Explicitly state that the real values will not be shared. See AI prompt examples for guidance.
You can then ask the model to write, test and debug the analysis code using a fictitious dataset that is structurally identical to the real one. Once the code works, copy it into a secure local environment and run it on the protected data.
This workflow keeps sensitive information away from the LLM while still allowing AI to assist with scientific programming.
AI changes what it means to learn coding
AI can generate complex code, statistical analyses and visualizations rapidly. But scientists still need coding knowledge to design sound workflows, choose appropriate methods, identify errors and protect the integrity of their data.
The goal is no longer to memorize every function or syntax rule. It is to understand the systems being built, break analyses into reliable components, organize projects consistently and use AI without compromising privacy or reproducibility.
Source: www.nature.com


