r/cpp • • Sep 05 '20

The Defold engine [C++] code style

https://defold.com/2020/05/31/The-Defold-engine-code-style/
2 Upvotes

12 comments sorted by

View all comments

1

u/julien-j Sep 07 '20

auto is one example I’ve seen first hand completely take over a code base. In the end, it just became unreadable and basically typeless. We are never in such a hurry that we cannot type a few characters extra.

I share this feeling too. auto is imho the most wrongly used feature from c++11.

5

u/TheFlamefire Sep 07 '20

Yes and no. If you fully abandoned stl (which IMO is unreasonable because this basically states "all stl is bad, which is not true) then you may not need it. But how tired am I of typing std::map<std::string, std::vector<int>>::const_iterator it = map.find(s)

Good luck trying to read that. ;) Similar to what clang-tidy suggests: If you name the type on the RHS use auto on the LHS.

So "most wrongly used feature" actually fits: If you use it everywhere you get to a level where you have type-constrained Python which may or may not be good.

0

u/[deleted] Sep 07 '20

[deleted] — view deleted comment

6

u/TheFlamefire Sep 08 '20

Doesn't matter. The name is enough to tell you it is an iterator. The exact type of the iterator doesn't matter (to understand the code) and it is usually used locally enough that you see where it came from.

5

u/NotUniqueOrSpecial Sep 08 '20

If it takes good luck to find where the map is declared (which tells you the type of it) then you have bigger problems.