Maybe I'm just one of those spoiled younger developers who expects great DX on all my tools, but it makes me really reluctant to invest more time into learning C++ when I could be contributing to open source Rust and improving the ecosystem. Getting better with C++ just feels like learning an endless series of sharp edges.
They are adopting Rust in some small spots like Azure Sphere, and Rust/WinRT, yet WinDev, XBox, Office, .NET (for the runtime), DirectX aren't getting rid of their C++ code anytime soon.
Rust experience is compeling if one doesn't need to rewrite the world, e.g. doing CUDA in C++ versus Rust.
Of course it's sticky- someone who's already an expert in the miserable language may not choose to totally re-skill themselves (and anyway, once you know something that well it tends to become less miserable). But the new generations will heavily favor the thing that's welcoming to them, not the thing that's prickly
Which part of the following example is hard:
program(mynewproject LANGUAGES CXX)
add_library(libfoo STATIC foo.cpp )
add_executable(bar bar.cpp main.cpp )
target_link_libraries(bar libfoo )
Edit: and this message was downvoted? Seriously?
Differently put: a phrase "metabuild system" has both a lexical sense and an idealized sense. The lexical sense would be something that generates an input to build systems. The idealized sense would be something that does everything else not possible or difficult in build systems. CMake was definitely far from that ideal [1]; it was often simpler to make a configure script in your favorite language (and, for god's sake, not in M4) than using CMake.
[1] Was using a present tense but edited after realizing that I don't know much about recent changes to CMake. Still enough to justify my (and others') criticism.
Not really. When people talk about setting up a new project, they talk about starting a hello world project and build up from there.
Anyway, I'll bite. What would it take to add a dependency? If it exports a cmake config file which exports targets, all it takes is this:
find_package(MyDependency),
target_link_libraries(bar MyDependency::targetA MyDependency::targetB ... MyDependency::targetZ )
If it doesn't and it is instead a system library then you can even pass the library instead.
add_library(bar systemlibrary )
If the library exports no cmake config and you have anything exotic you can put together your own cmake find modules, and proceed to follow step A.
Alternatively, you can even bolt on something like Conan and just follow step A all the time.
> Differently put: a phrase "metabuild system" has (...)
Sorry, but do you actually have any concrete example of any difficulty setting up a C++ project?
The original reply said one dabbled C++ via "creative coding, graphics programming, etc.", which definitely needs dependencies from the beginning. Can you draw a nicely shaded triangle only with the C++ standard library?
> If the library exports no cmake config and you have anything exotic you can put together your own cmake find modules, and proceed to follow step A.
They are not exotic, libraries without cmake config are common. So, as I've said before, people had to come up with their own find modules and this requires lots of trial and error to get it right. Guaranteed, it might have been possible to collect those into some sort of registry (a la DefinitelyTyped for TypeScript .d.ts files), and probably something like Conan can provide that, but ideally that should have been built into CMake. And keep in mind that Cargo---something we were comparing against back in time---does all of them declaratively. (Arguably, from users' perspective, it can handle C/C++ dependencies better than CMake!)
Taken straight from Qt's page on OpenGL support:
find_package(Qt6 REQUIRED COMPONENTS OpenGL) target_link_libraries(mytarget PRIVATE Qt6::OpenGL)
https://doc.qt.io/qt-6/qtopengl-index.html
Do you feel this is too hard to setup?
It's not Qt6. The same goes for Qt5, which has been around for what, close to a decade?
And what's your point, exactly? That things are hard if you purposedly ignore all the examples that prove that things are patently easy and trivial? Because it seems evident to me that if you want to quickly setup a C++ project to try out stuff, a CMake project with single-digit lines of code that get you a window with an OpenGL context going is right what you'd be looking for.
But instead you complain that the choice of build system and framework made things easy? And that's why things are not hard
What exactly do you think is your point?
I have no doubt that people who work on big commercial C++ project have sensible build systems and documentation that's not too hard. But it's incredibly common when working in this art/graphics space to need to try to get someone's bitrotted random project without docs or build system running. Common to have to do that AND have to do it on another platform.
That said... Rust and OpenGL have quite an impedance mismatch, don't they?
The options are there to be used.
Take a look: https://stackoverflow.com/questions/75270938/thread-pool-wit...
Options that are barely supported, severely limited in features, are only reasonable for tiny side projects, etc.
If your project doesn't take long to compile or test anyways.... I can see getting annoyed.
I have to call bullshit on this claim.
CMake is at its hear a build system generator. It offers a high-level abstraction to define software projects, and it uses that abstraction to generate the actual build system. It can generate makefiles, but also Ninja, Xcode, visual studio, and even msbuild projects.
What actually does the build is not CMake, but make, msbuild, ninja, Xcode, or visual studio. Not CMake.
You run CMake once to generate the build project, and when you actually want to build the project you only call ninja or make etc.
To top that off, some of these build systems support build cache systems such as sccache or ccache. Plugging in one of these tools can easily drop build times to a fraction of the time. Literally. I had C++ projects which used CMake whose build time of a complete rebuild dropped to 15% of it's original time.
Nothing beats a language's own dedicated packaging system (yes, even python's mess is better than bazel+python) but C++ and Java have bad build systems, so bazel is better for them
What is wrong with Maven or Gradle?
But in a corporate environment where repositories are often authenticated, the fact that dependency fetch issues are reported as Java exceptions (having the wrong password in your netrc file shows up as "IOException occurred during fetch of ... Code 401") is a deal breaker for a C/C++ development staff unfamiliar with Java.
They happily take their ten minute incremental builds and "it works on my machine" issues in return for a build process they can understand, and as much as I want them to be wrong (I use Bazel all the time at home), I can't blame them for wanting tooling they understand.
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++.
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.
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).
Modules: GCC and clang will eventually get there, I am already enjoying them on VC++
#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.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).
C++ has lots of problems, lack of expressiveness isn't one of them.
I feel that you are the very first person ever making such a statement. Can you provide what's your single best example showing C++'s inexpressiveness and "high impedance with cognition"?
I've been working with C++ for a few years and did some work porting legacy apps to CMake. I've saw awful CMake legacy projects but since CMake 3.0 and the introduction of it's declarative way of setting up targets CMake is actually quite nice to work with.
What exactly does CMake do that you feel is "an ancient horrible mess"? Can you provide any specific example?
There is build2[1], which tries to approximate Cargo's experience for C/C++ projects while providing more depth, especially in the build system (unfortunately the "build by convention" ship has sailed for C/C++ so there needs to be some flexibility).
As some indication of the project's "seriousness" (there are a lot of toy build systems out there), it builds Boost and Qt (both 5 and 6 but only classic for now).
Rather marginalized but https://waf.io/
All of it seems to be based on copying dependencies around or installing them on a system level. Plus mostly template/text driven make files.
I'm still not sure if this is really how C++ is developed.
Four years ago, when I last looked, I wasn't able to find a good resource for people with my background to learn C++ the ecosystem (not the language).
That turned me to Rust. All of this text to give strong support for your first paragraph.
People do the C/Rust comparison, but at least C has a simpler mental model so is a different thing. I feel like C++ has similar, if not more, complexity to Rust and is harder to onboard.
I do think there are domains where "let's use Rust" are a bit ... aspirational more than anything (anything related to graphics or OS integration...). And there C++ makes a lot of sense. But I think that day by day the number of projects where C++ is the only obvious choice goes down. Hell, it's been going down since Java!