HC-Lisp A Modern Lisp Dialect

A modern Lisp dialect implementation in TypeScript, inspired by Clojure and Peter Norvig's Lispy project.

โš ๏ธ
Development Status: HC-Lisp is currently in active development and is not ready for production use. This is an experimental project for educational purposes and learning how Lisp interpreters work.
HC-Lisp REPL
hc-lisp> (+ 1 2 3)
6
hc-lisp> (ns demo (:import (node.crypto randomUUID)))
Importing node.crypto.randomUUID
:demo
hc-lisp> (crypto/randomUUID)
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"
hc-lisp> (str/upper-case "node.js rocks!")
"NODE.JS ROCKS!"
_

Features

โšก

Fast & Modern

Built with TypeScript for type safety and modern JavaScript performance

๐ŸŽฏ

Node.js Integration

Built-in namespace system with import/require for Node.js modules

๐Ÿงช

Thoroughly Tested

Comprehensive test suite with Jest, including individual isolated tests for each .hclisp file

๐Ÿ“Š

Rich Data Types

Lists, vectors, maps, keywords, and more built-in data structures

๐Ÿ”ง

Functional Programming

First-class functions, closures, and higher-order function support

๐Ÿš€

Easy to Use

Simple REPL interface and straightforward API for integration

Examples

Basic Arithmetic

;; Basic operations
(+ 1 2 3)        ; => 6
(* 2 3 4)        ; => 24
(/ 12 3)         ; => 4
(< 3 5)          ; => true

Functions & Variables

;; Define variables
(def x 42)

;; Define functions
(defn square [x] (* x x))
(square 5)       ; => 25

;; With let bindings
(let [a 10 b 20] (+ a b))  ; => 30

Lists & Collections

;; Working with lists
(first [1 2 3])    ; => 1
(count [1 2 3 4])  ; => 4
(cons 0 [1 2 3])   ; => (0 1 2 3)

;; Check predicates
(even? 4)          ; => true
(empty? [])        ; => true

Advanced Features

;; Higher-order functions
(map square [1 2 3 4])      ; => (1 4 9 16)
(reduce + 0 [1 2 3 4])      ; => 10

;; Mathematical functions
(sqrt 16)                   ; => 4
(abs -5)                    ; => 5

Namespace & Node.js

;; Create namespace and import modules
(ns my-app
  (:import
    (node.crypto randomUUID)
    (node.fs existsSync)
    (node.path join)))

;; Use Node.js modules
(crypto/randomUUID)           ; => Generate UUID
(fs/existsSync "file.txt")    ; => Check file
(path/join "src" "main.ts")   ; => Join paths

;; Built-in functions
(str/upper-case "hello")      ; => "HELLO"
(json/stringify {:key "val"}) ; => JSON string

Getting Started

Installation

$ npm install -g hc-lisp

Run

$ hc-lisp
# or
$ hclisp

Basic Usage

;; Start with simple expressions
(println "Hello, HC-Lisp!")

;; Define and use functions
(defn greet [name]
  (println "Hello," name))

(greet "World")

Namespace System

;; Create namespace with Node.js integration
(ns my-app
  (:import
    (node.crypto randomUUID)
    (node.fs existsSync)
    (node.path join)))

;; Use imported modules
(println "UUID:" (crypto/randomUUID))
(println "File exists:" (fs/existsSync "package.json"))

;; Built-in string functions
(println (str/upper-case "hello world"))  ; => "HELLO WORLD"
(println (json/stringify {:name "HC-Lisp"}))  ; => JSON

Testing & Quality

Comprehensive Testing

  • Unit tests for all language features
  • Individual isolated tests for each .hclisp file
  • Namespace and Node.js integration tests
  • Error handling validation
  • Type safety with TypeScript
  • Jest framework for modern testing