3 ms·
20 years. I find reading code with inferred types much much easier. The signal is what the code is doing. The typings are noise. Edit: In a big complicated sys
by trixie_ 8y ago
20 years. I find reading code with inferred types much much easier. The signal is what the code is doing. The typings are noise.
Edit: In a big complicated system, knowing the type like ‘user’ or ‘account’ doesn’t tell you much. There’s always more information and context. A small type definition is only the tip of the iceberg.
- josephg 8y agoThis is one of those aspects where a good editor makes a big difference. I've recently moved from writing javascript in vim, to writing typescript in vim, to writing typescript using VSCode. Being able to hover over a variable and see a variable's type makes it easier to read complex code. This is useful irrespective of whether or not you're using type inference, since you don't need to hunt down the variable's declaration to figure out its type. And if you're reading back the compiler's type information through your IDE while programming, you may as well take advantage of type inference.
- jstimpfle 8y agoI'm not a big fan of types, either. As a C programmer I use types pretty much only as much as they are required (indicate to the compiler how information is represented). It's mostly integers of various sizes, plus a few floats and structs and typedefs. Still, types in general convey more information to me than the variable name. For example, it's important to me to group fields in structures by their type to prevent superfluous padding and to get a feel of cleanliness. I tend to think of types as the relevant information that says what actually happens, and of names I tend to think as secondary information that gives an impression why it should happen.
- trixie_ 8y agoint[] UserIDs; If you had a choice of knowing the variable was an int[] or knowing it’s name was UserIDs the latter would be much more useful. This is why new languages are trending towards inferred types. Much easier to write and read (you get your padding taken care of for free as well when you use var) Also ‘what’ is happening is the actual flow and logic of the code. ‘Why’ it is happening is in your comments.
- jstimpfle 8y ago> (you get your padding taken care of for free as well when you use var) How so? Padding is inserted when the layout (order of fields) is bad. There are no language that reorder structures, are there? > Also ‘what’ is happening is the actual flow and logic of the code. ‘Why’ it is happening is in your comments. That's certainly one way to put it. But I was relating to the "show me your tables..." quote's kind of feeling. So, to be more clear, maybe more to the "what is possible" vs "what have the authors currently thought of / implemented".