Samstag, 18. April 2020

Reconsidering C++

Last week I worked on zweidee framework, https://github.com/kerm1t/zweidee. This morning I joined LD46, aiming to use zweidee to start off quickly. Upon an initial idea, I started creating a procedural level generator. However I faced some problem calculating a distance between two points. It took me a bit to track this down. It turned out, subtraction of unsigned int variables led to wrong results. So I started to think, what is the good of unsigned at all?

This happens on a lean, quick building project. At work C(++) projects are magnitudes more complex, compile / build times are long and nagging. Data structures are chunked up heavily. Implementing, as well as debugging is orders more tedious. Since some time it bothers me, to simplify. Why use unmaintainable build environments, overloaded frameworks and C/C++? Others are concerned, too: http://number-none.com/blow/https://www.youtube.com/watch?v=GC-0tCy4P1U&feature=emb_logo

Recently I started a small project using javscript and THREE.js, which was a breeze to implement: https://jsfiddle.net/kerm1t/5Lg1hxfb/. So what are he alternatives to C++? Rust maybe, or Pascal / Delphi, https://www.nerdherrschaft.com/en/delphi-pascal-development.html. Also Swift seems to be evaluated by Google as to replace python. https://tryolabs.com/blog/2020/04/02/swift-googles-bet-on-differentiable-programming/

Unity uses C#, which I never tried, since it is supposed to be a bloated Microsoft Language. Especially being interwoven with .NET. But then it was designed by Anders Hejlsberg, the Turbo Pascal originator and Borland Delphi Architect. Hey, isn't just the idea of Unity to get results fast? Wouldn't then C# just the right language?

C/C++ remains the language for low level coding. On a PC basis, however is seems reasonable to move away from it, as it over complicates debugging. Coming back to unsigned int, why is this needed at all. Meanwhile I found, that Google advises not to use unsigned. s. https://google.github.io/styleguide/cppguide.html
"You should not use the unsigned integer types such as uint32_t, unless there is a valid reason such as representing a bit pattern rather than a number"
Unsigned Arithmetic is error prone. Taking first steps I will consider Googles take on unsigned variables. https://www.learncpp.com/cpp-tutorial/unsigned-integers-and-why-to-avoid-them/