User loginNavigation |
Why type systems are interesting
In the Explaining Monads thread, Luke Gorrie wrote:
If someone could next show what makes type systems so interesting in terms that I'll understand then I'll be well on my way into the modern functional programming world.. :-) When you write code, even in the most dynamic language, you always know something about the types of the values you're operating on. You couldn't write useful code otherwise - if you doubt that, try coming up with some examples of operations you can perform on a value without knowing something about the type of that value. Type systems provide a way to encode, manipulate, communicate and check this type knowledge. In an earlier thread, you mentioned that you write the types of functions in the comments. That's an informal type system! Why do you do use a type system? Because type systems are useful, important, and as a result, interesting. The question didn't mention the word "static", but I'll raise it anyway. The type knowledge I'm talking about is necessarily mostly static - you know it when you're writing the program, and it's knowable when you're reading the program. Since we can't write useful code without it, it's also very important knowledge. That raises the question, if this important static knowledge is present in our programs, shouldn't we make it explicit somehow? Further, if possible, since we exploit and depend on this knowledge on almost every line of code we write, shouldn't we check it for validity as early as we can, even while we're writing the programs (e.g. within an IDE), perhaps before it's possible to run unit tests on them? Given this ability, why wouldn't you take advantage of it? Of course, the answer to that is that encoding a program so that its every term can have its type statically checked, introduces some constraints. But as I've argued before, the alternative of avoiding all static encoding of type information (other than in comments) is mostly a reflection of weaknesses in the state of the art.By Anton van Straaten at 2004-07-15 17:49 | LtU Forum | previous forum topic | next forum topic | other blogs | 137228 reads
|
Browse archives
Active forum topics |
Recent comments
26 weeks 5 days ago
26 weeks 5 days ago
26 weeks 5 days ago
48 weeks 6 days ago
1 year 1 week ago
1 year 2 weeks ago
1 year 2 weeks ago
1 year 5 weeks ago
1 year 9 weeks ago
1 year 9 weeks ago