Getting Started with HIL
This guide walks you through installing HIL, writing your first HIL LISP program, and running it either headlessly or on real hardware. By the end, you will have a working development environment and understand the fundamental workflow.
Prerequisites
- Node.js 18+ and npm (for the CLI and package manager)
- Go 1.21+ (for the host monitor and firmware compiler)
- TinyGo (only if flashing to Arduino hardware)
- A serial-capable device (Arduino Uno, Nano, or compatible)
Note: You can use HIL entirely headlessly without any hardware. The headless mode lets you develop and test LISP programs using only your computer.
Step 1: Install HIL CLI
The HIL CLI (hilp) is the primary interface for managing packages, compiling firmware, and deploying scripts.
# Install globally via npm
npm install -g @srashwan/hilp
# Verify installation
hilp --version
Step 2: Clone the Repository
git clone https://github.com/SRashwan/hilp.git
cd hil-os-v12
Step 3: Build the Host Monitor
cd hilp
go build -o hil-orchestrator ./firmware/
Step 4: Write Your First Program
Create a file called hello.hil:
; hello.hil - My first HIL LISP program
; This turns an LED on and off in a loop
(LOG "Starting HIL...")
; Set pin 13 as output
(PIN-MODE D 13 1)
; Blink the LED 5 times
(FOR i 0 5
(DO
(WRITE D 13 1)
(LOG "LED ON - Iteration " i)
(DELAY 500)
(WRITE D 13 0)
(LOG "LED OFF")
(DELAY 500)))
(LOG "Done!")
Step 5: Run Headlessly (No Hardware)
The fastest way to test your code is in headless mode, which simulates the hardware environment:
# Run the script in headless IPC mode
./hil-orchestrator -ipc -send hello.hil
This will output:
Starting HIL...
LED ON - Iteration 0
LED OFF
LED ON - Iteration 1
LED OFF
...
Done!
Step 6: Run on Hardware
Connect your Arduino Uno via USB and flash the firmware:
# Flash the firmware to Arduino Uno
hilp firmware flash --board uno --port /dev/ttyACM0
# Run the script on hardware
./hil-orchestrator -port /dev/ttyACM0 -baud 9600 -send hello.hil
The REPL
HIL includes an interactive REPL (Read-Eval-Print Loop) on the landing page that lets you test expressions instantly in your browser:
> (SET x 42)
42
> (+ x 8)
50
> (IF (> x 40) (LOG "big") (LOG "small"))
big
> (DEFUN CEL (c) (+ (/ (* c 9) 5) 32))
> (CEL 100)
212
The web REPL supports all operators, control flow, and function definitions. It is useful for learning the language and testing logic before deploying to hardware.
Project Structure
A typical HIL project looks like:
my-project/
├── src/
│ ├── main.hil ; Main program entry point
│ ├── sensors.hil ; Sensor library
│ └── utils.hil ; Utility functions
├── lib/
│ └── cyber.hil ; Community library (installed via hilp)
├── hil.json ; Project manifest
└── README.md
Next Steps
- Learn the Language Reference for complete syntax documentation
- Explore Operators for the full operator table
- Read about Control Flow for loops and conditionals
- Study the Firmware for hardware deployment
- Browse Examples for real-world programs
References
McCarthy, J. (1960). Recursive functions of symbolic expressions and their computation by machine, Part I. Communications of the ACM, 3(4), 184–195.
Papert, S. (1980). Mindstorms: Children, computers, and powerful ideas. Basic Books.