[Top][All Lists]

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

[potluck dish] Compiler for the Joy language

From: Eric Bavier
Subject: [potluck dish] Compiler for the Joy language
Date: Mon, 15 Feb 2016 22:17:23 -0600

Hello Guilers,

And happy birthday Guile!

I started this project a few weeks ago, and managed to make enough
progress that I thought I'd share it for the potluck.

Joy is a simple, forth-like, purely functional, concatenative
programming language:

Attached is a patch to guile master that adds a module/language/joy
directory, with lexer, parser, compiler to tree-il, runtime, and minimal
standard library.  This is still a work-in-progress, but you can already
do some fun things:

$ guile
scheme@(guile-user)> ,L joy
joy@(guile-user)> "<path-to>/" include .
joy@(guile-user)> 2 3 + 4 1 .
$1 = (1 4 5)
joy@(guile-user)> DEFINE foo == 2 3 + 4 1 ; bar == + + .
joy@(guile-user)> foo bar .
$2 = (10)
joy@(guile-user)> [1 2 3 4 5 6] [fact] map .
$3 = ((1 2 6 24 120 720))
joy@(guile-user)> [1 2 3 4 5 6] [fact] map sum .
$4 = (873)
joy@(guile-user)> [1 2 3 4 5 6] [fact 2 /] map .
$5 = ((0 1 3 12 60 360))

My interest in Joy came from a search to find a small language whose
minimal base could be implemented as an easily-audited assembly
interpreter, but which has higher-level language capabilities.  The
guile implementation sprang out of a desire to get to know the language
a bit more before embarking on the assembly route.  Learning more about
Guile's multi-language support has been a real pleasure, and I'd love
to see it/help it grow more.

Limitations and things yet to do:

- The compiler and runtime currently do not support "sets" aka bitsets
  as a native type like the reference implementation does.

- String support in the primitives and base library is not complete.  I
  have been toying with the idea of just compiling strings to
  lists-of-chars for easier handling and simplicity of the primitives.

- REPL: A joy-specific writer would be nice.  And better backtraces?

- Writing more interesting libraries.  I had hoped to write a useful
  parser-combinator library.

- Better include-path handling.

- Distribution: part of Guile, or separate?

Anyhow, I hope some find this interesting.

Happy Hacking and happy birthday Guile!
`~Eric Bavier

Attachment: 0001-Add-compiler-for-the-Joy-language.patch
Description: Text Data

reply via email to

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