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


Groups > comp.compilers > #1511 > unrolled thread

Re: Choosing a parser for Mathematica input

Started byfateman@gmail.com
First post2015-02-05 08:08 -0800
Last post2015-02-06 19:04 -0800
Articles 9 — 7 participants

Back to article view | Back to comp.compilers

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Choosing a parser for Mathematica input fateman@gmail.com - 2015-02-05 08:08 -0800
    parsability (was: Choosing a parser for Mathematica input) glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-06 00:05 +0000
      Re: parsability and human factors "Derek M. Jones" <derek@_NOSPAM_knosof.co.uk> - 2015-02-07 12:45 +0000
        Re: parsability and human factors glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-02-08 10:32 +0000
          Re: parsability and human factors "Derek M. Jones" <derek@_NOSPAM_knosof.co.uk> - 2015-02-10 12:44 +0000
      Re: parsability "Robin Vowels" <robin51@dodo.com.au> - 2015-02-09 00:48 +1100
        Re: parsability Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2015-02-08 20:49 +0100
          Re: parsability news@iecc.com (News Subsystem) - 2015-02-09 14:37 +1100
    Re: Choosing a parser for Mathematica input Robert Jacobson <rljacobson@gmail.com> - 2015-02-06 19:04 -0800

#1511 — Re: Choosing a parser for Mathematica input

Fromfateman@gmail.com
Date2015-02-05 08:08 -0800
SubjectRe: Choosing a parser for Mathematica input
Message-ID<15-02-009@comp.compilers>
Hi, comp.compiler guys.
  I came across this thread while googling for something I wrote;
found this thread with stuff written about me.. It's a bit stale but
if David Kirby wants a Mathematica clone, he should look at Mathics.
Regarding the difficult of parsing the Mathematica language, he misses
the point, I think.  By the way, after conducting a worldwide search
for a better name for the language-minus-the-math-library, Stephen
Wolfram chose, tada, "The Wolfram Language".

Anyway the difficulty isn't parsing  x //f  to get  f(x).  It is in the
separation of lexical and syntactic uses of characters like "."  which have
multiple uses.
a.3 is Dot[a,3].  a .3  is Times[0.3, a].  And the difficulty with using
"space"
or merely adjacency for multiplication  is not resolved by asserting that
mathematicians use it all the time.

I have written papers and email in which I am critical of Mathematica.
 I have also written programs that are partial implementations of that program
but with illustrative changes showing (in my view) better design decisions.
Some of these decisions are mathematical rather than language issues.

Being (threatened or actually) sued by Wolfram is not so unusual.  It does add
some perspective to the fellow. See for example,

http://vserver1.cscs.lsa.umich.edu/~crshalizi/reviews/wolfram/

oh, about the name for the language, see
https://groups.google.com/forum/#!searchin/sage-devel/egofart/sage-devel/VEVW
bpDLc_g/cI0iIhIk7-AJ
for my own acronymic juggling, which explains the name EGOFART.

[toc] | [next] | [standalone]


#1513 — parsability (was: Choosing a parser for Mathematica input)

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2015-02-06 00:05 +0000
Subjectparsability (was: Choosing a parser for Mathematica input)
Message-ID<15-02-011@comp.compilers>
In reply to#1511
fateman@gmail.com wrote:
> Hi, comp.compiler guys.
>  I came across this thread while googling for something I wrote;
> found this thread with stuff written about me.. It's a bit stale but
> if David Kirby wants a Mathematica clone, he should look at Mathics.
> Regarding the difficult of parsing the Mathematica language, he misses
> the point, I think.  By the way, after conducting a worldwide search
> for a better name for the language-minus-the-math-library, Stephen
> Wolfram chose, tada, "The Wolfram Language".

It seems that most computer languages are designed to be easy to parse
by programs, but not for ease of use by people.

When computers were smaller and slower, that might have made sense,
but for the computers we have today, making it easier for people
should come first.

I went to a talk, not so long ago, by someone actually studying people
using computer languages. It seems that many people who write papers
about how easy or hard they are to use don't actually do any tests
with real people.

> Anyway the difficulty isn't parsing  x //f  to get  f(x).  It is in the
> separation of lexical and syntactic uses of characters like "."  which have
> multiple uses.

