3 ms·
I've basically spent my career without static types (except for the little bits of C that happen here and there), but I keep hearing about how types would chang
by toast0 8y ago
I've basically spent my career without static types (except for the little bits of C that happen here and there), but I keep hearing about how types would change my world ... But then evertime I've looked at a typed language lately, everything is type 'auto'. Well, maybe not Java, I don't think they have auto yet?
As an honest question, if types are good, why would you put auto, instead of telling me the type?
For context, I'm a neanderthal and just use a boring text editor, so I'm not getting any tool assisted type information if you write auto everywhere.
- jayd16 8y agoAs others have said, you keep all the static checking with these systems but you get the brevity of a shorter definition. It also makes refactoring easier. If you use var then you don't need to change all your declarations if you change a class name.
- pjmlp 8y agoBecause even with type inference, the compiler shouts at me during compile time if they don't match, instead of crashing at runtime, because Joe of the 5th floor forgot to add a field when he checked in his code. So I don't need to write additional unit tests to do the compiler's work that would have prevented Joe to check in his code.
- cube2222 8y agoBecause it's quicker to write and often more readable. Your IDE (or tooling) can provide you with the type of a variable whenever you want.
- IshKebab 8y agoAutomatic type deduction is not the same as dynamic typing. There are still types and you still get compile time errors if they don't match.