I am happy to announce the first version of Swearjure, version 1.0.0. If you have a recent version of Cabal installed, you can build Swearjure by doing the following commands in your favourite terminal:
If you have
on your path, you can also attempt to do
The source code is available at https://github.com/hyPiRion/swearjure.
What is Swearjure?
The language Swearjure is the subset of Clojure without alphanumeric characters. The program Swearjure is an implementation of Clojure that enforces those constraints.
If you wonder how you can program anything sensible without alphanumerics in Clojure, there are several introductions. Gary Fredericks presented Swearjure in his lightning talk at Clojure/West some years ago, and I wrote a blogpost about it as well.
Swearjure is turing complete1, so you can in theory convert any program to Swearjure. This is a bit easier said than done, though.
Notable Differences from Clojure
- No alphanumerics
- Fast startup!
- Strict (no laziness)
- Interpreted, not compiled
- “Tail recursion”
Pure Swearjure programs can only print the last expression in the file they are
executing. For convenience, the Swearjure implementation therefore ships with
, that allows you to read and print values.
See the I/O section in the tutorial for more information.
The Swearjure tutorial has good documentation on how to get started with Swearjure. It will learn you basic Swearjure, and the thought process used to convert more complex Clojure programs into Swearjure.
For more experienced users, there is also a document on extra tricks. For example, it shows how you can implement random number generation in this Swearjure implementation.
Swearjure programs look just like Clojure programs, except that they have no
alphanumeric characters in them. Functions do look somewhat obscure, mostly
because they can only be defined through clever use of
This is one way of implementing a program printing out “Hello World!” in Swearjure:
This code generates three big numbers (the last 3 lines) and feeds it into an
anonymous function. The anonymous function then combines these numbers to form
all the integer values corresponding to the string
, which is
then sent to the printing function
This program works like
without any arguments. It takes in a single
character (represented as an integer value) and prints it out again. Afterwards
it calls itself. In contrast to Clojure proper, Swearjure implements “tail
recursion”, so the stack is not consumed on tail calls.
The only thing that breaks the illusion that this is
itself is that it
spits out the error
when EOF is
swearjure: <stdin>: hGetChar: end of file
For more examples, take a look at the examples directory in the Swearjure repository.