News for hackers. Stuff that matters.
Re:Why MIT switched from Scheme to Python by jules on Tuesday March 24, 2009 @04:17PM (#530736)
> If you can convey 95% of the basic ideas in Python

But you cannot.

Some of the ideas in SICP can nearly be conveyed in Python (like lexical scoping, closures, data types, streams). You'll use built-in language features in Python (classes, generators) instead of implementing the functionality. I think that implementing these things is important if you want to really understand them.

An example, cons, car and cdr from nothing at all:

    (define (cons a b) (lambda (f) (f a b)))
    (define (car p) (p (lambda (a b) a)))
    (define (cdr p) (p (lambda (a b) b)))
You can do this in Python in theory, but you can't throw this into a Python course.

Other ideas, like interpreters, require a lot of effort. Try writing a metacircular interpreter!

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'
Re:Why MIT switched from Scheme to Python by maggie on Tuesday March 24, 2009 @04:31PM (#530755)
You need to remember that 6.001 is an /introductory/ programming course. Presumably most of the people taking it at MIT have done some codework before : ] but an intro. course is an intro. course. The question of what language to use is a pedagogical one, not a question of thoroughness.
Re:Why MIT switched from Scheme to Python by abstractbill on Tuesday March 24, 2009 @04:54PM (#530810)
But the above examples are taken straight from SICP. Wasn't that the textbook for 6.001 before they switched to Python?
Re:Why MIT switched from Scheme to Python by jerf on Tuesday March 24, 2009 @05:09PM (#530842)
Which sort of wanders back around to begging the question; is that still the best way to start teaching, as Sussman talks about?

I ask myself, "how would I teach my son to program?", and for all my copious academic and practical experience, "start with re-implementing car and cdr from lambda functions" isn't even remotely in the running. Sure, I'd introduce such things earlier than most people and SICP is still firmly in the running, but for that to be an introduction in the general case? Not so sure.

There's definitely an argument to be made that robotics is in many ways a much more realistic starting point. While some people may find the idea that we should actually start out by making a case to the students that their major is cool and important and gives them the ability to affect things in the real world vaguely repulsive, I'd say that it's an idea at least worth considering. The student that can leap from lambda, car, and cdr, to realizing that right in the introductory course is so exceptional that you're not going to hold them back anyhow.

Re:Why MIT switched from Scheme to Python by abstractbill on Tuesday March 24, 2009 @05:24PM (#530875)
Yeah, I think I actually agree with the overall point. I got my first experience of programming using BASIC to get various Sinclair computers to paint stuff on the screen and make funny beeping noises. I'm all for instant gratification.

On the other hand that was when I was 9. By 12 I was learning Lisp, and by college age I'd written my own little Lisp compiler.

I've always had this image of MIT students that doesn't quite mesh with them needing a gentle introduction to programming, but maybe that's not really the case?

Re:Why MIT switched from Scheme to Python by bk on Tuesday March 24, 2009 @05:37PM (#530900)
> I've always had this image of MIT students that doesn't quite mesh with them needing a gentle introduction to programming, but maybe that's not really the case?

If it leads to more (non-CS) students taking a programming class, I'd call it a big win. Other fields can benefit greatly from programming skills. I'd almost go as far as calling it a new form of literacy.

Re:Why MIT switched from Scheme to Python by irrelative on Tuesday March 24, 2009 @07:27PM (#531070)
Absolutely I'd call it a new form of literacy. The most impressive applications of computer science always happen outside the realm of computer science disciplines.
Re:Why MIT switched from Scheme to Python by jjames on Tuesday March 24, 2009 @05:33PM (#530892)
"I've always had this image of MIT students that doesn't quite mesh with them needing a gentle introduction to programming, but maybe that's not really the case?"

6.001 from my experience does not in any way imply a student's focus on computer programming or software development. I've heard horror stories about people in completely unrelated majors ending up in that class and having their brains thoroughly melted. In my personal opinion, Python will be considerably more humane in that department.

Re:Why MIT switched from Scheme to Python by wheels on Tuesday March 24, 2009 @07:39PM (#531089)
There are probably a lot of physics, math and engineering students taking intro to programming that haven't written a line of code before.

I'd assume most, if not all, computer science students have, but there's still a difference from learning to bang out some code in high school that does neat things, vs. starting back at the beginning and approaching it as, well, computer science.

The way my university covered it was doing Pascal for the intro courses (this was the mid-90s) and then in third-semester "Programming Languages" we worked mostly in Scheme implementing language fundamentals. That seemed to be a reasonable balance.

Re:Why MIT switched from Scheme to Python by Kaizyn on Wednesday March 25, 2009 @07:22PM (#532625)
6.001 presumed the students had prior exposure to college physics and calculus mathematics. If your son has this level of foundational knowledge, then SICP probably would be the most efficient way to bring someone up to speed on programming. If they have not attained that level of education, then this isn't the best intro point to computer science. Predicate logic and set theory is probably a better starting point. Or if you're feeling particularly cruel, Java. :-)