Welcome
NOTE: Not released yet - finishing up on distribution/documentation
Deft is a TCL-meets-Clojure programming language. It pairs TCL's shell-friendly command syntax with Clojure's data abstractions: immutable persistent data structures, lazy sequences, transducers, protocols, and a rich functional core.
The runtime is written in Zig and compiles to a single self-contained binary with no external dependencies. Scripts are parsed to S-expressions, compiled to bytecode, and executed on a stack-based VM with tail-call optimisation. It's neck and neck with Python on some standard benchmarks.
Does It Work? Can it Scale?
Deft is more than a language, it ships with a full UI platform with functionally equivalent hosts for scripting, GL and Ansi (also embedded). The Deft apps on the right exist with publically available source, the editor has more than 7000 lines of Deft. All apps are interoperable via pubsub or rpc. In fact the Deft platform is very similar to what Emacs offers with a Blender style tiled interface and workspaces. Check out the Highlights page.
Work in Progress, Evaluation
Deft is a WIP, the runtime/language sources are currently not open, however, runtimes binaries and all Deft source for the apps are.
If anyone is interested in commercial opportunites or open sourcing Deft in a Blender style "Free the Source", please contact me ritchie@deft-lang.org.
# Three call forms — pick the one that reads best in context set name "Alice" echo "hello $name" # bare (top-level statement) set length $name(len) # postfix (single-arg on a variable) set mid $name(1..3) # postfix range slice — chars 1..2 set total ($price * $quantity) # infix (arithmetic / comparison) # Pipelines thread a value through a chain def numbers @{ 1 2 3 4 5 } def even? {|x^number| [mod $x 2] == 0 } $numbers |> [filter even?] |> map { $it * 2 } |> collect # => @{ 4 8 } # Persistent data: lists, maps, sets, tagged maps def user %User{ name "Alice" roles ^{:admin :user} } # Pattern matching match $user~roles { %{ :admin } => "is admin" _ => "is not admin" } # Protocols and types deftype Point %{ :x %{} :y %{} } defimpl Point Drawable { draw {|ctx bounds| @doc "Draw a point at (x, y)" [draw/cell $ctx $self~x $self~y "*"] } }
Language Features
The features that make Deft, Deft.
- TCL command syntax —
[echo "hello"], or top levelecho "hello" - Infix expressions in parens —
($a + $b),($n == 0) - Postfix sugar on values —
$str(trim),$items(first),$m~field - Range slicing —
"string"(0..1),$list(2..5),$xs(1..)— postfix slices of strings and collections - Immutable persistent collections — lists
@{}, maps%{}, sets^{} - Lazy sequences & transducers — Clojure-style
map/filter/take/comp/into/transduce - Pattern matching —
match, type patterns, guards, or-patterns, ranges, regex - User types & protocols —
deftype,defprotocol,defimpl,defmethod - Coroutines & async tasks —
defcoro+spawn/vwait,deftask+await,defworker+worker/send - Macros — Elixir-style
defmacrowithmacro/quote/macro/unquote - Native FFI — load shared libraries, call C functions
- Batteries included — HTTP client/server, SQLite, JSON/YAML, TCP/UDP, regex, crypto
Apps built with Deft
Editors, tools, and games from the packages tree.
Benchmarks
Deft vs CPython — representative suite.
The retro workspace
btc, sysmon, codegraf, sheet and flappy tiled side by side.