> a.3 is Dot[a,3].  a .3  is Times[0.3, a].  And the difficulty with using
> "space"
> or merely adjacency for multiplication  is not resolved by asserting that
> mathematicians use it all the time.

Interesting that when we learn multiplication in 3rd grade, we learn
the x operator for it, but then when we learn algebra we expect
adjacent terms to be multiplied without any operator. Mathematicians
have been doing that for centuries.

Though there is the compilication of multiple character symbolic
names, which mathematicians seem still not to have adopted.

> I have written papers and email in which I am critical of Mathematica.
> I have also written programs that are partial implementations of that program
> but with illustrative changes showing (in my view) better design decisions.
> Some of these decisions are mathematical rather than language issues.

But did you do any tests comparing your design to others?  That is,
using actual people, both experienced and not so experienced?

The person I mentioned above, though I didn't find the reference,
compared currently popular languages taught in introductory classes
against ones with random ASCII characters in place of the keywords,
and the random one did better!

-- glen
[I can believe it, but I believe there is also some evidence that once
you get beyond examples of trivial size, languages that are hard for
computers to parse are also hard for people to use.  For example, with
implicit multiplication, what does this mean:

  a b c + d e f + g

Rules like APL's everything associates to the left, or languages where
you have to parenthesize everything may seem "unnatural" but also are
a lot easier to get things written correctly. -John]

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


#1515 — Re: parsability and human factors

From"Derek M. Jones" <derek@_NOSPAM_knosof.co.uk>
Date2015-02-07 12:45 +0000
SubjectRe: parsability and human factors
Message-ID<15-02-013@comp.compilers>
In reply to#1513
Glen,

> I went to a talk, not so long ago, by someone actually studying people
> using computer languages. It seems that many people who write papers
> about how easy or hard they are to use don't actually do any tests
> with real people.

Yes, plenty of arm waving and personal opinions abound.

One experiment suggests that developers are good at doing
what they do most:
http://www.knosof.co.uk/dev-experiment/accu06.html
[Write buggy code? -John]

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


#1518 — Re: parsability and human factors

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2015-02-08 10:32 +0000
SubjectRe: parsability and human factors
Message-ID<15-02-016@comp.compilers>
In reply to#1515
Derek M. Jones <derek@_nospam_knosof.co.uk> wrote:

(snip, I wrote)
>> I went to a talk, not so long ago, by someone actually studying people
>> using computer languages. It seems that many people who write papers
>> about how easy or hard they are to use don't actually do any tests
>> with real people.

> Yes, plenty of arm waving and personal opinions abound.

OK, here it is:

The talk was titled "The Programming Language Wars".

http://web.cs.unlv.edu/stefika/Papers.php

is a list of some of the papers by the author, and

paper number 7 is one people might find interesting.

The authorization system doesn't allow one to copy the link, but if
you go to the page you should be able to read it, even without an ACM
account.

There is very little research into how people actually use features in
programming languages, though all designers seem to already know
without studying.

He did actual tests with both experienced and new programmers.

-- glen

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


#1525 — Re: parsability and human factors

From"Derek M. Jones" <derek@_NOSPAM_knosof.co.uk>
Date2015-02-10 12:44 +0000
SubjectRe: parsability and human factors
Message-ID<15-02-023@comp.compilers>
In reply to#1518
Glen,

 > The talk was titled "The Programming Language Wars".
 >
 > http://web.cs.unlv.edu/stefika/Papers.php

and the answer is to invent another language!
http://www.quorumlanguage.com/

 > is a list of some of the papers by the author, and
 >
 > paper number 7 is one people might find interesting.

Most of this paper is based on two self reporting surveys,
the sort of thing pollsters use to rate public opinion.

The experiment that was run for the second part of the paper
looks very sloppy.

 > There is very little research into how people actually use features in
 > programming languages, though all designers seem to already know
 > without studying.

Some work is analyzed here:
http://shape-of-code.coding-guidelines.com/2014/08/27/evidence-for-the-benefits-of-strong-typing-where-is-it/

There is a growing body of measurements of the use of programming
language features.  Here is a very good one on the use of eval in
Javascript:
http://the.gregor.institute/papers/ecoop2011-richards-eval.pdf

It is now common to encounter papers that measure stuff and arm
wave about finding power laws and how interesting this must be.
Sometimes they even check to see whether the data does in fact
follow a power law:
http://vserver1.cscs.lsa.umich.edu/~crshalizi/weblog/491.html

