In Part I of this blog series we introduced you to our project CSM: Continuous Symmetry Measure. If you missed it, you can catch up here. Here in Part II, we’ll begin to explain the programming decisions we made, including the rationale behind our decision to switch the coding language from C++ to Python. If you’ve read our popular blog post, What’s the Best Language for Academic Software you already know the answer.

Our company follows the philosophy of legendary Stanford University professor, and author of “The Art of Computer Programming,” Donald Knuth:

“Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.”

C++ code is a lower-level language than Python. As a lower-level language, it has finer control available over exactly how the program works, which makes it possible to write much faster code. But being a lower-level language also makes it harder for a person to read and maintain. C++ code is more complicated, lengthier, harder to understand and easier to introduce bugs into.

In the case of CSM, Python had another, critical advantage over C++ that made us decide it was worthwhile to do the switch. Python syntax supports an easy implementation of something called a generator, a kind of function which makes creating permutations enormously more simple and efficient. The C++ code for creating generators was lengthy, complex, and fragile, easy to break with even minor changes. Because creating permutations was the central core of the CSM program, we knew making the switch to Python was justified.

But converting an entire program to another language is no small task…

Coming in Part III – The Python Switch

Leave a Comment