Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63045 > unrolled thread

Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

Started byChris Seberino <cseberino@gmail.com>
First post2014-01-02 22:46 -0800
Last post2014-01-04 07:38 +1100
Articles 10 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  Is Python really "Lisp without parentheses"?  So would it be easy to *implement* a lot of Python in Scheme/Lisp? Chris Seberino <cseberino@gmail.com> - 2014-01-02 22:46 -0800
    Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Rustom Mody <rustompmody@gmail.com> - 2014-01-03 15:30 +0530
      Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Chris Seberino <cseberino@gmail.com> - 2014-01-03 08:50 -0800
        Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Rustom Mody <rustompmody@gmail.com> - 2014-01-03 23:03 +0530
    Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-03 09:10 -0800
      Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Chris Seberino <cseberino@gmail.com> - 2014-01-03 09:26 -0800
        Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-03 10:32 -0800
          Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Chris Seberino <cseberino@gmail.com> - 2014-01-03 22:48 -0800
      Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp? Roy Smith <roy@panix.com> - 2014-01-03 12:26 -0500
    Re: Is Python really "Lisp without parentheses"?  So would it be easy to *implement* a lot of Python in Scheme/Lisp? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-04 07:38 +1100

#63045 — Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromChris Seberino <cseberino@gmail.com>
Date2014-01-02 22:46 -0800
SubjectIs Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<f51999a3-3302-4a7f-bfdb-756983e72fe3@googlegroups.com>
I've heard it said, by no less a guru than Peter Norvig, that Python is a lot like Lisp without the parentheses.... at least for the basics of Python.

For pedagogical reasons, I'm wondering if it would be easy to implement a big subset of Python in Scheme.  

The basics of Scheme or Lisp are amazingly easy to implement.  Would implementing a subset of Python in a Scheme subset be a clever way to easily implement a lot of Python?

(This isn't for practical reasons....I'm just curious.)

Chris

[toc] | [next] | [standalone]


#63046 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromRustom Mody <rustompmody@gmail.com>
Date2014-01-03 15:30 +0530
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<mailman.4843.1388743262.18130.python-list@python.org>
In reply to#63045
On Fri, Jan 3, 2014 at 12:16 PM, Chris Seberino <cseberino@gmail.com> wrote:
> I've heard it said, by no less a guru than Peter Norvig, that Python is a lot like Lisp without the parentheses.... at least for the basics of Python.
>
> For pedagogical reasons, I'm wondering if it would be easy to implement a big subset of Python in Scheme.
>
> The basics of Scheme or Lisp are amazingly easy to implement.

Because parsing and unparsing (aka printing) are so trivial for s-expressions

> Would implementing a subset of Python in a Scheme subset be a clever way
> to easily implement a lot of Python?

At the innards of lisp and python are garbage collected data structures.
Building one with the other gets you that for free
[Doing it in a lower level language like C is what invokes the humorous:
Greenspuns tenth law]
So yes in that one respect what you say is true.
But then theres also (apart from parsing) all kinds of semantic differences eg:
- exceptions
- modules
- OOP milarky
- C interfacing in Baskin Robbins number of flavours
- carefully crafted portable veneer on top of intrinsically non portable OSes

All these have to be handled one way or other

>
> (This isn't for practical reasons....I'm just curious.)

A crucial difference between python and lisp is that python is
practical and lisp is utopian

[toc] | [prev] | [next] | [standalone]


#63072 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromChris Seberino <cseberino@gmail.com>
Date2014-01-03 08:50 -0800
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<374d1574-94f8-4817-8406-23d6f38fc740@googlegroups.com>
In reply to#63046
Exceptions, modules, OOP, etc. would be tricky to implement in Scheme but at least the basics like for loops, while loops, assignment etc. would seem doable and very instructive for students.....they would thereafter, for all time, have a mental image of what the Python interpreter is doing.


> But then theres also (apart from parsing) all kinds of semantic differences eg:
> 
> - exceptions
> 
> - modules
> 
> - OOP milarky
> 
> - C interfacing in Baskin Robbins number of flavours
> 
> - carefully crafted portable veneer on top of intrinsically non portable OSes
> 
>

[toc] | [prev] | [next] | [standalone]