What is generally missing is any theory for the patterns seen.
A step up from arm waving here:
http://shape-of-code.coding-guidelines.com/2013/05/17/preferential-attachment-applied-to-frequency-of-accessing-a-variable/
Of course developer decisions on what variables to use are not based
on probabilities, this is an emergent behavior of higher level, as
yet unknown, processes.

 > He did actual tests with both experienced and new programmers.

The academic definition of experienced is often very different from
that used by industry.  It is common to hear third year undergraduates
labeled as experts and first year students as novices; industry would
regard them both as novices.  As far as I can see in this paper
experienced subjects are the ones enrolled in computer science courses
and inexperienced subjects are those not enrolled in such courses.

Thanks for the pointer, but I have deleted my copy of this paper.

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


#1519 — Re: parsability

From"Robin Vowels" <robin51@dodo.com.au>
Date2015-02-09 00:48 +1100
SubjectRe: parsability
Message-ID<15-02-017@comp.compilers>
In reply to#1513
From: "glen herrmannsfeldt" <gah@ugcs.caltech.edu>
Sent: Friday, February 06, 2015 11:05 AM

> It seems that most computer languages are designed to be easy to parse
> by programs, but not for ease of use by people.

An interesting thought, but not really the case, except for a few languages like C.

> When computers were smaller and slower, that might have made sense,

It is in this era that great efforts were made to make programming easier for people.
And even though computer memories were measured in hundreds and thousands of words,
considerable progress was made.
In the early 1950s, simple languages were developed to simplify the task of programming,
such as Alphacode, TIP, Easicode, GIP, etc etc.  Some were tagged "autocode s".
FORTRAN and GEORGE came along in the middle 1950s.
And COBOL and Algol arrived in the late 1950s.
BASIC was developed for the same purpose.

None of these (with the exception of small parts of FORTRAN) was
developed to make it easy for any parser.

Even PL/I was developed to make it easier for the programmer, though
some parts were not simple and probably not easy to parse (such as the
absence of reserved keywords)

Some features of FORTRAN were not exactly easy to parse, (blanks not
having any significance), but probably simplified the keying programs
on punch cards, though brought with it an unwitting source of
programmer errors.

> but for the computers we have today, making it easier for people
> should come first.

Indeed.

>> Anyway the difficulty isn't parsing  x //f  to get  f(x).  It is in the
>> separation of lexical and syntactic uses of characters like "."  which have
>> multiple uses.

A number of special characters have traditionally acquired multiple uses.
The asterisk, parentheses, apostrophe, colon, period, feature heavily
on account of the limited number of characters available in equipment
of the era (48-character set, 60 character set, etc.) and continue to do so
for historical reasons.

Algol perhaps fared best with preparation equipment that provided the
mathematical symbols, though implementations were bugged by line
printers that could deal only with upper-case characters and a
restricted set of special characters.
---
This email contains an annoying advertisement because avast! Antivirus protection is active.

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


#1521 — Re: parsability

FromHans-Peter Diettrich <DrDiettrich1@netscape.net>
Date2015-02-08 20:49 +0100
SubjectRe: parsability
Message-ID<15-02-019@comp.compilers>
In reply to#1519
Robin Vowels schrieb:

> A number of special characters have traditionally acquired multiple uses.
> The asterisk, parentheses, apostrophe, colon, period, feature heavily
> on account of the limited number of characters available in equipment
> of the era (48-character set, 60 character set, etc.) and continue to do so
> for historical reasons.

IMO the real and persistent limit is the keyboard, with a limited number
of keys. Increasing the number of keys is not a solution, because then
it may be more time consuming to find an special key, instead of reusing
a character or typing more characters. Why didn't APL succeed in the
long run?

OTOH there exist languages (and speakers) of languages with bigger
character sets, like Japanese or Chinese. What if people, used to
according input methods (character composition...), started to invent
and use dedicated glyphs for keywords and operators, in new programming
languages? Wouldn't this prevent coders of other *natural* languages
from using such a *programming* language, for its unreadability and
complicated keying?

DoDi

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


#1523 — Re: parsability

