lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Other programming languages & LilyPond


From: David Kastrup
Subject: Re: Other programming languages & LilyPond
Date: Tue, 03 Dec 2013 09:51:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Vaughan McAlley <address@hidden> writes:

> On 3 December 2013 13:18, PMA <address@hidden> wrote:
>> I program in J almost exclusively, since the pursuit of my brainstorms
>> (music-bound or not) tends to favor handy ad-hoc number crunching.
>
> +1 but with Lua. I’ve done some useful things.
>
> Alternatives are Frescobaldi snippets if you know Python, and you can
> do a lot with regexes, which is a side-effect of Lilypond’s text file
> format.
>
> David Kastrup wrote:
>>Scheme _is_ its scripting language.  There is some Lua branch in
>>GuileV2, but it's unclear when it will be production quality, unclear
>>when LilyPond will run on GuileV2, and unclear whether both efforts
>>could be combined.
>
> That looks really interesting—I’d probably do all sorts of stuff. But
> then Lilypond would become a Frankenstein’s monster of extensions in
> different languages. So I should probably just learn Scheme.
>
> Incidentally, when I first arrived on the Lilypond mailing list, I
> recognized David Kastrup from the Lua mailing list. So he does know
> Lua quite well, even if he keeps it quiet :-)

We've had discussions a few years ago where I did a number of
comparisons.  Lua is very nice and has some quite endearing traits as an
extension language.  What I consider probably its best feature is its
lack of choices.  It has a single data structure implemented
efficiently.  It has a single numeric type.  Instead of symbols and
strings it has a single chimera with traits of both: interned strings
(actually, as opposed to those of LISP, Guile symbols are pretty much
just an interned string as well, but one does not want to use them for
string processing as they are not tuned for that).

So whenever the question comes up "how do we map our user language to
Lua data structures", there is usually just a single sensible answer
instead of several different tradeoffs.

Now LilyPond works a lot with exact fractions, and teaching that to the
number type of Lua is not going to be funny.

But Lua falls down in a few areas: it is not a functional language, and
LilyPond juggles in and out of Scheme all the time for _expressions_.

And it doesn't support template/macro-like manipulation of its parse
trees like Scheme does, since everything in Scheme is transparently a
list.

I've actually used Lua for writing LilyPond code.  Nowadays I wouldn't,
really.  Scheme is a bit less convenient for scripting, so if I had the
option to write LilyPond code with a standalone Scheme interpreter and a
standalone Lua interpreter, it would likely be a tie.  But LilyPond's
Scheme knows about music.

-- 
David Kastrup



reply via email to

[Prev in Thread] Current Thread [Next in Thread]