C++ has its niche in parallel high performance computing. But would it be a bad idea to start a new project in 2024 using C++ when Rust and Zig exists? I'm looking at machine learning and array processing as applications
Python is used in ML because it's not the slow Python that's doing the matrix multiplication (if you write it right), so if you're asking what to learn, I'd start with that to get a feel for the math involved before wading into the deep end of the pool with C++.
If I were starting a new project today, it would depend on the project and who I was doing it for as to the language I would use, but C++ would definitely be on the list.
C++ is extensively used in HPC and in the lower level aspects of machine learning. I dont know what you are trying to make so I cannot make a recommendation.
C++ has a lot of pain points that are being either tackled by the committee or the community. But those pain points still rear their ugly heads.
But majority of the code for HPC and ML is written in C++ or has its core written in C++. Leaving such a huge set of libraries is not an optimal decision if you want to deliver your code without having to yak shave everything.
Based on the number of companies who are trying to hire c++ developers the marked is shrinking (c++ devs are getting old).
I like the simplicity of C and not having for wait several minutes to rebuild a project. Have you thought if Python and Cython would be adequate for the task you want to solve?
having near instantaneous builds is easy to achieve in C++ [depending upon projects, this will not happen for llvm] to the point that even REPLs for C++ exist that are used for large scale physics data analysis at CERN.
Do you just want to pick it up as a learning opportunity, or are you trying to accomplish a goal? There’s probably ‘better’ (by better, I mean ‘easier’, in this context) langs (Python + numpy comes to mind) if your goal is to bang some ndarrays together and do ML-type stuff.
There’s gonna be a bit more headache at each step of the process (finding the right libraries, building your code, and learning the language) that might come easily to someone who uses it professionally or used it extensively in college.
That being said, I think learning C/C++ has value in A) the areas you mentioned where it’s used extensively (e.g. kernel, embedded, or HPC dev) and it’s a good lang to know if just to understand how computers work a bit better. This is purely ‘extra credit’ though IMO if you’re already a productive developer.
No. All the core libraries in HPC/Machine learnings have native C++ (or C) underneath. This will continue to be the case for at least another decade as the investment needed to rewrite is massive (FORTRAN still exists!). If you want to jump on trends about some vague/superfluous memory safety issues you have solved, then go ahead with the pain of writing in Rust and trying to make it interoperate with C/C++ libraries. Otherwise stick to C++.
Zig is a better language than Rust but it is even further behind in native support for the HPC/ML space.
Depends on what you need. Rust's machine-learning tooling isn't very advanced, but then again neither is C++ if you want high-level features. You might want to use neither, if you can get away with a simpler language like Python.
Between Rust and C++ I tend to pick Rust for better tooling and simpler control over LLVM. It's entirely up to you, but I wouldn't be caught dead running Valgrind on my multithreaded machine learning app.
It's not necessarily a bad idea as long as you apply modern C++ practices. If you're going to be poking around with raw pointers, you might want to use a safer language, but if you want to use things like std::shared_ptr, C++ can be quite safe while continuing to provide good performance.
Anything C++ 17 and above is golden. I personally use a few things from C++20/23 and rely a lot on carefully reading and trying to understand https://en.cppreference.com/w/ when it comes to anything I might not be familiar about.
You dont have to use every single feature. Use whatever is required and if the need ever comes, go in depth with the language.
Its about to become way more complex and cooler after c++26 and 29 [with possible introduction of contracts and reflection!].
There is no way to completely learn this language anymore. I am not even gonna try.
If I were starting a new project today, it would depend on the project and who I was doing it for as to the language I would use, but C++ would definitely be on the list.
C++ has a lot of pain points that are being either tackled by the committee or the community. But those pain points still rear their ugly heads.
But majority of the code for HPC and ML is written in C++ or has its core written in C++. Leaving such a huge set of libraries is not an optimal decision if you want to deliver your code without having to yak shave everything.
I like the simplicity of C and not having for wait several minutes to rebuild a project. Have you thought if Python and Cython would be adequate for the task you want to solve?
There’s gonna be a bit more headache at each step of the process (finding the right libraries, building your code, and learning the language) that might come easily to someone who uses it professionally or used it extensively in college.
That being said, I think learning C/C++ has value in A) the areas you mentioned where it’s used extensively (e.g. kernel, embedded, or HPC dev) and it’s a good lang to know if just to understand how computers work a bit better. This is purely ‘extra credit’ though IMO if you’re already a productive developer.
Zig is a better language than Rust but it is even further behind in native support for the HPC/ML space.
Between Rust and C++ I tend to pick Rust for better tooling and simpler control over LLVM. It's entirely up to you, but I wouldn't be caught dead running Valgrind on my multithreaded machine learning app.
For machine learning you have the pytorch C++ API: https://pytorch.org/cppdocs/
You dont have to use every single feature. Use whatever is required and if the need ever comes, go in depth with the language.
Its about to become way more complex and cooler after c++26 and 29 [with possible introduction of contracts and reflection!]. There is no way to completely learn this language anymore. I am not even gonna try.