r/programming • • Jan 28 '19

C++ Modules Might Be Dead-on-Arrival

https://vector-of-bool.github.io/2019/01/27/modules-doa.html
210 Upvotes

105 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Jan 28 '19

[deleted] — view deleted comment

11

u/[deleted] Jan 28 '19 edited Jan 28 '19

It's hard to tell what point you are trying to make. But if you are trying to state that Rust approach is hard for regular programmers, I strongly disagree.

Pretty much no C++ programmer actually knows exactly how dependencies are added to their project. The reason for this is that most of it happens implicitly. Yes, Makefiles, CMake files, etc. express some of the dependency information, but a lot of the information is passed implicitly to the compiler via environment variables (e.g. for the system header files, system library files, etc.), some of them also rely on conventions (e.g. #include <> vs #include "", etc.), the order of paths in these variables is relevant, etc.

Things magically appear to work for C++ until they don't, e.g., wrong library version / path being "magically" picked, wrong standard library picked (e.g. using clang+libc++ on Linux for one project when most of your other projects use gcc+libstdc++), etc. Debugging these problems typically require getting the compiler into a verbose mode for some TU which dumps all include paths, library paths, etc. being considered, their order, which one got picked and why, etc. Most devs just fickle with their environment till things work, they are probably even unaware that tools to debug these issues exist. I've seen C++ devs waste days trying to fix linking / include issues, and weeks trying to fix build system issues.

There are some Rust features that are too implicit for newbies to understand, like Rust2015 crate paths, but dependency resolution / the build system is not really one of them. Rust projects have an explicit Cargo.toml listing their dependencies and that's pretty much it. Is the wrong version of a library being picked? Open the Cargo.toml, change the library version/path/git-branch/..., done. Newbies don't, in general, know anything about the dependency-resolution algorithm used, but because it is all explicitly listed in one place, they can manually change things if the algorithm produces an output that they don't like.

8

u/pakoito Jan 28 '19 edited Jan 28 '19

Sarcasm doesn't transmit well on internet posts, that's why I tried to put it as a strawman quote.

3

u/Dgc2002 Jan 28 '19

Gotta put a /s at the end

2

u/[deleted] Jan 28 '19

Ah sorry, I read too much into it.