Live data from Hacker News

Why MIT switched from Scheme to Python

wisdomandwonder.com

41–50 of 140 posts

Re: Why MIT switched from Scheme to Python

#41
post #36
post #28

Earlier quoted context omitted.

Yes, I use PyOpenGL in GTK (with GTKGLExt). People have said good things about Gazebo, but I haven't used it. Most of the 3D stuff is performance-critical, so I typically prototype in Python and then convert to C++, which for graphics code isn't too painful. The Boost.Python interface makes it pretty easy. Also, the Cairo graphics interface is wonderful for drawing charts, animated robot stick figures, and many other…

Nice. Yeah, the GL graphics code is pretty easy to convert to C++ when performance matters. It's wonderful to quickly prototype graphics code in Python with full error checking. Also, if you haven't used it yet, check out Py++. It takes a lot of the pain out of hand-authoring a Boost.Python code file. I'm using Py++ to automatically generate Boost.Python bindings for the C++ library FCollada. (FCollada is a library f…

My point was there's no single 'gl.Vertex3' call that takes native Lisp numbers. Thinking about double/float/int/short should be abstracted out below the Lisp level.

We use OpenGL to show real-time renderings of the robot, derived from the gyros and joint angle sensors. We have an analysis tool that shows, either in real time or post-run analysis, renderings synchronized with high-speed video of the robot and scrolling strip charts of every important variable over time. I always see much more looking at slow-motion videos & renderings afterwards than looking at the real robot.

OpenGL rendering also turned out to be useful for extracting data from CAD models. Our CAD software (SolidWorks) can export STL files (a list of polygons) and we need to extract center of mass and moment of inertia and such. Doing that without visualizing it is a nightmare.

We have done dynamics simulations (using ODE), but they haven't had much predictive value.

Re: Why MIT switched from Scheme to Python

#42
post #33

I wonder, if the switch had been made now, it they would have switched to Clojure instead of Python. It's a lot closer to Scheme, and its connection to the JVM gives it a lot of practical power. Does anyone have any thoughts on this?

People often say that Java has great libraries, but is it true? AWT is crufty and ugly. Maybe there are impressive XML parsers (Xerxes is 188,000 lines of Java!), but I don't want those. Numerical libraries seem bad. So what is the library that might convince me to use Java for something?

"The" library is which ever squirrelly database, file format, app, etc. your next project needs to talk to which doesn't have bindings for your favorite language. You compromise on Java to avoid writing that by hand and use a JVM language to avoid the pain of actually using Java.

Re: Why MIT switched from Scheme to Python

#43
post #24

Earlier quoted context omitted.

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…

> 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.

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

#44
post #41
post #36

Earlier quoted context omitted.

Nice. Yeah, the GL graphics code is pretty easy to convert to C++ when performance matters. It's wonderful to quickly prototype graphics code in Python with full error checking. Also, if you haven't used it yet, check out Py++. It takes a lot of the pain out of hand-authoring a Boost.Python code file. I'm using Py++ to automatically generate Boost.Python bindings for the C++ library FCollada. (FCollada is a library f…

My point was there's no single 'gl.Vertex3' call that takes native Lisp numbers. Thinking about double/float/int/short should be abstracted out below the Lisp level. We use OpenGL to show real-time renderings of the robot, derived from the gyros and joint angle sensors. We have an analysis tool that shows, either in real time or post-run analysis, renderings synchronized with high-speed video of the robot and scrolli…

Ah. Very cool.

