
On 5/10/05, Daniel Carrera
Hello,
This might be a strange question to ask on a Haskell list, but I do want to hear your opinions. What do you think of Python?
Python has first class functions and lexical scoping, and encourages higher-order functions, though to a much lesser degree than a real functional language. It has list comprehensions which it stole directly from haskell, and a tab oriented syntax that is somewhat similar to haskell's offside rule but simpler. It is very natural to write in a somewhat functional style, especially in regards to sequence processing: higher order functions and listcomps provide the processing and its built in generators and iterator protocol provide some of the benefits of laziness. Its elementary pattern matching encourages you to return as many values from a function as you need and use zip() (another haskell steal) to iterate over parallel sequences (all pattern matches are irrefutable, though). However, python is definately an imperative language. How much mutable state your objects have depends entirely on programmer discipline. Some built in types are mutable, and it's up to you whether you copy or mutate. Python's "lists" are actually arrays, and recursive car/cdr type stuff is not a natural fit. Python loves a for loop. All that said, it "feels" haskellish to me for some reason. I think teaching python is a reasonable approach. If you are used to using the REPL, writing small functions, and using listcomps and HOFs and not engaging in gratuitous mutation then I don't think haskell will be such a huge jump. Dynamic typing -> static typing and "why do you have to use do {}" is likely to be a bigger issue. I went from haskell to python so my perspective is all backwards though :)