Skip to main content
Astronomy and space

Astronomy and space

The code for better science: programming and astronomy

17 Dec 2015

In a recent survey of more than 1100 astronomers, almost half have received little or no software training, despite 90% writing at least some of their own code. Jon Cartwright reports on the latest programming-language trends and the call for basic programming training as standard

Rows of computer screens with users
Get with the programme Scientists can brush up on their coding skills at workshops like “SciCoder”. (Courtesy: Ivelina Momcheva)

Ivelina Momcheva finds she spends a lot of her time programming. Whether it is to analyse data or to produce figures for papers, she sits at her keyboard at Yale University in New Haven, US, writing line after line of code. Despite it being a major part of her job, however, she has never received any formal training in software development. “Once I started graduate school, I mostly taught myself,” she says. “I picked up a few recommended books, took some online classes and looked at code written by colleagues.”

Momcheva’s Yale colleague Erik Tollerud has a slightly different story. The son of a professor in computer science, he took a computing course as an undergraduate. With that background, he was better prepared than Momcheva – though perhaps not by much – for a life in modern astronomy. So are Momcheva and Tollerud typical of today’s astronomers – some trained a little in software development, others not at all? In December last year the pair attended the .Astronomy 6 (pronounced “dot astronomy”) conference in Chicago, US, where they found a lot of their fellow astronomers debating how software is used, and about the current levels of training. Seeing there was no consensus, the pair decided to find out for themselves by conducting an informal survey.

The results, based on responses from more than 1100 astronomers at all career levels, reveal just how ill-prepared astronomers are for what constitutes much of their working life. Some 90% of the respondents write at least some of their own software, according to the survey, yet fewer than one in 10 have received “substantial” training for it. About half said they have received “little” training, while 43% say they have had none at all (arXiv:1507.03989).

Momcheva and Tollerud, it turned out, were not in any way unrepresentative. “One of the points we wanted to make with the paper was that there is very little training for something that is a substantial portion of our jobs, and that is a problem,” says Momcheva. “We should consider it very seriously.”

The lack of training has caught the attention of others in the field, too. “It’s quite surprising that more than 40% of astronomers claim to have had no training in software development,” wrote theoretical astrophysicist Peter Coles of the University of Sussex in Brighton, UK, on his blog In the Dark. “We do try to embed that particular skill in graduate programmes nowadays, but it seems that doesn’t always work!”

On the job

Some might argue that a lack of training is not a problem. Scientists have always been quick to turn to computers to benefit their work, and there is a long history of them learning coding on the job without resorting to formal classes. Isn’t immersion like this actually the best way to learn, just as people learn a foreign language by living in its native country? Tollerud dismisses the comparison. “Despite the word ‘language’, the analogy is not so much learning a language as it is learning maths,” he says. “Maths is one of the fundamental underpinnings of science, but you would never say you can just pick up calculus and linear algebra as you go along.”

Even so, astronomers apparently have a good way of picking out what works for them, and what does not. Despite hundreds of programming languages in popular use, astronomers stick to just a trusted handful. Two-thirds of astronomers use Python, according to the survey, while 44% use IDL, 37% use C or C++ and 28% use Fortran. “Historically, a lot of scientific code was written in Fortran,” Tollerud explains. “And even though it’s now generally recognized as being more difficult to work with, it’s still used because it’s got decades and decades of astronomers’ brainpower embedded in it. They don’t want to change to something new.”

Tollerud admits, however, that languages such as Fortran, which are closer to actual machine code, can actually produce faster software. Jonathan McDowell, an astrophysicist at the Harvard–Smithsonian Center for Astrophysics in Cambridge, US, agrees. “Software engineers sometimes try and push us towards the latest greatest language that will be forgotten in 10 years,” says McDowell, who is leading software development for NASA’s Chandra X-ray Observatory. “Fortran may be a legacy language in the rest of the world but it’s a living one for us, and for a bunch of good reasons.”

Names of coding languages

Training needed

McDowell also shares Momcheva and Tollerud’s view that software training is inadequate. “A quick glance at [many astrophysicists’] code shows how deep the need is for some formal training,” he says. “Astronomer code is sloppy, tangled and often stuck in the styles of the 1960s.” He believes software courses ought to focus on the “simple stuff”: loops, subroutines, established coding styles, and so on. “Most astronomers only need the basic stuff, because they’re not trying to do anything super-fancy,” he explains. “A few do need fuller software-engineering training, [but] for those we probably only need to give them the basics and then point them in the right direction.”

Astronomer code is sloppy, tangled and often stuck in the styles of the 1960s

Momcheva believes the best time for would-be astronomers to learn programming is not at undergraduate level, as not all students will be planning to stay in academia, but as a graduate, because by that stage your path into research is more certain. Tollerud agrees that programming should be a “central” part of the graduate curriculum, although he notes that, in many US institutions, curricula are being shrunk to make way for research. Perhaps, he concludes, only those who have not had any prior training as an undergraduate should be required to take extra computer-science classes. “Personally, I think that might be the best way to do it – to give everyone the same fundamentals,” he says.

There are already ways for scientists to brush up on their programming skills, if they want to. In the US, astronomer Demitri Muna runs week-long “SciCoder” workshops on software development for astronomers. Internationally, the volunteer organization Software Carpentry runs two-day workshops for scientists of all disciplines.

Much of this, in fact, is an effort to take programming more seriously as a part of modern science – not just to make the software better, but to give proper credit to all those who create it. “There is less recognition of software as being a thing that is critical for doing the science as there is [for] actual instrumentation,” says Tollerud. “Even though, in modern astronomy, it is.”

Back to Astronomy and space Astronomy and space
Copyright © 2025 by IOP Publishing Ltd and individual contributors