Any reason for that conclusion? I personally have known the instructor of the course for the better part of a decade and he's one of the finest CS educators out there and has numerous awards to show for it.
I've talked with him about this choice and he has a lot of sound reasons for making this move backed by his years of experience teaching in various languages.
What's your line of thought? I use Clojure many hours every day and while I think that LISP languages are awesome, I don't think they're a good choice for a 1st programming course either.
One advantage Lisps have is that they tend to be much more inclusive of functional programming. Python supports (limited) lambdas and some higher-order functions, but it really feels like the language tries to steer you away from too much functional programming.
The best time to learn about different paradigms is right when you're starting out; if you basically only learn how to program imperatively, you're liable to start believing that that's the only way to go. I know because this happened to me (I was self-taught and learned a different set of languages, but it had the same effect); ultimately it took me longer to come to and start using functional programming properly than it would have had I learned about it at the very beginning.
Full disclosure: I've known John (the instructor) for 3 years, and I'm a TA for this course right now. On the other hand, I was also 'born' Scheme at MIT (which has also switched to Python).
I can confirm that moving to Python was a very well-reasoned decision. Having TA'd the Scheme version of the same course 2 or 3 times, I can say that for all talk of Scheme having very simple syntax, it's surprisingly hard for students to get used to.
- The code is hard to read, and, a humans, we're not built for nested expressions.
- Useful data structures, like key-value stores, and indexable lists, are limited, or introduced late
- Having recursion thrown at you in week 1, before you've learned basic debugging, the concept of abstraction, or how to write readable code, gets in the way of learning to program.
How does the course get around the problem of functional programming being a complete pain in the arse in Python? For me the value of SICP was to teach me how easy, beautiful and powerful it can be to program that way, because everything else before it failed to communicate that. I can't see how an SICP in python could have the same effect.
Python has some powerful elements too. It sure it lacks elements and features of historical and current pure functional[1] programming languages, but I find it elegant to use python as a set-theory powered language. Often I can solve complex problems in a few lines by thinking about the sets of elements I am manipulating, constructing and transforming them. Instead of imperative, python code becomes very descriptive. Indexing a dictionary with frozensets and making use of a proper definition of __hash__ to put various objects as dictionary keys or inside sets allows for tremendous power and terseness and explicitness.
In [2] the solution given by yairchu can be written succinctly via generators, which look extremely like a mathematical set definition.
def grandKids(generation, kidsFunc, val):
return reduce(lambda a, v: (x for v in a for x in kidsFunc(v)), xrange(generation), [val])
I often happen to think about a problem and explicit it with pen and paper using pure mathematical set notation then implement it in Python.
Mind: I said "a pain in the arse", not "impossible". And i think not only about the writing (writing such things regularly is not what any programmer would want to do), but also the debugging perspective.
What you have done there is cute and commendable as a mental exercise, but if i'd ever encounter that in production code someone would make a close encounter with my chainsaw. This is basically undebuggable (i don't know the line/statement debuggers python has available, so i'm guessing here at what happens) because either the debugger will step over that in one step because it's one statement, or it'll just keep stepping on the same line again and again which is also entirely useless.
Lastly, what you did there is basically golf the living hell out of that code to bring it down from multiple statement lines to a single one. If i have to reach to such means i might as well use Perl. Only Perl actually does allow me to put multiple statement subs into a lambda, so i don't have to golf there.
Weird days when i have to golf in Python but don't need to in Perl.
Comments
an abomination, pure and simple.
Any reason for that conclusion? I personally have known the instructor of the course for the better part of a decade and he's one of the finest CS educators out there and has numerous awards to show for it.
I've talked with him about this choice and he has a lot of sound reasons for making this move backed by his years of experience teaching in various languages.
What's your line of thought? I use Clojure many hours every day and while I think that LISP languages are awesome, I don't think they're a good choice for a 1st programming course either.
One advantage Lisps have is that they tend to be much more inclusive of functional programming. Python supports (limited) lambdas and some higher-order functions, but it really feels like the language tries to steer you away from too much functional programming.
The best time to learn about different paradigms is right when you're starting out; if you basically only learn how to program imperatively, you're liable to start believing that that's the only way to go. I know because this happened to me (I was self-taught and learned a different set of languages, but it had the same effect); ultimately it took me longer to come to and start using functional programming properly than it would have had I learned about it at the very beginning.
Full disclosure: I've known John (the instructor) for 3 years, and I'm a TA for this course right now. On the other hand, I was also 'born' Scheme at MIT (which has also switched to Python).
I can confirm that moving to Python was a very well-reasoned decision. Having TA'd the Scheme version of the same course 2 or 3 times, I can say that for all talk of Scheme having very simple syntax, it's surprisingly hard for students to get used to.
- The code is hard to read, and, a humans, we're not built for nested expressions.
- Useful data structures, like key-value stores, and indexable lists, are limited, or introduced late
- Having recursion thrown at you in week 1, before you've learned basic debugging, the concept of abstraction, or how to write readable code, gets in the way of learning to program.
- Almost nobody uses scheme.
How does the course get around the problem of functional programming being a complete pain in the arse in Python? For me the value of SICP was to teach me how easy, beautiful and powerful it can be to program that way, because everything else before it failed to communicate that. I can't see how an SICP in python could have the same effect.
Python has some powerful elements too. It sure it lacks elements and features of historical and current pure functional[1] programming languages, but I find it elegant to use python as a set-theory powered language. Often I can solve complex problems in a few lines by thinking about the sets of elements I am manipulating, constructing and transforming them. Instead of imperative, python code becomes very descriptive. Indexing a dictionary with frozensets and making use of a proper definition of __hash__ to put various objects as dictionary keys or inside sets allows for tremendous power and terseness and explicitness.
In [2] the solution given by yairchu can be written succinctly via generators, which look extremely like a mathematical set definition.
I often happen to think about a problem and explicit it with pen and paper using pure mathematical set notation then implement it in Python.[1] http://stackoverflow.com/questions/1017621/why-isnt-python-v... [2] http://stackoverflow.com/questions/1016997/generate-from-gen...
Mind: I said "a pain in the arse", not "impossible". And i think not only about the writing (writing such things regularly is not what any programmer would want to do), but also the debugging perspective.
What you have done there is cute and commendable as a mental exercise, but if i'd ever encounter that in production code someone would make a close encounter with my chainsaw. This is basically undebuggable (i don't know the line/statement debuggers python has available, so i'm guessing here at what happens) because either the debugger will step over that in one step because it's one statement, or it'll just keep stepping on the same line again and again which is also entirely useless.
Lastly, what you did there is basically golf the living hell out of that code to bring it down from multiple statement lines to a single one. If i have to reach to such means i might as well use Perl. Only Perl actually does allow me to put multiple statement subs into a lambda, so i don't have to golf there.
Weird days when i have to golf in Python but don't need to in Perl.
> the value of SICP was to teach me how easy, beautiful and powerful it can be to program that way
That might be your value. But, the goal of SICP class is not to teach functional programming or create fpfs.
I know. The goal was to show how functional programming is the base of all other paradigms. :)
What's an fpfs?
what would you pick instead?
thank god for this, then right?
http://www-inst.eecs.berkeley.edu/~cs61as/fa11/