Re:C++26: A Placeholder with No Name
by coffeeaddict1 on Saturday January 11, 2025 @03:33PM
(#42668711)
> Use types when they are needed and use the tools at your disposal (IDEs BT every text editor has clang language server integration nowadays)
While I agree that auto is helpful, the amount of times I had to wait for clangd (or whatever the IDE is using) to parse a .cpp file and deduce the underlying type is frustrating. It happens too often with every IDE (Qt Creator, CLion, VS Studio, VS Code, etc...) I've tried whenever I'm programming with a non-desktop machine that's not super beefy.
Plus I often use Github to search for code when I'm trying out a new lib so having the type spelled out is extremely helpful.
Plus assuming that your codebase is clangd parseable. Many aren't out of the box.
Plus assuming that you're not reading/modifying code on a (remote) machine where you don't have access to IDEs but simple editors only.
Otherwise, I also find auto helpful but I use it sparingly, mostly where type is obvious, e.g. can be easily deducted from the local scope.
Use types when they are needed and use the tools at your disposal (IDEs BT every text editor has clang language server integration nowadays)
> with light documentation which means reading the code,
You have to read the code anyways, documentation is impossible to trust. There isn't one big library for which I didn't have to go read the code at some point. Two weeks ago I had to go read the internals of msvcrt, Microsoft's C runtime, to understand undocumented features of process setup on windows. I had to go read standard library code thousands of times, and let's not talk about UI libraries.