Not getting lost in translations

Daniela Engert

60
intermediate
advanced
15:30-16:30, Thursday, 4th July 2024

Languages are difficult. Foreign languages even more so. This applies not only to people, but also to computers. Nevertheless, we must always try to find the most appropriate formulations that convey our intentions as clearly and comprehensibly as possible, regardless of the language in which we express ourselves.

As software developers, one of our tasks is to ensure intuitive operation - regardless of the language the user (or compiler!) understands best. Otherwise, the risk of errors increases and operational safety may no longer be guaranteed.

National language adaptations - possibly dynamically at runtime - appear to be a solved problem area. There are libraries for this. However, if you want to use them together with std::format or std::print, you will realise that none of them allow translation at runtime, because the format strings must be C++ literals! The compiler analyses these during program translation in order to detect errors in the use of formatting instructions and argument types. This is one of the main advantages of std/fmt formatting over the other options, which only detect errors during runtime!

I am currently developing a library for our company's machines that allows error detection at translation time, but still allows dynamic translation into the user's preferred language.

Human languages do not always follow immediately recognisable rules, e.g. when it comes to the correct choice of a linguistic form in connection with statements about several things. The Unicode Standard describes such rules in machine-readable form, which the library uses to provide the correct translation.

For the implementation of the library, it is crucial to convert known idioms from the programming of runtime code into semantically correct equivalent code for execution at translation time. Despite 'constexpr', some code looks unfamiliar at first when it is translated into the language of execution at compile time.

constexpr
templates

Daniela Engert

Daniela Engert

Daniela has a degree in electrical engineering and has been working for more than 35 years in small innovative companies in the field of software and hardware development. She has spent her youth with exploring the very first microprocessors since the late 70's, and has been creating software professionally for more than 40 years now. After a long time using many different programming languages, C++ has now been the exclusive workhorse throughout the last two decades. With great pleasure, Daniela is also a member of the ISO C++ committee.

For the better part of her career, the domain was applied digital signal processing (medicine, metrology, reconnaissance), but during the last decade the focus shifted onto special engineering in the field of industrial non-destructive testing of semi-finished and finished steel products, mostly using ultrasound. Besides that, she loves to relax with hard metal and soft cheese, hot curries and cool jazz."