• Stars
    star
    261
  • Rank 156,630 (Top 4 %)
  • Language
    Clojure
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lisp-flavored general-purpose programming language (based on Zig)

Liz: Lisp-flavored general-purpose programming language (based on Zig)

Borrowing Zig's tagline:

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

  • Written as Clojure-looking S-expressions (EDN) and translated to Zig code.
  • Type-A Lisp-flavored language. I call it "Lisp-flavored" because Liz is missing many fundamental features to be called a Lisp or even a Clojure dialect (no closures, no persistent data structures).
  • When you need a language closer to the metal and Clojure with GraalVM's native image is too much overhead.
  • Supports many targets including x86, ARM, RISC-V, WASM and more

Why is Zig an interesting choice as a lower-level language for Clojure programmers? (compared to Rust, Go or other languages):

  • Focus on simplicity
  • Seamless interop with C without the need to write bindings.
    Similar quality like Clojure seamlessly interoperating with Java.
  • Incremental compilation with the Zig self-hosted compiler.
    To accomplish this Zig uses a Global Offset Table for all function calls which is similar to Clojure Vars. Therefore it will be likely possible to implement a true REPL.
  • Decomplecting principles
    Most higher-level languages have bundled memory management, which disqualifies them from certain use cases. Zig decomplects memory management by introducing explicit Allocator interface, programmer can choose fitting memory management mechanism with regard to performance/convenience trade-offs.

Status: Experimental, but proving itself on a few projects.

Examples

Hello World:

;; hello.liz
(const print (.. (@import "std") -debug -print))

(defn ^void main []
  (print "Hello, world!\n" []))

It will get translated into:

const print = @import("std").debug.print;
pub fn main() void {
    print("Hello, world!\n", .{});
}

Run with:

$ liz hello.liz && zig run hello.zig
Hello, world!

FizzBuzz example:

(const print (.. (@import "std") -debug -print))

(defn ^void main []
  (var ^usize i 1)
  (while-step (<= i 100) (inc! i)
    (cond
      (zero? (mod i 15)) (print "FizzBuzz\n" [])
      (zero? (mod i 3)) (print "Fizz\n" [])
      (zero? (mod i 5)) (print "Buzz\n" [])
      :else (print "{}\n" [i]))))

See also:

Documentation

Read the work in progress language guide.
To see how a form is used you can also take a look at samples adapted from Zig docs.

Usage

Download Liz and Zig. To compile files from Liz to Zig pass them as parameters:

liz file1.liz file2.liz
# file1.zig and file2.zig will be created

Then use zig run or zig build-exe on the generated .zig files.

Alternatively you can use the JAR:

java -jar liz.jar file1.liz file2.liz

Extension and Syntax highlighting

Use .liz file extension. It works pretty well to use Clojure syntax highlighting, add -*- clojure -*- metadata to the source file for Github and text editors to apply highlighting.

;; -*- clojure -*-

Design principles

  • Create 1:1 mapping, everything expressible in Zig should be expressible in Liz, or can be considered a bug.
  • If a Zig feature maps cleanly to Clojure then use the Clojure variant and name.
  • If the mapping conflicts then use the Zig vocabulary.

License

MIT

Development

Get the source:

git clone https://github.com/dundalek/liz.git
cd liz

Build platform independent uberjar:

scripts/build-jar

Build the native binary (requires GraalVM):

# If you don't have native-image on PATH then you need to specify GRAALVM_HOME
export GRAALVM_HOME=/your/path/to/graal
scripts/build-native

Use Clojure CLI:

clj -M -m liz.main file1.liz file2.liz

Run tests:

clj -Mtest

More Repositories

1

markmap

Visualize markdown documents as mindmaps
JavaScript
1,696
star
2

closh

Bash-like shell based on Clojure
Clojure
1,616
star
3

awesome-lisp-languages

A list of Lisp-flavored programming languages
712
star
4

GrammKit

Generate diagrams for parser grammars
JavaScript
235
star
5

lazy-lsp.nvim

Neovim plugin to auto install LSP servers
Lua
192
star
6

latinize

Simple library to convert accents (diacritics) from strings to latin characters.
JavaScript
148
star
7

atom-markdown-mindmap

