static, const and volatile are the most complicated keywords in C.
You have obviously not seen the definition for
restrict(a slightly more understandable explanation:
https://en.wikipedia.org/wiki/Restrict )
Types are actually a common source of bugs. And also a reason for debate. Hence why C++ is equipped with auto. Or some languages not even having types at all. (javascript)
But not all languages are easily compatible with every platform or intended function. You can't really use javascript for embedded or kernel drivers for example.
That's actually completely wrong, on several fronts (I will get to the
auto keyword below).
Languages like Javascript (or Python, for ex.) of course do have types. They are just
dynamically typed - i.e. the type is associated with the value (string, int, float, etc.), often using some sort of a
tag stored with the data, not the variable that is used to refer to it. The "type" of a variable depends on what value has been assigned to it, so it could hold a string at one moment and an int two seconds later.
In contrast, languages such as C, C++, Java, Haskell and many others are
statically typed - the type is known at compile time and does not normally change at runtime (ignoring type casting, type punning and similar).
Dynamic typing is of course convenient - no type declarations, you can store everything anywhere you want, etc. The downside is pretty much unmaintainable code unless extreme care is taken, the compiler will not warn you that you are passing a string to a function that expects numbers as arguments and similar -> lot of runtime bugs and problems. There are ways out of this, e.g. obsessive use of automated tests, using type annotations where you actually declare what argument types is your function expecting (Python, Lisp have these, Javascript doesn't) but all that requires programmer's discipline.
Static typing avoids these issues. For example Haskell is a strongly statically typed language where if you get the code to compile correctly, it is almost assured the code is also correct. That's because the strong typing and the very powerful type system that Haskell has allow the compiler to reason about the behaviour of your code in detail - much more than e.g. C/C++ compiler can. Static typing also allows for much more powerful optimization techniques than dynamically typed languages can perform.
Dynamicaly typed languages have to typically resort to things like JIT which actually "learn" what the types of the data are at runtime before being able to optimize the code. Whereas statically typed language can be optimized at compile time and often to much higher degree because the compiler is able to reason about the data - e.g. replace constants with values, eliminate constant expressions (think constexpr in C++) with precompiled values at compile time, eliminating entire files of code in the process.
Good example of this is the Kvasir library (
https://github.com/kvasir-io/Kvasir) - it allows to write quite a bit of complex code e.g. initializing MCU registers, while checking that you don't write into bits that are not writeable or try to write an invalid value (e.g. 6bit value into 4bit register part - if you are doing it using bit manipulations you get no warning).
And all this (even multiple bit manipulations/assignments in a single register) typically compiles into a simple assignment because all this stuff is done as constant expressions and type manipulations (via C++ templates) so the compiler can optimize it. So you gain correctness, code readability and safety all the while not paying for it with runtime performance or code size. It costs only extra compilation time and possibly some horrific C++ error messages from the template instantiations if you screw up.
And re
auto - C++
auto does not remove any types from the language. It is just a syntactic sugar so that one doesn't need to write the type when the compiler is able to deduce it automatically - which is only possible because the language is statically typed, so the compiler can compute what the resulting type of the expression will be. The variable is still typed the same as if you wrote the type there by hand.
Types actually help prevent the bugs, lack of the type information at compile time is the source of problems.
(And the fact that Javascript or Python aren't used for writing kernel drivers has nothing to do with types but a different language focus, even though both can and do run on embedded hw too. You are also not writing website code in C++. But that's a different debate, let's not turn this into a pissing context about the merits of this vs that programming language)