4 ms·
I never really understand why I would want a type system until I learned Rust and was forced to learn it. Now I don't understand what I was thinking before..
by atoav 7y ago
I never really understand why I would want a type system until I learned Rust and was forced to learn it. Now I don't understand what I was thinking before..
- mehrdadn 7y agoWhat were you using before?
- atroche 7y agoNot parent, but I’d be surprised if the answer didn’t include JavaScript, Ruby or Python.
- atoav 7y agoMostly python and C. With python I didn't really have a type system and with C I never truly realized what the typesystem could give me.
- fulafel 7y agoI suspect one would learn appreciation of limited type systems from the other direction by using a typeless language.
- fulafel 7y agoI would be interested in hearing counterarguments to this!
- leshow 7y agoI wouldn't. Why would you want to take errors that happen at compile time and create runtime errors? In dynamic languages you still have type invariants, it's just now they are invisible and can break your code at runtime.
- fulafel 7y agoIn typeless languages like forth, asdembly etc the debugging is more confusing than in Python, because you often see the situation blow multiple layers after the error happened. Or you may simply get silent wrong anwers. And in C, just the pointer vs value distinction in the type system makes code dramatically clearer and catches lots of errors. This is how limited type systems are still very much better than no types.
- leshow 7y ago> This is how limited type systems are still very much better than no types. This is not what I was arguing against. I was arguing that I would be surprised if people were happy to go from strong typing to dynamic typing, not that 'limited' type systems are better than 'no types'.
- fulafel 7y agoAh. My original comment was about how limited type systems are still useful, in response to someone not seeing their point when using them. Communication is hard :)
- cogman10 7y agoA few things come to mind. For a dynamically typed language, a REPL ends up being essential. In a lot of ways, REPLs can be a superior form of programming. Those are often much harder to get to work with static type languages (often too much ceremony around the types). The other thing that comes up is sometimes those compile time errors are somewhat pointless. For example, in many cases the difference between an int and a long are completely inconsequential. But further, whether or not your type is a Foo with a name field or a Bar with a name field or an Named interface simply does not matter, you just want something with a name field. While static typing would catch the case of passing in something without the name field, it unnecessarily complicates things when you want to talk about "all things with a name field" (Think, in the case of wanting to move Foo, rename Bar, etc). Then there is the new concepts you need to learn. With dynamic typing, you can write "add(a, b) { return a + b; }". But how do you do that with Static typing? Well, now you need to talk about generics. But what if you want to catch instances where things are strictly "addable?" now you are looking at constrained generics. But what if you want a specialized implementation? Now you are potentially talking about doing method overloading. What if you want a different style of adding? Now you might be talking about plugging in traits. Typing and type theory have a tendency to add a requirement that you learn a whole bunch of concepts, but also that you learn how to correctly use those concepts. It is no wonder dynamic typing has it's appeal. Dynamic languages are generally low on ceremony and cognitive burden. I say all this being someone that likes static typing. Just want to point out that dynamic typing has it's appeal. Obviously, the big drawback is when you come back to a dynamically typed language and you want to fix things. It can be insidiously hard to figure out how things are tied together and you get no aid from the language.