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:

git clone https://github.com/hypirion/swearjure.git
cd swearjure
git checkout 1.0.0
cabal sandbox init
cabal install
cp .cabal-sandbox/bin/swearjure swearjure
# and we're ready to go!
./swearjure

If you have

1
~/.cabal/bin
on your path, you can also attempt to do

cabal update && cabal install swearjure

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 the functions

1
>>
,
1
>>'
and
1
<<'
, that allows you to read and print values. See the I/O section in the tutorial for more information.

Learn Swearjure

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.

Example Programs

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

1
->>
,
1
->
and
1
#()
.

Hello World

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

1
"Hello World!"
, which is then sent to the printing function
1
>>'

Cat

((->> (>=>)
      #(>>' (<<'))
      (-> >=>)))

This program works like

1
cat
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

1
cat
itself is that it spits out the error
1
swearjure: <stdin>: hGetChar: end of file
when EOF is received.

More

For more examples, take a look at the examples directory in the Swearjure repository.