[racket] Sweet expressions; or making it easier to introduce Racket to me and my coworkers :-)

From: Hendrik Boom (hendrik at topoi.pooq.com)
Date: Thu Jul 21 12:58:56 EDT 2011

On Thu, Jul 21, 2011 at 10:01:44AM -0400, Deren Dohoda wrote:
> Fully-parenthesized math is more difficult to read, I agree, but overall
> lispy syntax has really grown on me. I can't tell you how many times Excel
> has gotten mad at me for typing
> 
> =*5A1
> 
> I think the math problem is accidental, related only to the customary use of
> infix. The difference between
> (f x)
> And
> f(x)
> Is not obvious. Had we always added as
> plus(a, b)
> then
> (plus a b)
> would be no problem.

Conventional mathematical notation has evolved to be an efficient 
notation for hand calculation with polynomials.  This is an 
applicatino where it's iportant to see, quickly, which terms are of 
the highest degree in the variable 'y', and so forth.  All of which 
is hopelessly obscured by Polish prefix notation.  And it isn't even 
infix notation that the conventional mathematician uses:  it's infix 
for addition and subtraction, concatenation without an opreator for 
multiplication, and exponentiation expressed with superscripts.  The 
visual appearance wsa everything, and otimized for additive terms 
consisteing of multiplicative factors consisting of variables raised 
to small integral powers.  The cisial was everything.  It became 
easy to see which term had the highest power in y, foe example.
Parenthese were used when this tidy structure was violated -- and 
these violations could then be easily be seen so that more exotic 
algebraic procedures could be used on them.

None of this has any direct relevance to computer programming. 
Except, of course, that it's important to adapt the notation to the 
properties of the work that's being perfomed using that notation.  
There's no particular reason to think that conventional mathematical 
notation is optimum for the manipulations normaally performed on 
programming.  Except for parts of programs dealing with numerical 
analysis or maybe predicate calculus, 

-- hendrik

> On Jul 20, 2011 5:04 PM, "Greg Hendershott" <greghendershott at gmail.com>
> wrote:
> > In this regard, I was you a couple years ago.
> >
> > Spoiler alert: It turned out to be no hurdle at all. The psychic
> > whiplash lasted days/weeks, not weeks/months.
> >
> > As people will point out, you must use an editor that does Lisp/Scheme
> > paren matching and indentation (like DrRacket or emacs).
> >
> >> ... getting my head to read the deeper
> >> nested (if (some thing) (else branch)) structures is somewhat painfull.
> >
> > Actually, "control flow" code like that is pretty easy with the right
> > editor: The "if", "else" and indentation will be in much the same
> > places you're used to. The underbrush will just be () instead of {}.
> >
> > With time you may find yourself doing far fewer nested conditionals
> > and loops, at all. Because you're using more-succinct tools like
> > match, map, fold, etc.
> >
> > Anyway I think you'll probably find it less daunting than you imagine.
> >
> > Where prefix never gets natural (at least it still hasn't for me) is
> > complicated math expressions. Having something like curly infix for
> > that, would be handy.
> >
> > Also I've been known write some comparisons in infix using a Racket
> "trick".
> >
> > Instead of:
> >
> > (if (< a b) ...
> >
> > you can write:
> >
> > (if (a . < . b) ...
> >
> > Anything between two dots like that "gets moved to the front". This
> > used e.g. with Racket contracts, so you can write (arg1 arg2 . -> .
> > result) which is more intuitive than (-> arg1 arg2 result). This can
> > help in a few cases but isn't the generalized curly infix thing.
> >
> > On Sun, Jul 17, 2011 at 1:13 PM, Danny Wilson <danny at decube.net> wrote:
> >> Hi List,
> >>
> >> Short version: is there an implementation of
> >> http://www.dwheeler.com/readable/sweet-expressions.html  for typed/racket
> or
> >> just racket?
> >>
> >>
> >> Long version:
> >>
> >> The past few days I've gotten really excited about the possibilities of
> >> using the Racket for my projects. I'm mostly a self-taught programmer
> >> without a CS or scheme background. Currently I'm working on a rather
> large
> >> (web)application project, consisting of:  haXe, some Scala, PHP
> >> (unfortunately) a bit of D and modifications to C/C++
> >>
> >> I tend to make enough typo's in my coding to appreciate static typing.
> >> Having tried scheme and lisp now and then, I couldn't really get over
> >> everything being dynamically typed - (as well not finding any mentioning
> or
> >> guarantees about performance, memory usage or anything like that). Typed
> >> Racket got me very excited.
> >>
> >> I 'get' the lovelyness of code as data, as i've written a few code
> >> generators to reduce boilerplate. But getting my head to read the deeper
> >> nested (if (some thing) (else branch)) structures is somewhat painfull.
> >>  Especially for my colleagues who never have tried programming in any
> lisp
> >> or even heard of it.
> >>
> >> I noticed the Holu language, but couldn't find any examples of what it
> might
> >> look like. Can languages like holy and typed/racket be combined somehow?
> >> Again I've just started using DrRacket so maybe these are all very
> obvious
> >> questions.
> >>
> >>
> >> Thanks!
> >> _________________________________________________
> >>  For list-related administrative tasks:
> >>  http://lists.racket-lang.org/listinfo/users
> >>
> >
> > _________________________________________________
> > For list-related administrative tasks:
> > http://lists.racket-lang.org/listinfo/users

> _________________________________________________
>   For list-related administrative tasks:
>   http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.