4 ms·
> 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 th
by coffeeaddict1 2y ago
> 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.
- menaerus 2y agoPlus 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.
- cma 2y agoOne approach is use auto while coding, auto convert to full types when finalizing/commiting except where they hurt readability.