News for hackers. Stuff that matters.
Re:“Modern” C++ Lamentations (2018) by hawk_ on Tuesday January 11, 2022 @06:33PM (#29900028)
> other viable systems programming languages simply did not exist (now you at least have Rust as a possible contender).

(I have no horse in this race) But if a big part of their complaint is compile times, Rust may not be the best example of a contender.

Re:“Modern” C++ Lamentations (2018) by spoiler on Tuesday January 11, 2022 @07:35PM (#29900634)
Rust incremental (and debug) compilation times aren't that bad, though. It almost feels like a mindlessly perpetuated rumor at this point.

Sure, it's kinda slow when compared to something like Go, but the amount of extra work rustc does compared to pretty much every other compiler is very big. Taking this into account, I can forgive it.

But even with all that said, Rust has a compiler performance team that is constantly trying to improve things and keep track of regressions. I dunno if C++ implementations (eh gcc) have something similar?

But yeah, at the end of the day, I think compilation times are important, but not as important as some other aspect of the language... Like, in C++ you can't even catch some errors until you start compiling and it fails in template expansion, while I usually don't have to compile Rust until I'm checking business logic. This allows me to focus on the problem at hand, not the language.

Re:“Modern” C++ Lamentations (2018) by xedrac on Tuesday January 11, 2022 @09:02PM (#29901371)
As someone who loves Rust and uses it daily, compile times are abysmal, even compared to C++. It's the sole reason I bought a 32-core workstation. But you're right, when iterating, incremental compilation times are reasonable enough. Compile time is a very small price to pay for all the developer time that is saved over the life of the project.
Re:“Modern” C++ Lamentations (2018) by djdjfhsje33edh on Tuesday January 11, 2022 @10:37PM (#29901973)
Have you tried the mold [1] linker? It's a drop-in replacement with a single cargo config change and gave me a massive speed-up (> 10x) for incremental debug builds of a large project with around 450 dependencies.

[1] https://github.com/rui314/mold

Re:“Modern” C++ Lamentations (2018) by ReactiveJelly on Tuesday January 11, 2022 @11:03PM (#29902135)
C++ makes me miss `cargo check`.

Sure, Rust compiles slower, but in C++ I have to wait on a slow compile just to find something dumb like a typo. And it doesn't even have the borrow checker. I have to make an exe that doesn't work to see if I made one typo. And then the errors are so bad.

Re:“Modern” C++ Lamentations (2018) by petr_tik on Wednesday January 12, 2022 @05:18AM (#29904497)
you might find clang-check useful.

https://clang.llvm.org/docs/ClangCheck.html

you will need a Compilation Database (CDB) in a compile_commands.json file. I know CMake knows how to generate one, but the fact that other build systems don't shows how fragmented and user- unfriendly the cpp ecosystem is.

Re:“Modern” C++ Lamentations (2018) by jcelerier on Wednesday January 12, 2022 @03:02AM (#29903643)
... your C++ IDE does not show the errors as you type ? If you're using sub-par tools by choice you cannot complain..
Re:“Modern” C++ Lamentations (2018) by spoiler on Wednesday January 12, 2022 @05:06AM (#29904413)
The best thing that I found that works is Clion. Everything else in the ecosystem lacked polish, or ergonomic, or consistency. And Clion is lacking in these too, just not as much.

Maybe I'm setting the bar too high for an old technology? I don't know.

What IDE (or just DE) would you recommend that works well?

Re:“Modern” C++ Lamentations (2018) by ahartmetz on Wednesday January 12, 2022 @07:05AM (#29905228)
Qt Creator is fine, Kate with LSP plugin is also fine. I use the latter because I prefer, well, editor-style editors. The main reason is that I prefer to do build and run related things on the console, it's more quick and flexible.
Re:“Modern” C++ Lamentations (2018) by jcelerier on Wednesday January 12, 2022 @06:11AM (#29904851)
I use QtCreator. Here's my experience while editing, what do you think is missing ? https://streamable.com/xm1xw9
Re:“Modern” C++ Lamentations (2018) by spoiler on Saturday January 15, 2022 @10:13AM (#29946898)
This looks a lot more responsive/snappier than Clion. I sometimes have to wait half a minute for syntax highlighting to "catch up" (not always, so I don't understand what ails it), or for it to pick a new method/classname to appear in auto-completion results.

I'm not on my work machine now. I don't write C++ as much at my company anymore, as I was pushed into a more (regrettably), so I can't recall an example from the top of my head now. But there were definitely instances where you can pass in something, and it doesn't error until you hit the "build" button (or run a build via cli). And even then, the editor doesn't report where the error is in the "editor area", you have to read the file/line in the console.

Re:“Modern” C++ Lamentations (2018) by dureuill on Wednesday January 12, 2022 @03:13AM (#29903718)
I never found a C++ IDE capable of understanding our root CMake project so it can gives us autocompletion and inline errors.

We have a root project that's fully CMake, that orchestrates our sub libraries (also using CMake, declared with ExternalProject_Add) so the dependees are built before their dependents (and also to handle final packaging). The subprojects are added as git submodules.

I tried VSCode and QtCreator but none of them seem to support CMake multi-projects defined in this way. I have to create a build directory per subproject, which can be painful when we have so many subprojects.

Re:“Modern” C++ Lamentations (2018) by jcelerier on Wednesday January 12, 2022 @05:11AM (#29904442)
> We have a root project that's fully CMake, that orchestrates our sub libraries (also using CMake, declared with ExternalProject_Add)

well, those are not sub-libraries but external projects with their own build-system. I have sublibraries in submodules and add them with add_subdirectory and everything shows and is auto-completed correctly.

Re:“Modern” C++ Lamentations (2018) by dureuill on Wednesday January 12, 2022 @07:42AM (#29905542)
Thanks. We've been using external projects since some of them are old style CMake, ripe with global variables, but apparently we could've used add_subdirectory for some other libs. I'll keep that in mind for future refactorings and libraries.
Re:“Modern” C++ Lamentations (2018) by gpderetta on Wednesday January 12, 2022 @05:26AM (#29904555)
Even if you can't make the IDE work, having a link target that does -fsyntax-only and skip linking should still greatly speed up your compile-edit loop.
Re:“Modern” C++ Lamentations (2018) by maxnoe on Wednesday January 12, 2022 @02:19AM (#29903363)
Try ccls
Re:“Modern” C++ Lamentations (2018) by xedrac on Wednesday January 12, 2022 @01:04PM (#29910532)
No, but thank you for making me aware of it. Linking with LTO takes forever on the projects I work on. I'm excited to see what Mold can do here.
Re:“Modern” C++ Lamentations (2018) by dureuill on Wednesday January 12, 2022 @02:49AM (#29903553)
Curious what kind of code you have. Sure, we don't have anywhere close to our C++ codebase in Rust, but we did integrate with a library that's on the bigger side, and compile times of the Rust part have been negligible compared to the C++ parts.