DEV Community

Cover image for Synapse 0.2: REPL, S-Expressions & Working Loops
Pavel
Pavel

Posted on

Synapse 0.2: REPL, S-Expressions & Working Loops

Hey everyone!

It's been a while since the last update on Synapse — the AI-first programming language built on Abstract Syntax Graphs. Today I'm excited to share version 0.2.0 with some major new features!

What's New in 0.2.0

1. S-Expression Syntax (Lisp-like)

I chose S-Expressions for maximum LLM-friendliness:

; Factorial using a loop
(let n 5)
(let result 1)
(let i 1)
(while (<= i n)
  (do
    (set result (* result i))
    (set i (+ i 1))))
result  ; => 120
Enter fullscreen mode Exit fullscreen mode

Why S-Expressions?

✅ Unambiguous structure — every expression in parentheses
✅ No whitespace dependency — unlike Python
✅ Easy for AI to parse and generate
✅ Homoiconicity — code is data

2. Interactive REPL 🖥️

$ cargo run --bin synapse

Synapse 0.2.0 - AI-friendly language
Type :help for commands, :quit to exit.

synapse> (+ 1 2)
3
synapse> (let x 10)
()
synapse> (* x x)
100
synapse> :quit
Enter fullscreen mode Exit fullscreen mode

REPL Features:

  • Command history (persisted)
  • :help, :quit, :ast, :clear commands
  • Execute files: synapse examples/demo.syn
  • One-liners: synapse -e "(* 6 7)"

3. Working Loops & Blocks

I have updated the interpreter to fully support while loops with the (do ...) construct for multiple statements:

(let sum 0)
(let i 1)
(while (<= i 5)
  (do
    (set sum (+ sum i))
    (set i (+ i 1))))
sum  ; 15
Enter fullscreen mode Exit fullscreen mode

Benchmarks

Operation Time
Simple arithmetic ~1.4 µs
Nested expressions ~1.8 µs
Conditionals ~2.1 µs
JSON serialization ~1.6 µs

Updated Roadmap

  • [x] S-Expression Parser (logos)
  • [x] Type Checker (Hindley-Milner)
  • [x] LLVM Backend
  • [x] Interpreter (30+ node types)
  • [x] REPL & CLI ✨ NEW
  • [x] While loops & blocks ✨ NEW
  • [ ] Recursive functions
  • [ ] Standard Library
  • [ ] Pattern Matching
  • [ ] VSCode Extension

Try It Now

git clone https://github.com/Xzdes/synapse.git
cd synapse
cargo run --bin synapse
Enter fullscreen mode Exit fullscreen mode

Get Involved

GitHub
Open issues, PRs welcome!

What features would you like to see next? Drop a comment below!

Top comments (2)

Collapse
 
xzdes profile image
Pavel

Mandelbrot fractal rendered in pure Synapse — an AI-friendly programming language I'm building. This example was pair-programmed with Claude AI to showcase the language's capabilities: complex arithmetic, nested loops, and string ops. 100 lines of S-expressions generating mathematical art!

M A N D E L B R O T S E T
============================

...............:::::::::::::::::::::::::::::::::::::::::::::::::::::::
.............:::::::::::::::::::::::::::::-----=------::::::::::::::::
............::::::::::::::::::::::::::--------=+==-----::::::::::::::
...........:::::::::::::::::::::::::----------=+%
#=-----::::::::::::
..........::::::::::::::::::::::::-----------==+# *==-------::::::::::
..........::::::::::::::::::::::-----------==# %
=-------:::::::::
.........:::::::::::::::::::::----------====+* ==-------::::::::
........::::::::::::::::::::---------======++
+======---:::::::
........::::::::::::::::::---------==
** ++++#=--::::::
.......:::::::::::::::::----------===+ % +---:::::
.......::::::::::::::-----------====+% *=---:::::
......::::::::::::---=====---=====+ %+==---::::
......:::::::-------== +===
+====++ %##----:::
......::::----------==% ## # ++** ==---:::
......::-----------===+ ## #=----:::
.....:------------=++* =----:::
.....:------======+ ## ==-----::
.....--===
=+++++## #+=------::
.....--====+++++## #+=------::
.....:------======+ ## ==-----::
.....:------------=++
=----:::
......::-----------===+ ## #=----:::
......::::----------==
% ## # ++* ==---:::
......:::::::-------== +===+====++ %##----:::
......::::::::::::---=====---=====+ %+==---::::
.......::::::::::::::-----------====+
% =---:::::
.......:::::::::::::::::----------===+ % +---:::::
........::::::::::::::::::---------==
** ++++#=--::::::
........::::::::::::::::::::---------======++* +======---:::::::
.........:::::::::::::::::::::----------====+
==-------::::::::
..........::::::::::::::::::::::-----------==# %
=-------:::::::::
..........::::::::::::::::::::::::-----------==+# ==-------::::::::::
...........:::::::::::::::::::::::::----------=+%
#=-----::::::::::::
............::::::::::::::::::::::::::--------=
+==-----::::::::::::::
.............:::::::::::::::::::::::::::::-----=------::::::::::::::::

Rendered with Synapse v0.6.0

Collapse
 
xzdes profile image
Pavel