[ :: Clyx is... ]
- Concatenative: build anything via the series of simple word applications.
- Stack-based: a single data stack can hold any types allowed in the language, no precedence ambiguity when applying operations.
- Homoiconic: Clyx features Q-forms, list-like ordered structures that can hold either data or code. In fact, Clyx has no native data types other than numbers, strings and Q-forms (which in turn can hold numbers, strings or other Q-forms): everything else is being built on top of them.
- Expressive: the primitives and the standard library give you enough abstractions to get started; from that point onwards, Clyx can be as high-level or as low-level as you need it to be, which makes it ideal for creating DSLs (domain-specific languages).
- Portable: just implement 50 primitives, main interpreter loop and program loader and you're good to go!
- Interoperable: file and TCP I/O available out of the box (on the targets that support them).
- Embeddable: the reference Python port has been tested on MicroPython and CircuitPython (on the MCUs like ESP32-S3).
- Interactive: almost all Clyx ports come with a simple Forth-like REPL (written in Clyx itself).
- Unicode-friendly: since the version 0.3.3, all Clyx implementations are expected to natively handle UTF-8 strings and seamlessly convert between them and byte-representing Q-forms.
- Easy to learn: being inspired by languages like Forth and Tcl, it has almost no syntactic elements to memorize in order to start writing valid code.
- Pronounced like clicks, because it clicks in your brain how to solve a problem without the language getting in the way.
[ :: Get Clyx ]
- Repository
- Reference manual
- Install Go version (+
clyxcbundler):go install codeberg.org/luxferre/clyx/...@latest - Install Python version:
pipx install "git+https://codeberg.org/luxferre/clyx.git#subdirectory=clyx-python"
The most recent Clyx version is 0.3.7. The version is bumped every time the language core words (aka primitives), the standard library or the REPL get updated. The primitive set is expected to be indefinitely frozen once the version number reaches 1.0.
[ :: Examples (clyxc-compatible) ]
[ :: Hello World program ]
#!/usr/bin/env clyx _start [ say "Hello from Clyx!" ]
[ :: FizzBuzz program ]
#!/usr/bin/env clyx
_start [
for [ 1 101 range ] [
1 # tracking flag
swap # the index is on top
dup 3 mod 0= if [ "Fizz" puts swap drop 0 swap ] [ ]
dup 5 mod 0= if [ "Buzz" puts swap drop 0 swap ] [ ]
swap if [ . ] [ drop cr ]
]
]
[ :: TCP echo server ]
#!/usr/bin/env clyx
_start [
say "Listening on port 1337..."
1337 nlstn # listen on port 1337
1 while [ # outer connection accept loop
dup read # accept a new connection -> conn_fd
1 # loop condition for client session loop
while [
dup read # read data
dup vlen 0 != # check if data is non-empty
if [ over swap write drop 1 ] [ drop 0 ]
]
close # close the connection socket
1 # loop condition for outer server loop
]
]
[ :: Try it online ]
Under construction!
[ :: Credits ]
- Author: Luxferre
- License: public domain