#63078 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromRustom Mody <rustompmody@gmail.com>
Date2014-01-03 23:03 +0530
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<mailman.4865.1388770450.18130.python-list@python.org>
In reply to#63072
On Fri, Jan 3, 2014 at 10:20 PM, Chris Seberino <cseberino@gmail.com> wrote:
>
> Exceptions, modules, OOP, etc. would be tricky to implement in Scheme but at least the basics like for loops, while loops, assignment etc. would seem doable and very instructive for students.....they would thereafter, for all time, have a mental image of what the Python interpreter is doing.

If thats the intent, sure, scheme is heaven for such
In particular, take a language, break it up into a dozen or so
'little-languages' eg
one for types, one for control structures, one for scoping/parameter
passing etc while 'stubbing out' the rest -- for such scheme is simply
unbeatable.
And this includes IDEAS of oop modules etc.

Its only when you then start demanding: "Why cant this become
realistic?" that things start creaking and groaning at the edges

A simple example:
One of the much touted features of modern functional languages like
Haskell (actually its the SML family) is pattern matching. I
implemented a macro -- destruct -- to do it in scheme -- all of 91
lines!

Now one gets greedy and says: "Hey! Neat! Only small catch is that
haskell patterns looks so much neater than these home-cooked
Lots-of-Irritating-Single-Parenthesis (aka Lisp-y) patterns." And
Wham! The shit begins to hit the ceiling

To my mind, scheme is so powerful that even Abelson and Sussman dont
get how powerful.  I wrote a blog post on that but then diluted the
title :D
http://blog.languager.org/2013/08/applying-si-on-sicp.html

On the whole though, functional languages are distinctly weaker than
lisps but much easier for students.  Heres an old Wadler paper
explaining that:
http://www.cs.kent.ac.uk/people/staff/dat/miranda/wadler87.pdf

[toc] | [prev] | [next] | [standalone]


#63073 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromDevin Jeanpierre <jeanpierreda@gmail.com>
Date2014-01-03 09:10 -0800
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<mailman.4862.1388769050.18130.python-list@python.org>
In reply to#63045
On Thu, Jan 2, 2014 at 10:46 PM, Chris Seberino <cseberino@gmail.com> wrote:
> I've heard it said, by no less a guru than Peter Norvig, that Python is a lot like Lisp without the parentheses.... at least for the basics of Python.

There are plenty of non-superficial differences. Python has lexical
scope, lisps usually have dynamic scope. Python has statements and
expressions, lisps have expressions and maybe only a few tiny extra
restrictions. Python has dynamic dispatch everywhere, lisps have it
usually almost nowhere. And the unifying thing that makes a lisp a
lisp is macros, which Python lacks.

> For pedagogical reasons, I'm wondering if it would be easy to implement a big subset of Python in Scheme.

A lecturer of mine back in university did this (implemented a subset
of Python in Racket). My understanding is that this is primarily
interesting to show that Racket is not as crazily different as it
looks from the syntax.

When I TA'd for him, he had a really neat lecture where he gave the
following three snippets of code:

// C++
Foo x = y;
x.bar = 3;

// Java
Foo x = y;
x.bar = 3;

// Scheme
(define x y)
(foo-bar x 3)

The syntax of the first two is identical, so the uneducated would
assume they do the same thing. But actually, the latter two are the
ones with the identical behaviour. It is definitely true that the
syntax differences hide how similar Scheme and Python are. These two
languages are close enough together that any

> The basics of Scheme or Lisp are amazingly easy to implement.  Would implementing a subset of Python in a Scheme subset be a clever way to easily implement a lot of Python?

If it's easy to implement in terms of Scheme, which is itself easy to
implement, then it would be easy to implement directly, so this
doesn't seem like a useful question to ask. Anyway, most of the useful
bits of Python aren't present or have different semantics than how
they work in lisps.

-- Devin

[toc] | [prev] | [next] | [standalone]


#63075 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromChris Seberino <cseberino@gmail.com>
Date2014-01-03 09:26 -0800
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<4d0281ee-2b28-484b-943d-666ea40800df@googlegroups.com>
In reply to#63073
On Friday, January 3, 2014 11:10:07 AM UTC-6, Devin Jeanpierre wrote:

> A lecturer of mine back in university did this (implemented a subset
> 
> of Python in Racket). My understanding is that this is primarily
> 
> interesting to show that Racket is not as crazily different as it
> 
> looks from the syntax.

