Search code examples
c++c3dprogramming-languagesmathematical-optimization

a good companion for C/C++ in the 3D world?


I'm not really convinced about how C/C++ performs under certain circumstances, especially when it comes to keeping the approach to the math world simple and efficient, I don't know how to explain this since i have skilled my self on only other 2 languages: Python and Java ( and other languages for the www world like html, js, php, etc etc ... ) and they are all really different from C++ because the way they are designed.

What I don't like it's probably a mix between syntax and performances, for example C++ doesn't offer a support for matrices or vectors natively, all boils down to doubles and floats and you need to always keep an eye on what you are presuming you are doing because of the binary arithmetic that sometimes can give you unexpected results, and since your matrix it's not a primitive type it's treated like any other custom class without any particular optimization on the math, even if it's "math" and sometimes it can be optimized.

I will probably repeat myself but since C++ it's the only compiled languages that i know, that is right for some kind of performances, I can't really compare what it's offering to something else, but some aspects of the C++ world are cumbersome and not really shaped in a way that they can fit my needs, it's probably the best language to build an engine and the biggest part of my application, but i would appreciate some suggestions about what language can be the perfect companion in a 3D application and basically, an application with a lot of math.


Solution

  • I am not convinced about your line of thought.

    About the math part: Doing it with native C++ is cumbersome, I believe that. However, there are many libraries available that help you do your maths in a way that is efficient both in development and runtime performance.

    For example, have a look at the Eigen library. Eigen heavily uses templates and compiler optimization to get the most out of your maths. I have yet to find great optimization potential (well, you can always get a bit by using processor specific optimization such as BLAS, but that could be done using Eigen as well).

    I'm no expert on the 3D-part, though.

    No language offers all features that you might ever need on it's own. That is what libraries are for. You should be able to find a suitable library for most problems you will encounter in C++.

    About the syntactic difficulties: I do not know how far you have dug into C++. I learn something new every day - things that used to take me 10 lines of code when I started learning now can be done in one - without loosing performance or readability, on the contrary, usually gaining more clarity of the code. Thus: It is all about experience.