[racket] `def' ?

From: Justin Zamora (justin at zamora.com)
Date: Thu May 10 17:18:44 EDT 2012

In my experience, the heaviness of Racket doesn't come from words like
"define", etc.  It comes in certain categories of programs that deal
extensively with strings, vectors, and structured data.  For example,

initials = person[i].firstname[0] + person[i].lastname[0]

This is very readable and useful.  It can be written quickly and is
read and understood easily The overloading of "+" (or your operator of
choice) and the implicit coercion of characters to strings is exactly
what is wanted here.  Even evaluating person[i] more than once doesn't
clutter up the expression.

Compare this to the equivalent Racket:

(define initials
  (string-append (string (string-ref (id-firstname (vector-ref person i)) 0))
                 (string (string-ref (id-lastname (vector-ref person i)) 0))))

For this sort of thing, the Racket version is much harder to write,
read, and verify.  It would be nice to have something akin to
at-expressions that would allow such expressions to be written more
clearly.

Justin

On Thu, May 10, 2012 at 4:00 PM, Matthias Felleisen
<matthias at ccs.neu.edu> wrote:
>
> I will assert something about readability:
>
>  Racket programs look heavy when compared with Haskell programs.
>
> This is probably true for Python instead of Haskell, too. It is also true for ML. I conjecture that part of that heaviness comes from wide lines, long names, deep nesting. Who knows. I don't even know how to measure this kind of property.
>
> At this point, I can express certain ideas more easily in Racket than in Haskell, Python, ML or whatever, which is why I am fine. But if this advantage ever disappeared, heaviness would definitely be a factor to weigh.
>
> -- Matthias
>
>
>
>
>
>
> On May 10, 2012, at 3:49 PM, ozzloy-racket-users wrote:
>
>> i didn't assert that word length has nothing to do with readability, just that word frequency has more impact on reading time than word length.
>>
>> On Thu, May 10, 2012 at 3:39 PM, Luke Vilnis <lvilnis at gmail.com> wrote:
>> I can only speak for myself but I think it's a bit much to assert that word length has nothing to do with readability. Heck, maybe that's even true for you, but not for everyone. I have certainly felt it to be an issue. If the "define" keyword was 50 letters long it would definitely have an impact on my ability to read code - it seems to be an issue of degree, not existence.
>>
>> On Thu, May 10, 2012 at 3:26 PM, ozzloy-racket-users <ozzloy+users_racket-lang_org at gmail.com> wrote:
>> am i the only one that thinks not having abbreviated names for anything is good?
>> i like not having "def".  especially if it's going to be redundant.
>> i see this as a slippery slope i don't want to go down.
>> it annoys me when switching to other languages to have to ask: which way of shortening "function" does this language go with?  was it "fn"? maybe "fun"?
>> if the language has a strict policy of not using short versions of words, i don't have to guess.
>>
>> as for "def" being easier to read than "define", that's not true.  word frequency has more impact on reading time than word length for normal reading.  having more aliases makes both less frequent, so adding "def" could plausibly make reading both take longer.  most people read whole words at a time, rather than letter-by-letter.
>>
>>
>> On Thu, May 10, 2012 at 2:56 PM, Grant Rettke <grettke at acm.org> wrote:
>> There is always pretty mode in Emacs.
>>
>> On Thu, May 10, 2012 at 1:45 PM, Ray Racine <ray.racine at gmail.com> wrote:
>> > FYI for those who may not know.  Racket supports λ as an alias for lambda.
>> >  ctrl-\ in DrRacket.
>> >
>> >
>> > On Thu, May 10, 2012 at 1:59 PM, Nikita B. Zuev <nikitazu at gmail.com> wrote:
>> >>
>> >> +1 for `def' as alias for `define'.
>> >> May I also suggest `fun' for `lambda' alias?
>> >> Three letter names are the best =)
>> >>
>> >> (well one can always do it with require rename-in)
>> >>
>> >> --
>> >> Regards,
>> >> Nikita B. Zuev
>> >> ____________________
>> >>  Racket Users list:
>> >>  http://lists.racket-lang.org/users
>> >
>> >
>> >
>> > ____________________
>> >  Racket Users list:
>> >  http://lists.racket-lang.org/users
>> >
>>
>>
>>
>> --
>> http://www.wisdomandwonder.com/
>> ACM, AMA, COG, IEEE
>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>>
>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>>
>>
>>
>> ____________________
>>  Racket Users list:
>>  http://lists.racket-lang.org/users
>
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users


Posted on the users mailing list.