Visualize markdown files as mindmaps in Atom editor
CoffeeScript
117
star
8

warehouse

Warehouse.js is a data storage layer for node.js and browser providing unified API for many supported storage engines (MongoDB, MySQL, SQLite, in-memory and others).
JavaScript
103
star
9

clojurescript-guide

My notes on ClojureScript
69
star
10

react-blessed-contrib

A wrapper for blessed-contrib widgets to be rendered with react-blessed.
JavaScript
61
star
11

notcurses-zig-example

Demo showing how to use Notcurses library for building terminal UIs with Zig
Zig
60
star
12

kmdoc

KMDoc is a software for an intelligent representation of knowledge useful for quick learning and browsing.
JavaScript
43
star
13

casio-f91w-fsm

Interactive model of the Casio F-91W watch using statecharts
Clojure
29
star
14

longdown

Convert longform markdown files to outline format used by Logseq
Clojure
28
star
15

parpar.nvim

Plugin for Neovim that seamlessly integrates Parinfer and Paredit for editing lisp code
Lua
27
star
16

dinodoc

Polyglot documentation system for building unified documentation sites
Clojure
27
star
17

osquery-rest-adapter

Visualize information about your OS (REST adapter for osquery compatible with Vega)
JavaScript
26
star
18

stratify

Visualize structure and dependencies of Clojure codebases
Clojure
21
star
19

notcurses-clojure-example

Demo showing how to use Notcurses library for building terminal UIs with Clojure
C
16
star
20

humble-outliner

Clojure
13
star
21

bindem

A light-weight library providing Knockout-like two-way declarative data binding for Backbone.
JavaScript
13
star
22

knowledge-base

Notes on various subjects represented using KMDoc knowledge format
HTML
8
star
23

archieml-peg

Alternative parser for ArchieML in JavaScript using PEG (Parsing Expression Grammar)
JavaScript
8
star
24

dotfiles

Shell
7
star
25

git-sheet

Interactive page which presents most used git commands as a cheat sheet.
JavaScript
6
star
26

czech-stemmer

This is a port of stemmer for Czech language to Javascript, for both node.js and browser.
JavaScript
6
star
27

jquery-tagin

Simple jQuery Tag Input plugin with advanced features
JavaScript
5
star
28

userstyles

CSS
5
star
29

solid-cljs

Clojure
5
star
30

humble-graal

Compile HumbleUI apps with GraalVM
Clojure
5
star
31

recline-warehouse

code for integration of Recline.js with Warehouse.js and other various additions to Recline
JavaScript
4
star
32

intools

Clojure
4
star
33

github-comparison

Show comparison of github repos in a table with this simple javascript component.
JavaScript
4
star
34

testing-without-mocks-clojure

Clojure
4
star
35

daba

Clojure
3
star
36

MEB-Genetic-Algorithm

Genetic Algorithm implementation in javaScript solving Minimum Energy Broadcast Problem
JavaScript
2
star
37

whitescape.js

Library for escaping whitespace characters
JavaScript
2
star
38

QueryHammer

QueryHammer is a visual tool that helps you create queries interactively
JavaScript
2
star
39

adventofcode

Clojure
2
star
40

rama-clj-playground

Clojure
2
star
41

lumo-unpack-binding

Unpack binary node bindings for apps bundled with pkg-lumo
JavaScript
1
star
42

vmp

1
star
43

calculator-exercise

Clojure
1
star
44

cljs-stickies

Sticky notes demo app with Drag n Drop written in ClojureScript
Clojure
1
star
45

notemx

NoteMX is a note taking app for Android with Dropbox sync using React Native
JavaScript
1
star
46

livereloader

[Deprecated] Simple HTTP server with livereload functionality. No setup, other apps or browser extensions required.
JavaScript
1
star
47

x11-playground

JavaScript
1
star
48

cljs-kanban

Kanban board with drag and drop written in ClojureScript
Clojure
1
star
49

commandray

CommandRay is a graphical command-line tool to discover and execute commands more efficiently
JavaScript
1
star
50

cljs-date-format-tool

A simple tool that helps creating date format strings
Clojure
1
star
51

pickfile

JavaScript file picker component supporting drag and drop, file chooser and remote URL
JavaScript
1
star