\page cs_dg_programming_languages Programming languages
[TOC]
The code_saturne tool is written mostly in C++, but was only recently converted from C, so most programming constructs encountered in the code will be Very similar to C rather than "modern" C++.
-
Functions with the same name but different arguments. This "syntaxic sugar" can allow handling variants of a function without requiring long and excessively verbose names.
-
Templated functions. Using templated types allows a single function for various data types, which allows for better code factoring.
-
Lambda functions. Lambda functions are an essential part of the
cs_dispatchmechanism used to handle local parallel constructs, and enabling generation of CPU and GPU execution from the same source code.
-
Class methods. Since most of code_saturne was only recently converted to C++, although many structures use an object-oriented approach, they are still only defined as C structures and do not (yet) use a C++ method syntax.
- For example, given a
cs_field_tstructure*f, we can calla = cs_field_get_key_double(f, k), but nota = f->get_key_double(k). - For the same reason, constructors and destructors are explicit.
- For example, given a
-
Inheritance. For the same reasons, code_saturne does do not currently use class inheritance. Class inheritance may be used in the future, though caution must be used with virtual methods, to avoid performance issues (i.e. these must be used only for high-level contructs and operations).
-
Exceptions. Actually, a few
try/catchexceptions handling examples may be found in the SYCL portions of the code, but exceptions must be avoided in performance-ciritical portions of the code (and were not available in C).