all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: becoming a lisp developer
Date: Wed, 27 Jun 2012 18:09:36 +0200	[thread overview]
Message-ID: <87ehp0pwhr.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.3561.1340811384.855.help-gnu-emacs@gnu.org

ken <gebser@mousecar.com> writes:

> Yes, the latter sort of expression, where the operand is at the
> beginning of the expression, is called reverse-polish.  

Of course not.

> There was at
> least one hand-held scientific calculator which came out in the
> mid-1970s which used this notation.  

No, it used the Reverse Polish Notation ("RPN"), in which, the arguments
are first, and the operators are suffixed.

    12  45  +  --> 57

In Lisp, we use the fully parenthesized Polish Notation!

   (+ 12 45)    --> 57

The reasons we use parentheses is that:

1- it allows us to deal easily with variadic operations

      (+ 1 2 3 4)    ; lisp

      + + + 1 2 3 4  ; Polish

2- it allows us to deal with fixed-arity operations WITHOUT HAVING TO
   KNOW what their arity is.  This is important to be able to write
   macros easily.


> Though it took only a few seconds
> to adjust one's thinking to this syntax, that sort of syntax on such
> devices pretty much died out (AFAIA), people, not surprisingly,
> preferring a notation which conformed more closely to natural
> language.

Not at all.  Discriminating user of hand-held calculators still prefer
HP calculators for its RPN.
http://welcome.hp.com/country/us/en/prodserv/calculator.html


> Conforming to natural language has long been a goal of
> cyber-language developers, for understandable reasons: less attention
> to syntactic anomolies allows for more attention to logic and so too
> then probably better applications.

And this has been a failure in all case, because natural language is by
nature ambiguous, which is a deal breaker for algorithmics and
programming languages.


> But, yes, just this once instance is trivial.  Back in the 1980s I
> wrote an expression parser (in C).  I remember being quite surprised
> how little code it required, just ten or twelve lines IIRC.  It was so
> pleasing in its terseness and elegance that I assigned the same task
> to my college students to exercise our discussion on recursion.  (To
> make it a homework assignment they could do in a week, their C code
> needn't perform error checking, but rather assume that all expressions
> their programs would read in were well formed, nor would they need
> consider critically heavy burdens on the stack due to very deep
> nesting.)  This function/program was intended to parse C-style syntax
> (e.g., "(2 + (5 * 3))"), but it would be trivial to alter it to parse
> reverse-polish, or vice versa-- which offers up the question, why
> require text to be parsed to conform to one syntactical ruleset as
> opposed to another?  The code for the parser is nigh identical... so
> why not cut developers a small break by conforming more closely to
> natural language?

That's the wrong question (see above).  The right question would be, why
the editors wouldn't present the same Sexp-based representation of
program sources, in the syntax the user prefers.

In emacs you could easily unparse sexp files into any kind of syntax,
and parse it again upon saving to write back sexps.

That's exactly what lisp does, but lisp programmers (in general) just
like to write directly the sexps, instead of dealing with artificial and
useless syntax layer.


