Types and Learning
Via Michael Feather’s blog: “On programming language design”
I used to think that statically checked languages are better for teaching because they prevent the students from doing obviously stupid things. About two years ago I changed my mind. The students learn much better by doing stupid things than by being told by an oppressive compiler that their programs are stupid. So this year I switched to Python. The students are happier, and so am I (because I don’t have to explain that code must be properly indented). Python does not whine all the time. Instead it lets them explore the possibilities, and by discovering which ones crash their programs they seem to understand better how the machine works.
Interesting final words for an article that’s so much in favor of static types. So according to this, you learn more with a dynamically typed, “exploratory” language. If that’s true, it makes me wonder what’s better:
- A language that allows programmers to learn a lot, while having no static types,
- or a language with a type system that prevents certain errors while you don’t learn so much.
…and of course, in which scenarios are they better?
The article is generally an interesting read regarding the topic of if-im-ever-going-to-design-a-programming-language.
Well, ideally, you want to be learning new things most of the time.Then an exploratory environment would be best.
It is strage however that he advocates Python when he is used to languages like OCaml/Haskel/ML that can do some type inferring and that have their own shells for ‘exploratory development’?
- Paddy.
For learning how to program this might be true.
However, I still think that if you actually want to sell a system, the more static analysis the better. It gives you guarantees and better tool support.
@Akerbos,
OCaml/Haskel/ML are statically typed, but I think they have type inference too, so you don’t havew to add type where the program can infer it.
- Paddy.
@Akerbos, this doesn’t necessarily mean that you need to start your development effort in a statically typed language. For example, in some languages, static typing is optional, so you can add it later on (object types in Objective-C, for example). So you can have the best of both worlds.
However, Objective-C’s refactoring tools (You were referring to that, right?) are actually relatively poor compared to the wide spectrum of refactorings that’s available in, say, Eclipse. It think that other aspects like “being a superset of C” have much bigger impact on refactorability than a type system. For example, on the other side of the spectrum, there’s Smalltalk, whose refactoring browser has pretty much the same features than Eclipse’s Java refactorings. But it also had them *first*. And the implementation is way easier to understand. (After all, Smalltalk has only a few types of AST nodes, whereas Java has something beyond 100.)
I’d really like to try another optinally typed language one day, I think I’ve read Common Lisp can also do this kind of stuff, but I’m not sure how far compiler support goes there.
@Paddy3118, of course I want to learn new things most of the time.
But let’s see this from the manager’s side: Given a group of ten developers (who you don’t know very well). They also don’t tell you how interested they are, because you’re their boss. Is it better to let them work in an exploratory environment where they can learn on the go, or is it better to let them code in a less exploratory environment, which involves bigger up-front investment in education?
Both options have advantages and disadvantages. I’m especially worried about young, motivated programmers getting frustrated by super-technical type systems they don’t understand. In some cases, type systems can also be a hinderance to building something useful, both in a motivational and a technical sense.
The more technical sense is this: Recently I read something about functional programming and came across the notion of monads, which seem to be a very important argument for Haskell’s sophisticated type system. There are some tutorials about monads on the web, which typically start with an introduction into mathematical category theory and all have around 10 pages or more. I haven’t had the time to read one of yet, but it also doesn’t look easy to me. To me, this looks like automatic type inference doesn’t necessarily mean that the type system is easy to use…?