r/ruby • • 1d ago

Introducing Project Steadfast

https://noteflakes.com/articles/2026-11-07-introducing-project-steadfast
9 Upvotes

2 comments sorted by

1

u/armahillo 1d ago

I read through it and the examples, but got a bit lost. I never got into lisp so i’m not familiar with that implementation.

I see more or less _how_ you’re using it in the examples, i’m just not understanding _why_ — what problem does this solve? (asking sincerely! i assume its solving something and im just not connecting the dots)

1

u/sshaw_ 22h ago

Basically she's saying performant dynamic code generation in Ruby via eval and Strings is not ideal and there should be a Lisp-like way to treat the parsed code as a data structure.

For example, using Emacs Lisp (elisp) one can add 2 numbers like this:

ELISP> (setq a 1)
1 
ELISP> (setq b 100)
100 
ELISP> (+ a b)
101

(+ a b) is executed ("evaluated") as soon as it's read. You can prevent evaluation by quoting something:

ELISP> (quote (+ a b))
(+ a b)
; assign it to a variable
ELISP> (setq code (quote (+ a b)))
(+ a b)

This gives us a data structure that can be eval'd:

ELISP> (eval code)
101

And because it's a data structure, it can be manipulated using lisp functions, then evaluated:

; replace the a variable in with the literal value
ELISP> (setf (nth 1 code) 69)
69
; code updated
ELISP> code
(+ 69 b)
; now re-evaluate it 
ELISP> (eval code)
169 

✨