>> What's more important to understand the meaning of those programs, is
>> their semantics.
>>
>> In a 32-bit C, (ie. a C where int has a 32-bit two-complement
>> representation), the result would be -2072745071 with some compiler.
>> (In some other C compilers, it could signal a run-time error, the C
>> standard doesn't specify what must happen).
>>
>> In a 64-bit C, (ie. a C where int has a 64-bit two-complement
>> representation), the result would be 2222222225.
>>
>> In a 32-bit emacs, which has no bignums and where fixnums are limited to
>> 29-bit two-complement the result would be 74738577.
>>
>> In a 64-bit emacs, which has still no bignums, but where fixnums are
>> limited to 61-bit two-complement, the result would be 2222222225.
>>
>> In a Common Lisp implementation, which therefore has bignums, whatever
>> the size of the fixnums, the results would be 2222222225.
>>
>> ....
>
> Thank goodness such concerns are seldom central to applications
> developers, systems developers having for the most part isolated app
> developers from hardware vagaries (as von Neuman intended).  This
> however has long been an area requiring more co-operation between
> hardware and systems folks.

You mean, to Common Lisp application developers.
But not to

1- emacs application developers,

2- C or C++ application developers,

3- any other language that doesn't provide bignums,

4- any programming language (included Common Lisp!) that doesn't provide
   real Real numbers (eg. using the reallib library). 
   http://www.daimi.au.dk/~barnie/RealPractical.pdf


Otherwise, given that there's still no cl-reallib, and that most other
programming language don't have bignums for integers, then it's
obviously a central concern for any application developers!  Just try to
write a program to compute the US debt!  Or the next Fed quantitative easing!




>> The semantical differences are therefore:
>>
>> In Common Lisp, + for integers implements the mathematical integer
>> addition (up to the available memory).
>>
>> In emacs lisp, + for integers implements the addition modulo 29 or 61
>> depending on the machine word size.
>>
>> In C, + for int may implement the addition modulo 32 or 64, or something
>> else (including signaling a run-time error, or a compilation-time error).
>
> Yes, if these were the only barriers to understanding, for all
> practical purposes, there effectively be no barriers at all.

That wasn't my point.  My point was that since even for the simpliest
operation there are big semantics difference, you can expect that
learning a language in a different category of language be something
that either:

1- is hard, or

2- require that you empty your mind and start from a blank slate.




>> The conclusion is that to learn a programming language in a different
>> category of what you know already, you must forget what you know, and
>> just learn it from the beginning.
>
> I wouldn't say, "forget what you know" but rather "don't make
> assumptions about one language based solely on knowledge from another
> language."  

You may express it like that.  But it looks like for most people it
would be easier to forget than to keep knowledge about different things
separate.

> As you pointed out above, while there are many differences, there are
> also many similarities.  We don't really want to forget and then have
> to relearn the similarities.

    It is practically impossible to teach good programming to students
    that have had a prior exposure to BASIC: as potential programmers
    they are mentally mutilated beyond hope of regeneration. 

http://www.cs.virginia.edu/~cs655/readings/ewd498.html


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


  parent reply	other threads:[~2012-06-27 16:09 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2952.1339986753.855.help-gnu-emacs@gnu.org>
2012-06-18  3:22 ` Emacs users a dying breed? Pascal J. Bourguignon
2012-06-18  9:32   ` djc
2012-06-18 10:25     ` Pascal J. Bourguignon
2012-06-18 17:09     ` Ken Goldman
2012-06-21 15:27 ` rusi
2012-06-22  6:19   ` Tom
2012-06-22  8:45     ` Jeremiah Dodds
2012-06-22  9:40       ` Tom
2012-06-22 11:07         ` Bastien
2012-06-22 11:16           ` Andreas Röhler
2012-06-24 23:19             ` James Freer
2012-06-25  7:23               ` give emacs --daemon / emacsclient a try (was: Re: Emacs users a dying breed?) Gregor Zattler
     [not found]             ` <mailman.3407.1340581002.855.help-gnu-emacs@gnu.org>
2012-06-25  2:58               ` Emacs for writers (was " rusi
2012-06-25  9:38                 ` James Freer
2012-06-26 21:47                   ` James Freer
     [not found]                   ` <mailman.3534.1340747277.855.help-gnu-emacs@gnu.org>
2012-06-27  3:41                     ` rusi
2012-06-22 13:13           ` Emacs users a dying breed? Tom
     [not found]           ` <mailman.3233.1340370922.855.help-gnu-emacs@gnu.org>
2012-06-22 14:12             ` Jay Belanger
2012-06-22 15:02               ` Tom
     [not found]               ` <mailman.3245.1340377350.855.help-gnu-emacs@gnu.org>
2012-06-22 18:25                 ` John Bokma
2012-06-22 11:17         ` Jeremiah Dodds
2012-06-22 12:03           ` Andreas Röhler
2012-06-22 12:21             ` Richard Riley
2012-06-22 13:04               ` Jonathan Groll
2012-06-23 11:33                 ` Philipp Haselwarter
2012-06-23 12:05                   ` Teemu Likonen
2012-06-23 12:35                     ` Philipp Haselwarter
2012-06-23 12:53                       ` Eli Zaretskii
2012-06-23 13:53                       ` S Boucher
2012-06-23 12:37                     ` suvayu ali
2012-06-25 19:00                   ` Ken Goldman
2012-06-23 14:02               ` S Boucher
2012-06-22 12:46             ` Thien-Thi Nguyen
2012-06-22 13:27               ` Andreas Röhler
2012-06-22 13:45               ` Doug Lewan
2012-06-22 13:09           ` Tom
2012-07-02 11:36             ` Mihamina Rakotomandimby
2012-06-22 15:08 ` Issues with emacs (was Emacs users a dying breed?) rusi
2012-06-22 15:26   ` Issues with emacs Pascal J. Bourguignon
2012-06-23  2:28     ` rusi
2012-06-23  9:47       ` Pascal J. Bourguignon
2012-06-22 16:41   ` Issues with emacs (was Emacs users a dying breed?) Drew Adams
2012-06-22 18:01     ` Bastien
2012-06-23 20:04       ` Tom
2012-06-24 11:38         ` Eric Abrahamsen
2012-06-24 14:00           ` Drew Adams
2012-06-25 19:23           ` Ludwig, Mark
     [not found]         ` <mailman.3361.1340537904.855.help-gnu-emacs@gnu.org>
2012-06-24 13:52           ` Issues with emacs Pascal J. Bourguignon
     [not found]       ` <mailman.3330.1340481863.855.help-gnu-emacs@gnu.org>
2012-06-23 23:49         ` Dan Espen
2012-06-24  1:24           ` Pascal J. Bourguignon
2012-06-24  2:39           ` ken
2012-06-25 18:02             ` Sivaram Neelakantan
2012-06-26  3:03               ` becoming a developer [was: Re: Issues with emacs] ken
     [not found]               ` <mailman.3485.1340679833.855.help-gnu-emacs@gnu.org>
2012-06-26  3:23                 ` rusi
     [not found]                   ` <CAPyVhy_fL3KLrNzqOMbg69UqUMAKPmXbbu7gVYQcK+KiML44hA@mail.gmail.com>
     [not found]                     ` <CAJ+Teof7T6qXdztq_Pjh+S8gVXQV-ToYJ6EQrPNYQAumn_aDOA@mail.gmail.com>
2012-06-27 13:38                       ` antoine no
2012-06-27 17:44                         ` Aurélien Aptel
2012-06-26 12:29                 ` becoming a lisp developer Pascal J. Bourguignon
2012-06-27 15:36                   ` ken
2012-06-27 16:12                     ` PJ Weisberg
     [not found]                   ` <mailman.3561.1340811384.855.help-gnu-emacs@gnu.org>
2012-06-27 16:09                     ` Pascal J. Bourguignon [this message]
     [not found]             ` <mailman.3455.1340647361.855.help-gnu-emacs@gnu.org>
2012-06-25 18:40               ` Issues with emacs notbob
2012-06-25 19:05                 ` Glyn Millington
     [not found]           ` <mailman.3348.1340505598.855.help-gnu-emacs@gnu.org>
2012-06-24  6:39             ` rusi
2012-06-24  7:01               ` Corentin Henry
2012-06-24  7:55                 ` Andreas Röhler
2012-06-24 16:04                   ` Eli Zaretskii
2012-06-24 17:38                     ` Andreas Röhler
2012-06-24 18:21                       ` Eli Zaretskii
     [not found]                 ` <mailman.3355.1340524541.855.help-gnu-emacs@gnu.org>
2012-06-24 12:17                   ` notbob
2012-06-24 13:24                     ` Deniz Dogan
2012-06-24 14:42                       ` Yuri Khan
2012-06-24 15:08                       ` Gregory Benjamin
2012-06-25 19:26                         ` Deniz Dogan
2012-06-24 16:24                       ` Eli Zaretskii
2012-06-25 19:25                         ` Deniz Dogan
2012-06-24 13:36                     ` Richard Riley
     [not found]                     ` <mailman.3362.1340544276.855.help-gnu-emacs@gnu.org>
2012-06-24 14:03                       ` notbob
2012-06-24 16:01                 ` Eli Zaretskii
2012-06-24 10:14               ` Rainer M Krug
2012-06-24 14:18                 ` Drew Adams
2012-06-24 15:41                   ` Rainer M Krug
2012-06-24 16:07                     ` Drew Adams
2012-06-24 16:48                       ` Rainer M Krug
     [not found]               ` <mailman.3354.1340521292.855.help-gnu-emacs@gnu.org>
2012-06-24 12:15                 ` notbob
2012-06-24 14:02               ` Drew Adams
2012-06-25  3:54               ` ken
     [not found]               ` <mailman.3424.1340596458.855.help-gnu-emacs@gnu.org>
2012-06-25  5:51                 ` rusi
2012-06-25  7:45                   ` Helmut Eller
2012-06-25  8:57                     ` Tom
2012-06-25 21:24                       ` Jeremiah Dodds
2012-06-26  5:50                         ` Tom
2012-06-26 20:08                           ` Jeremiah Dodds
     [not found]                         ` <mailman.3486.1340689846.855.help-gnu-emacs@gnu.org>
2012-06-26 13:29                           ` notbob
2012-06-26 17:47                             ` Dustin Hemmerling
2012-06-26 18:13                             ` Sivaram Neelakantan
2012-06-26 18:32                             ` Richard Riley
2012-06-28 12:14                               ` Tom
     [not found]                             ` <mailman.3520.1340735564.855.help-gnu-emacs@gnu.org>
2012-06-26 19:28                               ` notbob
2012-06-26 19:49                                 ` Ludwig, Mark
2012-06-26 19:52                                   ` Pascal J. Bourguignon
2012-06-27 15:49                                   ` PJ Weisberg
2012-06-28  2:09                                     ` John Wiegley
     [not found]                                 ` <mailman.3523.1340740164.855.help-gnu-emacs@gnu.org>
2012-06-26 20:13                                   ` notbob
2012-06-26 23:57                             ` John Wiegley
2012-06-27  9:23                               ` temacs Jambunathan K
2012-06-27 14:44                                 ` temacs Ken Goldman
2012-06-28  2:40                                   ` temacs John Wiegley
2012-06-28  8:49                                     ` temacs Bastien
2012-06-29 19:37                                       ` temacs Ken Goldman
     [not found]                                       ` <mailman.3732.1340998682.855.help-gnu-emacs@gnu.org>
2012-06-30  3:51                                         ` temacs rusi
2012-06-27 14:44                                 ` temacs suvayu ali
2012-06-27 16:24                                   ` temacs Alp Aker
2012-06-27 19:57                                     ` temacs Ken Goldman
2012-07-05  4:14                                 ` temacs John Wiegley
2012-07-05 12:46                                   ` temacs Eli Zaretskii
2012-07-07 16:51                                     ` temacs John Wiegley
2012-07-07 17:20                                       ` temacs Eli Zaretskii
2012-06-27 15:48                             ` Issues with emacs Stefan Monnier
2012-06-26  3:08                     ` rusi
2012-06-26  8:35                       ` Thien-Thi Nguyen
2012-06-27  5:54                   ` MBR
2012-06-26 18:03             ` Bug Dout
2012-06-25  2:43       ` Issues with emacs (was Emacs users a dying breed?) Ugly Sean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ehp0pwhr.fsf@kuiper.lan.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.