Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

kanaka/miniMAL: Lisp in <1kb javascript

58 views
Skip to first unread message

RS Wood

unread,
Feb 26, 2015, 6:48:07 AM2/26/15
to
https://github.com/kanaka/miniMAL

A Lisp implemented in < 1 KB of JavaScript with macros, TCO, interop
and exception handling.

//--clip
miniMAL

A Clojure inspired Lisp implemented in less than 1024 bytes of
JavaScript.

Rationale

I originally started implementing a tiny Lisp interpreter as a quick
hack to submit to the 2015 JS1K competition (demo 2209). However, I
soon realized that I could fit far more functionality into 1024 bytes
of JavaScript than I expected and so miniMAL was born as a
"full-fledged" Lisp in its own right.

The design of miniMAL started with mal (a Clojure-insipred pedagogical
Lisp interpreter with implementations in over two dozen languages). And
in fact, in the miniMAL repository you can see the incremental steps to
build up the interpreter just like for each of the mal implementations.
However, the syntax and functionality of miniMAL is fairly different
from mal so it has become a standalone project.

Usage

There are several different ways to use miniMAL:

Start a REPL: run the miniMAL REPL (read-eval-print-loop). Requires
Node.js. ./miniMAL
Run a miniMAL program: run a miniMAL program and then exit. Requires
Node.js. ./miniMAL hello.json
As a shebang script: add a shebang line to the top of your miniMAL
program and turn it into an executable script. Requires Node.js.
//--clip

--
RS Wood <r...@therandymon.com
Posting to comp.misc, sci.misc, and misc.news.internet.discuss.

Marko Rauhamaa

unread,
Feb 26, 2015, 9:08:30 AM2/26/15
to
RS Wood <r...@therandymon.com>:

> A Clojure inspired Lisp implemented in less than 1024 bytes of
> JavaScript.
>
> [...]
> Requires Node.js.

Here's a complete Scheme implementation in mere 193 bytes of C:

========================================================================
#include <libguile.h>
static void inner_main (void *closure, int argc, char **argv)
{scm_shell (argc, argv);}
int main (int argc,char **argv)
{scm_boot_guile(argc,argv,inner_main,0);return 0;}
========================================================================

Requires libguile.so.


Marko

PS See <URL: http://www.gnu.org/software/guile/manual/html_node/A-Sample-Gui
le-Main-Program.html#A-Sample-Guile-Main-Program>

Matthew Carter

unread,
Feb 27, 2015, 12:48:35 AM2/27/15
to
I couldn't imagine writing code in the miniMAL language linked in the
thread start - so many double quotes and square brackets.

Nice link for libguile.

--
Matthew Carter (m...@ahungry.com)
http://ahungry.com

RS Wood

unread,
Feb 27, 2015, 8:23:50 AM2/27/15
to
On 2015-02-27, Matthew Carter <m...@ahungry.com> wrote:
> Marko Rauhamaa <ma...@pacujo.net> writes:
>> PS See <URL:
>> http://www.gnu.org/software/guile/manual/html_node/A-Sample-Gui
>> le-Main-Program.html#A-Sample-Guile-Main-Program>
>
> I couldn't imagine writing code in the miniMAL language linked in the
> thread start - so many double quotes and square brackets.
>
> Nice link for libguile.

I wasn't familiar with Guile so my question was 'is Guile a Lisp
derivative?' You might take issue with my choice of the word
'derivative' but here at least is what I found on that site:

//--clip
Guile is an implementation of the Scheme programming language. Scheme
(http://schemers.org/) is an elegant and conceptually simple dialect of
Lisp, originated by Guy Steele and Gerald Sussman, and since evolved by
the series of reports known as RnRS (the Revised^n Reports on Scheme).

Unlike, for example, Python or Perl, Scheme has no benevolent dictator.
There are many Scheme implementations, with different characteristics
and with communities and academic activities around them, and the
language develops as a result of the interplay between these. Guile’s
particular characteristics are that

it is easy to combine with other code written in C
it has a historical and continuing connection with the GNU Project
it emphasizes interactive and incremental programming
it actually supports several languages, not just Scheme.
//--clip
0 new messages