53 lines
3.6 KiB
Markdown
53 lines
3.6 KiB
Markdown
# Clyx programming language
|
|||
|
|
|
||
|
|
## About
|
||
|
|
|
||
|
|
Clyx (pronouned like _clicks_) is a concatenative, stack-oriented, interpreted programming language designed for simplicity, minimalism, and metaprogramming capabilities.
|
||
|
|
|
||
|
|
Clyx aims for maximum portability and can be implemented in any modern runtime environment that supports data structures defined in JSON (numbers, strings, lists and key-value dictionaries). Extra features varying in portability include filesystem support and TCP socket I/O.
|
||
|
|
|
||
|
|
## Language features
|
||
|
|
|
||
|
|
- Single, unbounded data stack that can hold numbers, strings and quotations (lists)
|
||
|
|
- Forth-like parsing, RPN (postfix notation) and word definition mechanics
|
||
|
|
- Tcl-like quotation (list) bracket syntax
|
||
|
|
- Janet-like quotation (list) operations
|
||
|
|
- Homoiconicity: quotations and strings can be manipulated as data and executed dynamically
|
||
|
|
- Character I/O (implementation-dependent)
|
||
|
|
- File I/O (may not support all features on some targets)
|
||
|
|
- TCP socket I/O (may not be supported on some targets)
|
||
|
|
- Platform-agnostic [standard library](lib.clx)
|
||
|
|
- Ability to include custom modules into the current runtime context (depends on file I/O capabilities)
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
Note: this section describes how to run the interpreter itself. For the language manual, refer to [Clyx Reference Manual](clyx_manual.md).
|
||
|
|
|
||
|
|
All core implementations must accept a `.clx` file to run (either via command line or via library call parameter). The REPL is implemented in Clyx itself and resides in the [clyx_repl.clx](clyx_repl.clx) file.
|
||
|
|
|
||
|
|
To run the REPL with the reference Python implementation, run `[micro]python clyx.py clyx_repl.clx` command.
|
||
|
|
|
||
|
|
## Implementations
|
||
|
|
|
||
|
|
- [Reference implementation in Python](./clyx.py) (compatible with MicroPython and CircuitPython)
|
||
|
|
|
||
|
|
## FAQ
|
||
|
|
|
||
|
|
### Where does the name Clyx originate from?
|
||
|
|
|
||
|
|
Similarly to [LVTL](https://codeberg.org/luxferre/lvtl-x) and [LTTB](https://codeberg.org/luxferre/lttb), the prototype of Clyx had been called LPLF (Luxferre's Pointer-Less Forth). However, as the finalized language began to differ from the Forth standard in too many ways, a decision was made to focus on the concatenative nature itself. Thus, the word ConCat had been chosen, which was quickly modded into ConLynx and then naturally shortened to Clyx.
|
||
|
|
|
||
|
|
Additionally, this name can be viewed as an acronym hinting at the order some binary operations pop their operands from the stack: "Compute by Loading Y, then X".
|
||
|
|
|
||
|
|
### Why not just pick up a Forth instead?
|
||
|
|
|
||
|
|
Forth is good if you are fine with only being able to push integers onto the stack and building all your abstractions using direct memory access. Clyx, on the other hand, does not have direct memory access because it was designed for the systems that might not even give you one, but you can do so much more with the data types that it allows you to push onto the stack without involving any trickery.
|
||
|
|
|
||
|
|
Clyx combines the conceptual simplicity of Forth (and concatenative/RPN programming in general) with list definition syntax, list manipulation and metaprogramming capabilities of Janet and Tcl, making it much more practical for everyday tasks. At the same time, you can build abstraction levels as high as you need to, making it a nice choice for creating custom DSLs (domain-specific languages), especially with the `next` word that pushes the next logical token onto the stack, allowing to change token processing order.
|
||
|
|
|
||
|
|
While diverging from some "purity" aspects, Clyx is a decent choice for newcomers that want to try out a totally new programming paradigm without investing too much time into fighting the language's quirks.
|
||
|
|
|
||
|
|
## Credits
|
||
|
|
|
||
|
|
Created by Luxferre in 2026, released into the public domain with no warranties.
|