11 ms·
Scheme vs. Python (2011)
- shadowmint 11y agoThis course is taught in python now; this post is about 4 years old. Oh look, there's even a past thread about it https://news.ycombinator.com/item?id=3491142 https://news.ycombinator.com/item?id=3491142
- mixmastamyk 11y ago> Rossum, the inventor of Python, hates Lisp, but he was dragged kicking and screaming to lambda I'm not sure that's true, anyone have more details? Most people don't like the parens everywhere with lisp, but otherwise speak of it highly. Edit: thanks for the links on lambda, read all of them. However, didn't see anything obvious written about lisp itself.
- oconnor663 11y agoThis looks like Guido's version of the story: http://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html http://python-history.blogspot.com/2009/04/origins-of-python...
- tikhonj 11y ago"Kicking and screaming", to be fair, is a bit of a literary exaggeration. But Rossum did not particularly want to add functional features to the language and only did so at the behest of his users. Lambda as well as map/filter/reduce were "a significant, early chunk of contributed code", not something he intended the language to have from the outset[1]. More recently, he has been trying to deemphasize these features in favor of list comprehensions. Moreover, Rossum is opposed to proper tail calls and even recursion in general[2]. He also doesn't like folds, and generally thinks you should just express that sort of logic as some sort of loop. (I forget exactly where I read that opinion, but it could easily have been [1].) He's a staunchly imperative programmer, and the design of Python shows this off consistently except for an initial accident of first-class functions and closures (of a sort)—a design he likes because it enabled other, non-functional language features like new-style classes. "Kicking and screaming" might have been an exaggeration, but it captures his overall attitude towards functional programming pretty well. [1]: http://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html http://python-history.blogspot.com/2009/04/origins-of-python... [2]: http://neopythonic.blogspot.com/2009/04/tail-recursion-elimination.html http://neopythonic.blogspot.com/2009/04/tail-recursion-elimi...
- setheron 11y agoI just can't understand anyone who is black and white. I like when I have both tools at my disposal: recursion and iteration.
- hueving 11y agowhen you have a project concerned with readability, adding new features is a huge community cost in the long run because it's one more thing you have to learn to deal with as you go across projects. One of the wonderful things with python is that you can dig into the code of most python projects and not have to worry much about completely different idioms requiring a complete context switch to understand how they work. He is not really being black and white, he is doing a service by preventing language bloat ala C++ as much as possible.
- mhd 11y agoIt always struck me as a reaction against Perl's "Tim Toady" approach, encouraging a more idiomatic and unified programming strategy to ease comprehension and teaching (IIRC the origin of Python, or at least ABC).
- sklogic 11y agoThis is exactly what makes Python a bad language. Lack of expressive power results in an unnecessary complexity of the code. It's much easier to comprehend a short, compact code written in the familiar, domain-specific idioms rather than digging through convoluted pile of low-level leaky idioms like loops, list comprehensions, generators, classes, recursion and all that irrelevant crap.
- afc 11y agoJust wanted to add my voice: this matches exactly my perception. I used to really like Python, but I've come to the conclusion that there's a certain point in terms of the complexity of a Python program where everything just blows up and it's next to impossible to keep it from becoming a tangled mess. This point is reached incredibly soon, something like five classes with some inheritance, some interface/virtual/abstract class. Ugh. Now I avoid Python as much as possible, much preferring C++ or Java, which I think work incredibly better for larger programs.
- dalke 11y agoLambda entered Python in 1993: changeset: 1369:89e1e5d9ccbf branch: legacy-trunk user: Guido van Rossum <guido@python.org> date: Tue Oct 26 17:58:25 1993 +0000 summary: * compile.[ch]: support for lambda() so that's only two years after it was first released, and before it was 1.0. The code was user-contributed, but given the timing and the recollections at http://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html http://python-history.blogspot.com/2009/04/origins-of-python... I can't agree that the historical record is compatible with "dragged kicking and screaming to lambda." (See also http://legacy.python.org/search/hypermail/python-1994q2/0705.html http://legacy.python.org/search/hypermail/python-1994q2/0705... for his views on the topic from 1994.) Van Rossum doesn't think lambda is important, and would rather not have it in Lisp. He wanted to remove it for Python 3, but there was large opposition to that. See his viewpoint from 2005 at http://www.artima.com/weblogs/viewpost.jsp?thread=98196 http://www.artima.com/weblogs/viewpost.jsp?thread=98196 . After a large debate about alternatives (see https://wiki.python.org/moin/AlternateLambdaSyntax https://wiki.python.org/moin/AlternateLambdaSyntax ) he agreed to keep lambda in 2006 at https://mail.python.org/pipermail/python-dev/2006-February/060415.html https://mail.python.org/pipermail/python-dev/2006-February/0... .
- Psyonic 11y agoWhat a shame it would be if he'd removed it. Pyspark now makes great use of lambdas, and I'd strongly argue that having to name every function argument would be strictly worse.
- dalke 11y agoTk developers have long agreed with you, because it really is easier to say Button(frame, text="abc", command=lambda: self.highlight("abc")) than to make a function for each command. The loose consensus in Python is that lambdas are best when they fit on a line, which is what the examples at http://www.mccarroll.net/blog/pyspark2/index.html http://www.mccarroll.net/blog/pyspark2/index.html do. Otherwise, make a named function. I think arguments like this are one of the main reasons why van Rossum has kept lambda in the language.
- strontium_90 11y agoThere appears to be a website [1] for the self-paced, Scheme version of the course referenced (61AS) although it doesn't appear to be run as a MOOC formally. There's also a well-organised site for the scheduled, Python version [2] . [1]: http://www.cs61as.org/ http://www.cs61as.org/ [2]: http://cs61a.org/ http://cs61a.org/
- analognoise 11y agoI wish the lecture videos for 61AS were online, but sadly I can't find them. I think 61AS is done in Racket now, which would make it even more practical.
- ssaddi 11y agoAs a developer, I tend to be now agnostic/indifferent towards programming languages. Essentially, you can use any programming language to do the job. The difference lies in developer's comfort zone and libraries. For example, I prefer C# over VB.Net for ASP.NET/MVC backend. However, for several practical in-house projects, I've found Excel+VBA far quicker over IIS/ASP.NET project. So, it all depends on the context, your audience and usability of the project. We should not let technologies drive our projects, but our business users and current trend patterns. For example, I'm seeing a lot of JavaScript frameworks being used to deliver responsive and device-independent web applications, such as SPA (Single Page Application). Granted, it takes a while to learn a language's API, but essentially all of them do similar things. The advantages lies not in them alone, but in the entire framework/suite that it comes with. We are living in times where knowing programming languages is not as important as knowing frameworks/libraries. There are heaps of them out there that require programmer to spend more time on writing integration code to "glue them" or configuring them. We no longer need to write the low-level mundane code, but focus on delivering high-quality, rich software applications.
- fallat 11y agoYes I'm the same way, but you really can't do anything clever until you really know a programming language well. You could implement anything using the basics of language, but for it to be a good implementation, you need to have experience with the language to fully exploit its power.
- sklogic 11y ago> Essentially, you can use any programming language to do the job. Of course you can code even in Brainfuck if you want. But the difference in time and quality would easily be in orders of magnitude. > Granted, it takes a while to learn a language's API, but essentially all of them do similar things. Uhm, no, not nearly. Languages are far too different, and all of them are very specialised. There is no such thing as a general-purpose language.
- signa11 11y agocouple of quotes from the article: It's SICP that I want to preserve, not Scheme. For writing real-world code, what you want is aggressive optimization, and access to libraries for up-to-the-minute solutions to real-world problems. and ofcourse, this mindset is _exactly_ right in the context of a course for teaching programming. as much as we might fantasize about it, computers are made of metal, not lambda calculus :)
- gus_massa 11y agoI know more about Racket (that is very similar to Scheme). The compiler does a very aggressive optimizations and inlines many of the lambdas. You can write nice understandable code with lambdas, but under the hood many of them are removed and the actual running code is similar to the imperative version. In Haskell there are a lot of abstractions, the compiler is also very aggressive, but I don't know the details. Anyway, in the "Computer Language Benchmarks Game", most of the programs in Haskell and Racket are much faster (> 10x) than Python. http://benchmarksgame.alioth.debian.org/u32/compare.php?lang=ghc&lang2=python3 http://benchmarksgame.alioth.debian.org/u32/compare.php?lang... http://benchmarksgame.alioth.debian.org/u32/compare.php?lang=racket&lang2=python3 http://benchmarksgame.alioth.debian.org/u32/compare.php?lang... (But I like the saying: There are lies, dammed lies, statistics and microbenchmarks.)
- igouy 11y ago"After all, facts are facts, and although we may quote one to another with a chuckle the words of the Wise Statesman, 'Lies--damned lies--and statistics,' still there are some easy figures the simplest must understand, and the astutest cannot wriggle out of." Leonard Henry Courtney, 1895 Also, those are "toy programs" not "microbenchmarks".
- hayksaakian 11y agoI was actually enrolled in the first python version of this course. at that time it was taught by a google employee and not Brian Harvey (author of the OP, past professor of this course). For me personally, the biggest benefit of python was the large amount of accessible resources online. There were multiple ways to learn something rather than banging my head against SICP. Incidentally, writing a scheme interpreter was one of the last projects of the course. ---------- EDIT: More from the OP about this topic https://www.cs.berkeley.edu/~bh/61a.html https://www.cs.berkeley.edu/~bh/61a.html
- willtim 11y agoAt Oxford University in the UK, students are taught exclusively Haskell in their first year - a language designed by a committee of some of the worlds best computer scientists. An institution that teaches Python under the banner of computer science, certainly loses prestige in my opinion.
- collyw 11y agoI don't know the Haskell ecosystem, but my guess is that Python will have many more libraries already developed for scientific tasks.
- willtim 11y agoFor computer science, I doubt it.
- yenda 11y agoYou can doubt as much as you want it's just a fact. But I'm not saying it's good either. As much as I like python as a scripting language I don't think that's it should be use as widely as it is now. Concerning Haskel it still lacks some pragmatism to solve some pratical problems such as install and cabal hell.
- willtim 11y agoThere are countless parsing libraries, compilers and cutting edge research done in Haskell. My guess is that you are thinking of NumPy and similar wrappers over older C/Fortran code. A computer scientist would seek to design something better, perhaps by exploiting algebraic properties not considered by NumPy. Universities teaching Python is a relatively recent phenomenon, perhaps to appease industry. EDIT: cabal came from industry and was based on ideas from the Java, Python, Ruby communities. The Nix packager better embodies the ideas of Haskell.
- codygman 11y ago> Concerning Haskel it still lacks some pragmatism to solve some pratical problems such as install and cabal hell. I'd argue stack pretty much solves those: https://github.com/commercialhaskell/stack https://github.com/commercialhaskell/stack
- asgard1024 11y agoI think what makes Python unique and successful as a programming language is a strict pragmatism (rejection of any ideology) and rather conservative choices in features to add (that is, don't add everything that someone suggest, wait until we can see it's a good idea and it cannot be readily composed from existing parts). Scheme, OTOH, has some ideological choices. The whole notion of programmable programming language that comes with Lisp tradition (which includes s-expressions). The emphasis on teaching and small libraries. Attempt to somewhat model mathematics in numerical tower. These design choices, while interesting, are going against practicality. I am big fan of mathematics, Common Lisp, Haskell. There is so much beauty and elegance. And yet, when I need to get something done quickly, I will just use Python because it drops the mathematical purity without prejudice, just like a physicist working on an impossible problem.
- willtim 11y agoWhen we want to get something done, we typically reach for what is most familiar.
- asgard1024 11y agoPython wasn't my first programming language. And I think I gave a fair chance to other languages. But there come these moments where you are like "oh, this would be really simple in imperative code". Ideology gets in the way; to claim the opposite is just kidding yourself. I probably gave the most chance to Common Lisp. It's a very pragmatic language too, unfortunately (largely for historical reasons), the standard library didn't keep the pace. It's not just a matter of what you can do, it's also the design. Python standard libraries almost always put the user first and the purity second. For instance, Python would never add versions of functions remove-if, remove-if-not, delete-if, delete-if-not. That's mathematical purity (in if vs. if-not) and letting the onus of choice on user (in delete-if vs. remove-if) instead of conservatively making reasonable default. At the same time, Common Lisp library lacks things like function to strip whitespace from string; you can do it, but Python has it as a function. It's just hundreds of little things like these that make Python more pleasant to work with. I genuinely want to like Lisp more than Python (I am learning Clojure about now, which is on par with Common Lisp when it comes to pragmatism). But sometimes it is just a little more frustrating, because of ideology and not putting user first when it comes to API design.
- coldtea 11y ago>How many people reading this are 50 years old? Lisp is 50 years old — and for the most part, the lifespan of a programming language is closer to the lifespan of a dog than to that of a person. Only one other language (Fortran) is that old and still in use. Why has Lisp survived? Not because it’s useless. People still use it because you can write working code in Lisp way faster than you can in most so-called “practical” languages. Sorry to burst this bubble, but tons of languages created in the same period or 10-15 years later are still in use. Fortran, which he already mentioned. COBOL is still in use (much much more than any Lisp, just not in shiny new startups). Forth is still used here and there. C of course which is about 12 years younger but still around 40ish. Pascal is still used (in far greater numbers than Lisp). Heck, even BASIC still has tons of fans, either in VB disuise or in the the various commercial BASIC's around. With this in mind, Lisp being "50 years old and still in use" is much less impressive -- since one other 50 year old, and several 40 and 30 year old languages are still in widespread use. We use lots of 3+ decades old languages - so, it's not like we only use "new" languages and Lisp is the exception.
- icebraining 11y agoAnother 50 year old language still in use is IBM's RPG - you can even compile it to .NET bytecode nowadays. And there's also Prolog (40 years).
- mangecoeur 11y agoHell, even python is 24 years old now, it's not exactly a spring chicken in programming language terms... this observation rather supports the idea that Lisp is mostly used by old professors who think 1991 is still very recent :P
- brudgers 11y agoOne of the differences is that Lisp became relevant quickly at least in part because the digital universe was so much smaller and correspondingly so was the community of digerati. Python lived in relative obscurity throughout the 1990's and early oughts before becoming an overnight success. The same could be said for Ruby.
- kriro 11y agoIt's interesting that the PG article is cited. I've always had mixed feelings about it. On the one hand I agree that wanting to use Lisp for a startup is probably a good indicator of technical strength (yes I'm saying that people that pick Lisp as their first language are smarter than the average). On the other hand startup financing is all about the hyper growth potential and it would seem to me that basing your technology stack on Lisp could be quite the hinderance. The job market is already tough and finding people with a deep understanding of Lisp to start working on an (assumed) nontrivial Codebase isn't easy. I guess Clojure and "allowing" (or migrating to) Java could be an option? Then again some hypergrowth startups don't need many developers (WhatsApp)
- foobarian 11y agoWhen they were starting their company there was no Python/Ruby/PHP to choose over Lisp, and Java wasn't as mature. Lisp was actually quite the RAD choice at the time.
- dschiptsov 11y agoWhat students cannot understand is that after passing the classic CS61A in Scheme, languages such as Python or Julia could be picked up in a few hours with occasional consulting of reference manual for particular details. Erlang in a couple of days. Well, for Java (a dogmatic religion) one have to be thoroughly brainwashed, so there is CS61B for that.
- holografix 11y agoCan't believe you air heads are seriously comparing Scheme to Python. Scheme is a nightmare, it's only good for academics who have nothing better to do and the 1% of your projects where functional programming may actually be beneficial to what you're trying to do.
- hayksaakian 11y agoHere is a video playlist of the first Here are video playlists of all the CS courses at berkeley http://webcast.berkeley.edu/series.html#c,d,Computer_Science http://webcast.berkeley.edu/series.html#c,d,Computer_Science This is the most recent version of the CS61A course (Spring 2015) 2015 version: https://www.youtube.com/view_play_list?p=-XXv-cvA_iBM29DgZsGaQihJp8lLQn3J https://www.youtube.com/view_play_list?p=-XXv-cvA_iBM29DgZsG... first python version available online (Fall 2012) https://www.youtube.com/view_play_list?p=EC87898FD0A141069E https://www.youtube.com/view_play_list?p=EC87898FD0A141069E This is the last version of CS61 taught by Harvey (Fall 2010) https://www.youtube.com/view_play_list?p=EC6D76F0C99A731667 https://www.youtube.com/view_play_list?p=EC6D76F0C99A731667