Fromnews@iecc.com (News Subsystem)
Date2015-02-09 14:37 +1100
SubjectRe: parsability
Message-ID<15-02-021@comp.compilers>
In reply to#1521
From: "Hans-Peter Diettrich" <DrDiettrich1@netscape.net>
Sent: Monday, February 09, 2015 6:49 AM
> Robin Vowels schrieb:
>
>> A number of special characters have traditionally acquired multiple uses.
>> The asterisk, parentheses, apostrophe, colon, period, feature heavily
>> on account of the limited number of characters available in equipment
>> of the era (48-character set, 60 character set, etc.) and continue to do so
>> for historical reasons.
>
> IMO the real and persistent limit is the keyboard, with a limited number
> of keys.

Present keyboards for the PC have keys for 33 special characters
(in addition to upper and lower-case and digits).
That's twice as many in use in languages.

> Increasing the number of keys is not a solution, because then
> it may be more time consuming to find an special key, instead of reusing
> a character or typing more characters.

No need to increase the number of keys.  Recall old typewriters?
Some had provision for three shifts (lower-case, upper-case, and special characters).
The same could be done with computer keyboards (well, it's sort of done with the normal, caps, and
CTRL keys).
A proper third shift key with corresponding glyphs inscribed on the keys
could extend the range of special characters.  After all, there is provision for 256 characters
encoded in a byte, and we use only half of them.

>Why didn't APL succeed in the long run?

Because it was write once throw-away language.
Programs were largely unintelligible to all except the writer.

This email probably contains viruses and malware despite what avast! Antivirus protection says.
[It was perfectly possible to write readable APL programs, but almost
nobody did. -John]


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


#1514

FromRobert Jacobson <rljacobson@gmail.com>
Date2015-02-06 19:04 -0800
Message-ID<15-02-012@comp.compilers>
In reply to#1511
I am among those who are trying to write a Mathematica parser. There are a few
Mathematica parsers out there.

* Richard Fateman's old MockMMA of course (written in Lisp) which is mentioned
in the first post of this thread from 2010.

* This MIT-licensed parser written in Scala is notable. Written by Mateusz
Paprocki "and contributors" a couple of years ago.
https://github.com/mattpap/mathematica-parser

* Alex Gittens's basicCAS is a python Mathematica parser, but it appears to
have disappeared from the author's website. It's still available elsewhere on
the net for those interested in looking for it. This project is interesting
because it includes Alex's notes regarding implementation.
https://pypi.python.org/pypi/basicCAS/1.0

* Mathics, a Mathematica clone written in Python and created by Jan Pvschko,
is particularly interesting. You can use it online. GPL licensed, copyright
2007.
http://www.mathics.org

* omath is similar in spirit to Mathics but is written in Java and appears to
have been abandoned at version 10^(-16) in 2005. The parser is a generated
parser using JavaCC and JJTree. The source code is distributed without a
license.
http://omath.org/w/index.php?title=Main_Page

* symja contains a Mathematica parser for a reasonable subset of Mathematica.
https://code.google.com/p/symja/source/browse/#svn/trunk/matheclipse-parser

SymPy and Sage both have rudimentary Mathematica parsers that work for basic
mathematical expressions. There are also some (rumors of) proprietary
Mathematica parsers. John Herrop of Flying Frog Consultancy claims to have
written a Mathematica parser in 300 lines of OCaml under contract for Wolfram
Research. The code is obviously not publicly available. Semantic Designs, a
company specializing in compiler technologies, lists Mathematica among the
many languages for which it has "front ends." (Both mentioned here:
http://stackoverflow.com/questions/1608380/parser-for-the-mathematica-syntax.
)

Wolfram Research may be grotesquely litigious, but given the existence of so
many of these projects it seems to me they are no longer interested in suing
everyone who even thinks the word Mathematica as they once were.

My own project is to construct an ANTLR4 grammar for Mathematica. Such a
grammar seems to me to be the easiest way to benefit the most people with
current compiler technologies. ANTLR4 has c#, python, java, and javascript
targets (some better than others), and a c/c++ target is allegedly in the
works. Several projects have expressed interest in such a thing, but it
appears nobody has succeeded in producing it. I am very happy with how far I
was able to get with very little effort, but my grammar isn't yet ready for
public consumption (read: doesn't work). See my top-level post to this
community for an example of one of the problems I'm still trying to solve with
my project.

Best,

Robert

[toc] | [prev] | [standalone]


Back to top | Article view | comp.compilers


csiph-web