From SLangTNG



Keep it simple!

Students and engineers without good C++ knowledge have to use (and extend) the Lua and C++ API. Keep it simple!

  • Use C++ templates only where necessary, for example for private functions.
  • Never use C++ templates visible to SWIG.
  • If you want to create a super highend module with all C++ goodness and tricks, then you should provide a second module which is wrapping the complex API to a simple API for SWIG and us users/developers.

Keep it fast!

Always have in mind which algorithm creates temporary objects and which one takes too much operations, which method is crucial to be fast (to be called often), which one is not crucial (not called often).

  • Do not allow "short cut methods" for Lua users which are inefficient.
  • Inefficient things should be done by the Lua user such that he is aware of (for example: Quick appending of rows in tmath.Matrix is not allowed through the index operator, but by external functions - because appending rows is much slower than appending columns)
  • When using linear algebra, use Eigen objects directly whenever possible (our operators have builtin error checks and do not make use of expression templates):
    • Eigen::MatrixXd in favour of tmath::Matrix
    • tmath::Matrix.Base::operator*(x) in favour of tmath::Matrix*(x)

Hierarchical programming

Try to develop as modular as possible. Try to design the software architecture in two levels:

  1. break down any data structure to its most simple elements and give each elements its data and algorithms.
  2. glue all the small pieces together in a separate data structure to create the "black box" algorithm.

Document API

Information for users
Personal tools