Is that on the web anywhere?  That would be very interesting to look at.  I'm sure others would find it useful too.

[toc] | [prev] | [next] | [standalone]


#63080 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromDevin Jeanpierre <jeanpierreda@gmail.com>
Date2014-01-03 10:32 -0800
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<mailman.4866.1388774011.18130.python-list@python.org>
In reply to#63075
On Fri, Jan 3, 2014 at 9:26 AM, Chris Seberino <cseberino@gmail.com> wrote:
> On Friday, January 3, 2014 11:10:07 AM UTC-6, Devin Jeanpierre wrote:
>> A lecturer of mine back in university did this (implemented a subset
>> of Python in Racket). My understanding is that this is primarily
>> interesting to show that Racket is not as crazily different as it
>> looks from the syntax.
>
> Is that on the web anywhere?  That would be very interesting to look at.  I'm sure others would find it useful too.

As far as I know, no. There was an early version of it that was part
of a course, but as I understand it he did something much more
thorough later on. Even that course content seems to be offline and
not very available by archive.org; the relevant bits aren't archived:
https://web.archive.org/web/20111119221012/http://www.cs.toronto.edu/~gfb/csc324/2010F/content.shtml

Feel free to dig around and try to find something, but as I recall the
assignment on that page was to write some very minor interpreter
actions with a list generated from the AST of a python source file.
His later work was translating Python to Racket, with macros to
implement various Python operations. That wasn't an assignment or
course content, it was stuff he'd show to students during office hours
and such.


I believe the end goal was to turn it into a real tool for teaching
programming. The idea there was that Python is 90% irrelevant to
teaching students how to program, and the full generality of Python
makes it harder for students to learn due to weird behaviours or
unreasonable complexity. If you decide to only implement the 10% of
Python that you care to teach, then it's much easier to implement (in
fact, without that, the goal isn't even achievable for one person),
plus it serves your goals potentially better than Python does.

Regardless of if it's a particularly good idea, this is what Python
must look like if you try to elegantly directly translate it to Scheme
(or any lisp), just because the semantics will be so different once
you get out of the basics and the trivial things. If the translation
is to be clean, the input language can't actually be Python. If the
input language is Python, the output will be a horrible mess that
isn't useful for the student, and also it will take a lot of work
until it is even correct. Scheme is far simpler and smaller than
Python is.

-- Devin

[toc] | [prev] | [next] | [standalone]


#63120 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromChris Seberino <cseberino@gmail.com>
Date2014-01-03 22:48 -0800
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<58c2b080-cc39-4c10-b407-e5c9124ad814@googlegroups.com>
In reply to#63080
Thanks.. I think your 10% Python idea is the way to go.  And you are right
that most of Python is not needed in an intro course.  

[toc] | [prev] | [next] | [standalone]


#63076 — Re: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?

FromRoy Smith <roy@panix.com>
Date2014-01-03 12:26 -0500
SubjectRe: Is Python really "Lisp without parentheses"? So would it be easy to *implement* a lot of Python in Scheme/Lisp?
Message-ID<roy-7A13FC.12263503012014@news.panix.com>
In reply to#63073
In article <mailman.4862.1388769050.18130.python-list@python.org>,
 Devin Jeanpierre <jeanpierreda@gmail.com> wrote:

> // C++
> Foo x = y;
> x.bar = 3;
> 
> // Java
> Foo x = y;
> x.bar = 3;
> 
> // Scheme
> (define x y)
> (foo-bar x 3)
> 
> The syntax of the first two is identical, so the uneducated would
> assume they do the same thing. 

This is one of the things that tripped me up when I first tried to learn 
JavaScript.  They syntax is superficially identical to C++, so I assumed 
it worked the same way.  Bad assumption.

[toc] | [prev] | [next] | [standalone]


#63083

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-01-04 07:38 +1100
Message-ID<52c71fd0$0$29999$c3e8da3$5496439d@news.astraweb.com>
In reply to#63045
Chris Seberino wrote:

> The basics of Scheme or Lisp are amazingly easy to implement.  Would
> implementing a subset of Python in a Scheme subset be a clever way to
> easily implement a lot of Python?

I don't know how easy it was, but it was done:

http://common-lisp.net/project/clpython/



-- 
Steven

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web