3 ms·
> C++ just isn't a very expressive language Compared to what? Modern C++ is by far the most expressive systems language. That is its primary selling point. It
by jandrewrogers 4y ago
> C++ just isn't a very expressive language
Compared to what? Modern C++ is by far the most expressive systems language. That is its primary selling point. It isn’t pretty but it is uniquely powerful. One of the reasons C++ isn’t disappearing any time soon is that it elegantly and efficiently handles some software design problems that Rust struggles with. Rust and C++ are optimized for different types of software.
As is implied, the type of software someone is writing has a large impact on whether or not they need the expressiveness of C++.
- throwaway894345 4y agoCan you elaborate on how Rust and C++ differ in the kinds of software they’re optimized for? And what makes C++ more elegant for purpose?
- xigoi 4y ago> Modern C++ is by far the most expressive systems language. If you want to iterate over a range of integers, you need to manually explain to the computer how to do it. In 2023. Also, you need to Write Everything Twice because of the ancient header system.
- pjmlp 4y agoNo you don't. That is what ranges and modules are for.
- xigoi 4y agoRanges: kind of, there is the very awkwardly named std::ranges::iota_view, but it doesn't support random access and who knows if the compiler can optimize iteration over it into a simple loop. Modules are not supported by most compilers (in g++ you have to enable them as an experimental feature with -fmodules-ts, and if you want to import the standard library as modules, you need to pre-compile them into your project directory with some arcane commands).
- pjmlp 4y agoRanges: they are there, naming is a matter of taste. Modules: GCC and clang will eventually get there, I am already enjoying them on VC++
- jstimpfle 4y ago#define RANGE(type, name, last) type name = 0, last__ = (last); name != last__; name++ for (RANGE(i32, i, foo->count)) ... That solves the problem even in C. But why care much, typing a few plain loops isn't among the hard problems to solve.
- aldanor 4y agoCompared to Rust. Once you you've worked enough with proper enums and matches, that's the first thing you'll be lacking in C++ (and no, std::variant is a horrible mess without proper syntax support and doesn't even get close).