News for hackers. Stuff that matters.
Re:Why MIT switched from Scheme to Python by sharkbrainguy on Tuesday March 24, 2009 @08:16PM (#531145)

  def cons(a, b):
      return lambda f: f(a, b)

  def car(p):
      return p(lambda a,b: a)

  def cdr(p):
      return p(lambda a,b: b)
As well as in theory you can do this in practice. It's about as elegant (hard for me to judge as I have a strong pro-lisp bias).

Aside from lack of tail safety and performance issues with writing scheme-ish code I don't see why you couldn't implement those things in Python. The main difference is that typically in a real world situation you wouldn't because there's a library or a language feature

Re:Why MIT switched from Scheme to Python by jules on Wednesday March 25, 2009 @08:30AM (#531724)
The problem is not that you can't do this in Python, but that this is out of place in a Python course (you don't use linked lists in Python, for example). SICP shows that you need only a very small number of primitives to get a full programming language. You don't get this elegance with Python.

This may not be important if you teach programming to people who want use programming languages, but it is important for people who want to advance the state of the art in programming (i.e. CS students).

Maybe it's better if you teach Scheme in a seperate class class for CS students.

Re:Why MIT switched from Scheme to Python by scott_s on Wednesday March 25, 2009 @09:59AM (#531811)
Keep in mind this is a freshmen level course. You don't have to - and shouldn't - cram every important CS concept into an intro course.
Re:Why MIT switched from Scheme to Python by jules on Wednesday March 25, 2009 @06:09PM (#532518)
I agree. And this course probably is a lot better than the course I got (C++, ugh). That may be the reason I'm biased...
Re:Why MIT switched from Scheme to Python by silentbicycle on Tuesday March 24, 2009 @09:19PM (#531221)
It's also counterbalanced by there being an obviously standard, reasonably portable distribution of Python. You go to Python.org, and there it is.

It took me a while to find a Lisp that I liked, and it certainly wasn't a decision I was prepared to make while I was still trying to learn the basics. (I eventually settled on Chicken Scheme.)

Re:Why MIT switched from Scheme to Python by Kaizyn on Wednesday March 25, 2009 @07:28PM (#532631)
Your definitions do not work.

  foo = (1,2,3)
  bar = (4,5,6)

  print cons(foo, bar)
  print car(foo)
console output:

  <function <lambda> at 0x00B3F430>
  Traceback (most recent call last):
    File "./test.py", line 14, in <module>
      print car(foo)
    File "./test.py", line 5, in car
      return p(lambda a,b: a)
  TypeError: 'tuple' object is not callable
Re:Why MIT switched from Scheme to Python by danprager on Wednesday March 25, 2009 @07:49PM (#532654)
They do work; they just don't integrate with the built-in types: Why should they?

Try instead:

  car(cons(1,2)) 
    -> 1

  cdr(cons(1,2)) 
    -> 2

  car(cons('a', cons(2, 3))) 
    -> 'a'