快猫短视频

Musical approach helps programmers catch bugs

Transforming computer code into music makes bugs hit the wrong note, allowing better checking of new software

Making music out of computer code is helping programmers to catch the bugs that can cause software to go awry.

Computer code is often prone to errors that are difficult to spot. In a long program, made perhaps of hundreds or thousands of lines of programming language code, it is possible for the writer to misjudge how the various elements of the software will work together.

So-called debugging software can iron this out, by letting people look at a graphical representation of a program. This helps find bugs by highlighting which parts of a program are communicating with others.

But the computer鈥檚 sound capabilities are ignored in debugging, says Paul Vickers at the University of Northumbria. 鈥淚t鈥檚 sitting there as a completely unused channel, while lots of effort is being put into visualisation tools.鈥

So Vickers and James Alty of Loughborough University developed a system that automatically converts computer program code written in Pascal into simple 鈥渕usic鈥.

Stephen Brewster, who specialises in programming theory at the University of Glasgow, believes the music may well help programmers verify code. 鈥淵our ears are extremely good at picking up temporal patterns,鈥 Brewster says. 鈥淪ometimes better than eyes.鈥

Wrong note

Vickers and Alty assigned particular musical phrases to different Pascal language constructs, such as conditional statements and loops. A synthesised chord, for example, represents conditional statements such as 鈥淚F TRUE鈥. A loop could have an ascending string of synthesised notes associated with it.

When different sections of code are put together, they should form a harmonious tune. But if a loop, for example, does not execute properly, the music would not ascend properly and the programmer should hear the error. Similarly, a duff statement would produce a different chord that would be immediately apparent.

Vickers tested the system on 22 computer science students at Loughborough University. They had to find errors in a buggy program by scrolling through the code. But some of them could hear a musical representation of the program at the same time.

Musical aptitude

Overall, those who 鈥渉eard鈥 the code identified more bugs. 鈥淲hen they heard the music, they found more bugs,鈥 says Vickers. 鈥淚t was statistically significant enough to indicate it is worth taking further.鈥 But it is unclear how much this may be due to the ability of each programmer, or their individual musical aptitude, so Vickers plans more tests.

Alan Blackwell at Cambridge University, an expert on the psychology of computer programming, believes 鈥渁uralisation鈥 of program code can assist with some forms of problem-solving activity. But he says further research is needed to see if it is any better than other representations.

Brewster hopes that future software development tools will include some simple sound abilities. 鈥淭here would be lots of interesting things people could find out about their programs, by listening to them as well as looking at them,鈥 he says.

More from 快猫短视频

Explore the latest news, articles and features