Skip to main content

A minimal but elegant dialect of Joy, a functional / concatenative stack language.

Project description

joyfl (pronounced ˈjȯi-fəl) is a dialect of the programming language Joy.

Joy is a stack-based programming environment that’s both functional and concatenative, which results in highly expressive but short programs. joyfl is an implementation of Joy in Python in its early stages; it’s not entirely backwards compatible by design.

EXAMPLES

You can run a simple REPL (read-eval-print loop) by typing: python3 joyfl.py repl. From there, try typing these statements:

# Take the number one, the number two, add them. Then the number three and add it to the
# previous result. Is six equal to that?
1 2 + 3 +
    6 equal? .
>>> true

# Take the list of numbers seven eight nine. Take a program that subtracts one. Map the
# program onto the list, then reverse it.
[7 8 9] [1 -] map reverse .
>>> [8 7 6]

# Take a list of symbols 'a 'b 'c. Take the symbol 'd. Swap the symbol with the list. Get
# the "rest" of the list omitting the first item. Construct a new list with "cons" that
# uses 'd as the new head.
['a 'b 'c] 'd swap rest cons .
>>> ['d 'b 'c]

Also look at the #/examples/ folder and run them with python3 joyfl.py <filename>.

MOTIVATION

While it’s fun to implement languages, this project has particular #ML / #LLM research questions in mind…

“ What if there was a language for a ‘micro-controller’ able to process 99% of tokens? ”

📥 TRAINING: To produce training data, what’s the middle ground between a web-template (gasp!) and a synthetic theorem generator (whew!)? The answer looks more like another language than a hacked-together Python script.

📤 INFERENCE: For output tokens, how can we make sure prompts are followed, any arithmetic is correct, no items are missed, and formatting is right? The solution isn’t more Python but special tokens that can be interpreted as instructions…

The research goal of this project is to find out where and how Joy can shine in these cases!

DIFFERENCES

While some of the tests from the original Joy pass, many also do not. Here are the design decisions at play:

  1. Symbols vs. Characters — Individual byte characters are not supported, so it’s not possible to extract or combine them with strings. Instead, the single quote denotes symbols (e.g. 'alpha) that can only be compared and added to containers.

  2. Data-Structures — Sets are not implemented yet, but will be. When they are, the sets will have the functionality of the underlying Python sets. Lists too behave like Python lists. Dictionaries will likely follow too at some point.

  3. Conditionals — Functions that return booleans are encouraged to use the ? suffix, for example equal? or list?. This change is inspired by Factor, and makes the code more readable so you know when to expect a boolean.

  4. Stackless - The interpreter does not use the Python callstack: state is stored entirely in data-structures. There’s a stack (for data created in the past) and a queue (for code to be executed in the future). Certain advanced combinators may feel a bit different to write because of this!

REFERENCES

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

joyfl-0.7.tar.gz (81.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

joyfl-0.7-py3-none-any.whl (93.9 kB view details)

Uploaded Python 3

File details

Details for the file joyfl-0.7.tar.gz.

File metadata

  • Download URL: joyfl-0.7.tar.gz
  • Upload date:
  • Size: 81.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for joyfl-0.7.tar.gz
Algorithm Hash digest
SHA256 730cce92cb7efcda2ceae601eeb4eb4fc3fed51c53dbf401f590698a93111aa2
MD5 eb6097b2d6c0d57ff793823d41468121
BLAKE2b-256 d4ae6a218c711bc55671174942a67382c9af7da7e8bb28b02c82c0be6944e36e

See more details on using hashes here.

File details

Details for the file joyfl-0.7-py3-none-any.whl.

File metadata

  • Download URL: joyfl-0.7-py3-none-any.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for joyfl-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 89e2f4ee5ad6ffd9d8e0aa9e1ac309ffd3334e31567d298caa1bbdb638f1435a
MD5 930e7915803e575d7ec466ecda7669ec
BLAKE2b-256 0d6c97beb51da7c87af5e9809791871648c218cd87eef04ff584fb3857d0a0e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page