3 ms·
For me it's about compactness of type representation -- types are on the right, except when they're not -- in arrays or function pointer declarations, you have
by andrewla 8y ago
For me it's about compactness of type representation -- types are on the right, except when they're not -- in arrays or function pointer declarations, you have to deal with the fact that the variable name being introduced may be nested in unintuitive ways deep inside the declaration. By moving it to the right, you make that much clearer. In Java, they made it so that array information went on the left, which made it a little clearer, but was still kind of ugly, and Java really had no notion of function pointers anyway.
The other problem with the type-on-the-left is that variable declarations are hard to find without tooling designed for that purpose. Being able to search for "var x" is a nice feature that makes it easy to separate out the declarations from the usage.
I agree that type inference and optional types is something of an anti-feature from my perspective as well; even more frustrating is languages that treat a type declaration as a type assertion rather than a declaration, which serves to divorce ideas about physical storage from the code; abstract types like "bool", though, have already crept into C to make the type model a little more complicated than it has to be. Types in C used to be declarations of storage class as well; now I know that a bool in a struct will take up a byte, but that byte and bool are not really compatible types makes it a little harder to reason about, even if that does give better hinting to the compiler.