The use of "auto" when declaring types

I was taking a look at the coding standards and one of the sections has this bit:

The ‘auto’ Keyword

You should not use auto in C++ code, barring a few exceptions below. You must always be explicit about the type you’re initializing. This means that the type must be plainly visible to the reader. This rule also applies to the use of the ‘var’ keyword in C#.

They mentioned a few exceptions like going through for-loops and such. I noticed we use “auto” a lot inside member functions. We’re still explicit in the header files at least from what I’ve seen when declaring class member variables, but from the coding standard does Epic not want us to use “auto” inside member functions as well?

This is pretty much how I use auto in normally, be explicit everywhere except for things that are obvious or don’t matter what the type is, which is pretty much everything Epic listed. So I don’t make liberal use of it like Ben does in my code.

C++ is a notoriously badly designed language in so many different levels , evident by the fact that is by far the language with the largest syntax.

C++ started as a static typed language , the main reason for using static type languages is , not so much that as some people will say the fact that type errors are easily to be spot by the compiler even before executing the application , but by the fact that not having to guess the type makes the code run faster since it does less processing.

C++ is a language that started static typed and since it recently saw losing a lot of people to dynamic languages , same story for Java too, decided to bring more dynamism to the language. But when you bring dynamism to a language that is initially designed to be static will lead to some really ugly decisions.

Hence why generally speaking the use of the “dynamic” features of the languages is widely considered a bad idea.

Hence why you have been advised not to use the auto keyword.

Hence why you will be advised , if not already, to use as much Blueprint as possible and avoid C++ unless there are real performance concerns that you have actually profiled and measured.

Frankly I expect that when UE4 decides to really grow up to finally embrace a dynamic language like Python or Ruby , hopefully not Javascript, to bridge the huge chasm between the non coder friendly Blueprint to performance critical C++. It would be great if experience coder can use a fully blown dynamic language for most of the non performance critical code, for performance critical code C++ and people that are not coders or very new to coding can continue to use Blueprints.

Of course I will not hold my breath since wrapping the enormous UE4 API it will be quite a challenge even for Epic.

Actually there is little reason to use the auto keyword since its pseudo dynamic. You still have all the disadvantages of static typing and non of the advantages of dynamic typing by using auto. One of the many features of C++ bloated syntax that is rarely used because its existence is kinda pointless. If you want dynamic , templates is the way to go, but that’s another sad story for another time.