Are you computing center of mass / moment of inertia yourself, or using a 3rd party library to do it? PhysX is free, and I believe it can do those calculations for you fairly automatically. (In PhysX, a 'scene' is composed of 'actors', and each actor is described by a set of shape descriptors. A shape descriptor can represent a box, a sphere, a capsule, a convex hull, etc. So a laptop actor could crudely be approximated with two box shape descriptors (one for the screen, one for the body) connected by a joint. Given those shape descriptors, the library calculates the actor's center of mass / moment of inertia / etc. If your CAD software simply exports a list of polygons, you'll need to decompose those into a set of convex hulls using convex hull decomposition techniques: http://codesuppository.blogspot.com/2006/04/approximate-conv... ) You also might have better luck running dynamics simulations with PhysX than with ODE. It comes with a large number of code examples to get you started: http://developer.nvidia.com/object/physx_downloads.html

Re: Why MIT switched from Scheme to Python

#45
post #19

Earlier quoted context omitted.

My concern is that "practicality" is often just a code word for "resembles Java or whatever else I was comfortable with so I can continue on doing what I've always done before." (With the result that the student learns less than if they were required to do something truly different.) Reminds me of this post that came up on HN not too long ago: http://funcall.blogspot.com/2009/03/not-lisp-again.html

I think here, "practicality" means "has a library for controlling robots". Also a good numeric library, a good matlab-like graphing library, good 3D graphics, good real-time performance, easy C++ embedding, etc. Rather than complaining about how everyone else is a bonehead for not using Lisp, write some libraries to make it useful for more things in the real world. Also, Python does pretty well for real-time control.…

Libraries aren't the issue. I use Chicken Scheme for a few things, which has plenty of libraries and a fantastic package system called eggs. Sure, other languages like Perl and Python have more libraries now, but that's not what made them popular.

What made them popular was the design of the core languages. I started using Ruby because it was faster to type and easier to remember how to do things than Perl, not because it had more libraries, which it didn't.

The problem with Scheme is that the core language isn't terse enough, and so it gives the impression that it will be hard to do things. And that's correct. Scheme requires much more typing and is harder to remember than Ruby.

Consider:

Ruby:

  h = {}
  h[:foo] = "hi"
  h[:foo] #=> "hi"
  h[:bar] #=> nil
Scheme (Chicken):

  (define h (make-hash-table))
  (hash-table-set! h 'foo "hi")
  (hash-table-ref h 'foo) ;; "hi"
  (hash-table-ref/default h 'bar #f) ;; #f
That, in a nutshell, is why people don't use Scheme. The people who made Perl etc. popular hate typing, and the core language of Scheme forces you to type a ton. There are other problems like really slow string functions, things that should be core being in SRFIs, libraries being called "SRFI 18" rather than normal things like "threads" so that it's extra hard to tell where a function is coming from, where its documentation is, or what you have to import to get it. Lack of libraries (if indeed that's a problem for you) is downstream of the core problem, which is that Scheme has a lot of clumsy design features that discourage would-be library writers from using the language a lot.

This isn't a Lisp problem, it's a Scheme one. A Lisp with a better core and enough users would get lots of libraries eventually, just like any language.

I think Scheme is good for teaching though, and would rather learn it in a course than Python.

Re: Why MIT switched from Scheme to Python

#46
post #17

Earlier quoted context omitted.

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 firml…

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…

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

#47
post #10
post #3

I think there's something else here, implicit in Sussman's comment, that's important. MIT was founded on a philosophy of practicality, and everything else is secondary. If you couple that with the belief that fundamental computer science is the most efficient way to enhance practical software engineering, Scheme was a wonderful choice. Java and C++ may have been more directly practical to software engineers, but they…

> 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 fro…

Um... Yes you can. Here is your above example:

    >>> def cons(a, b):
    ...  def lm(f):
    ...   return f(a, b)
    ...  return lm
    ... 
    >>> def car(cns):
    ...  return cns(lambda a, b: a)
    ... 
    >>> def cdr(cns):
    ...  return cns(lambda a, b: b)
    ... 
    >>> x = cons(1, 2)
    >>> car(x)
    1
    >>> cdr(x)
    2
Most scheme code translates relatively cleanly into python code. The biggest problem in translation comes when code wants to modify variables in a closure. Since SICP is primarily concerned with functional programming, this is a non-issue. Furthermore, Python 3.0 includes the nonlocal statement which fixes this problem (details here: http://www.python.org/dev/peps/pep-3104/). Python is not lisp but its pretty darn close and unlike lisp (or scheme in this case), it has a well designed, well tested standard library -- something extremely important in programming languages today. In light of this information, MIT's decision to move to Python is justified.

Re: Why MIT switched from Scheme to Python

#48
post #33

I wonder, if the switch had been made now, it they would have switched to Clojure instead of Python. It's a lot closer to Scheme, and its connection to the JVM gives it a lot of practical power. Does anyone have any thoughts on this?

People often say that Java has great libraries, but is it true? AWT is crufty and ugly. Maybe there are impressive XML parsers (Xerxes is 188,000 lines of Java!), but I don't want those. Numerical libraries seem bad. So what is the library that might convince me to use Java for something?

I don't know why people even bother with XML when it is so much easier to write S-Expression generators and parsers.

Re: Why MIT switched from Scheme to Python

#49
post #7

Earlier quoted context omitted.

Python may not be a scheme, but it does have what they used to call functional programming, low-grade continuations with the generators, and some other stuff like that. Python may not stuff its academic credentials in your face, but I think it has one of the better balances between what you can use it to teach, and what you must teach to use it. (Referencing the common and IMHO justified complaint that the simplest p…

Python has some issues that can really interfere with doing Scheme-style FP in in it (no tail-call optimization, single-expression-only lambdas, closure/scope problems, general hostility from Guido), but IMHO it's a great general-purpose language, and well suited to teaching, particularly for introducing higher-order functions. Lua has much more Scheme influence than Python does (while being otherwise pretty similar)…

Yeah, that's why I called it "what they used to call functional programming". Functions are first-class values and closures are easy to get at. (Some people quibble with the exact implementation, but they are definitely there. Such people will be happier with Python 3.0, but still not entirely satisfied.) This is what "functional programming" used to mean.

Now it means having immutable values, tail recursion, easy lambdas, powerful type systems, and so on. There's a clear historical progression from past to present, but there's still been changes in what the term means over time which means that different people mean different things by "functional programming" if they don't clarify.

Re: Why MIT switched from Scheme to Python

#50
post #19

Earlier quoted context omitted.

I think here, "practicality" means "has a library for controlling robots". Also a good numeric library, a good matlab-like graphing library, good 3D graphics, good real-time performance, easy C++ embedding, etc. Rather than complaining about how everyone else is a bonehead for not using Lisp, write some libraries to make it useful for more things in the real world. Also, Python does pretty well for real-time control.…

Rather than complaining about how everyone else is a bonehead for not using Lisp, write some libraries to make it useful for more things in the real world. Thank you. Cannot stress this enough. (Making said libraries portable helps, too!)

[deleted]
Post reply on HN