4 ms·
I have never seen anyone come back to typing types everywhere after using auto for more than a couple months. Use types when they are needed and use the tools
by jcelerier 2y ago
I have never seen anyone come back to typing types everywhere after using auto for more than a couple months.
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.
- 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.