Pteros  2.0
Molecular modeling library for human beings!
Design thoughts

The very first version vertion of pteros was written in Fortran 90 in 2007.

I was programming in Fortran for many years and this language is great for scientific computing because of its unbeatable speed and excellent array facilities, which allow the programmer to think in terms of vectors and matrices instead of pointers and indexes. However, when it comes to complex data structures the Fortran becomes a nightmare. Molecular modeling is inherently object-oriented, while Fortran is not. Attempts to simulate the object-oriented design look ugly and complicates the code to the extent, when it becomes impossible to maintain. The first version of Pteros was abandoned because of these complications.

In the quest for good object-oriented language I was really impressed by D, however it is so purely supported that this is unfortunately not an option now for widely used library. Java an Python were ruled out because of their slow performance. So, I remained with old familiar C++. Well, familiar for somebody, but not for me. I had no experience with C++ before the start of Pteros development, so I had to learn. In my humble opinion this is a blessing rather than curse because resulting code will be immediately understandable for inexperienced C++ programmer (and most of the researchers are inexperienced programmers regardless of the programming language).

The first decision for scientific programming in C++ is the choice of the vector and matrix library. Pteros uses excellent Eigen library for all numerical vectors and matrices. In my opinion this library is the best thing, which happened in scientific computing in recent years.

Pteros is written in standard C++ at the highest possible level. This means that there is no low-level C-like code except the cases when this is absolutely required (like IO of complex binary file formats or optimized numerical code). The STL is used extensively everywhere for building complex data structures. All strings are std::string, not a char*. The use of STL iterators is limited to the cases where it simplifies the things. In general the code is as self-documented as possible.

The most complex part of Pteros (so far) is the selection parser. Initially it is implemented using boost::spirit parser generator library. Boost::spirit is an amazing bit of software, which is reasonably simple (to the extent to which expression parser could be simple) when used as a black box. Unfortunately, the compilation speed for boost::spirit is so slow, that it became unbearable. The recursive-descent parser in its present form is implemented by hand.

Pteros is designed to be very intuitive to use and to extend. C++ is not the most intuitive programming language, but most of its complexity comes from its much abused backward compatibility with C. Modern C++ can be almost as high-level and expressive as popular scripting languages if certain simple rules are respected. In Pteros only high-level language constructs are used. The code is very clean and well documented.