I just shipped Schematra 0.4 with some updates based on some usage and feedback.
Testing ergonomics: Went from 15+ lines of boilerplate to a one-liner by introducing structural testing. Routes can now return S-expressions (chiccup) instead of rendered HTML, so you test against data structures, not string parsing.
;; Assert against structure, not HTML strings
(test "returns greeting"
'(ccup [h1 "Hello"])
(test-route-body app 'GET "/hello"))
Structural middleware: Since routes return S-expressions and rendering happens at the framework boundary, middleware can inspect and transform the DOM structure before it becomes HTML. Want to inject CSRF tokens into every form? It's just an S-expression transform with sxml-transforms. No template engine plugins needed. (see the post for a complete example)
Performance notes: I benchmarked chiccup rendering at 145k ops/sec average (339k for simple elements, 2k for 50-row tables). Even worst case is 0.5ms - way below database/network latency, so no caching layer needed, at least not for now.
What's next: Besides the Redis-backed job queue and rqlite-based ORM mentioned in the full post, I'm working on improving route handling with automatic path parameter extraction:
(get "/posts/:id/comments"
;; :id automatically becomes a local variable
(display id)) ; just works, no (alist-ref 'id params) needed
Schematra is a Sinatra-inspired web framework for CHICKEN Scheme. Still pre-1.0, API is evolving based on real-world use.
funkaster•2h ago
Testing ergonomics: Went from 15+ lines of boilerplate to a one-liner by introducing structural testing. Routes can now return S-expressions (chiccup) instead of rendered HTML, so you test against data structures, not string parsing.
Structural middleware: Since routes return S-expressions and rendering happens at the framework boundary, middleware can inspect and transform the DOM structure before it becomes HTML. Want to inject CSRF tokens into every form? It's just an S-expression transform with sxml-transforms. No template engine plugins needed. (see the post for a complete example)Performance notes: I benchmarked chiccup rendering at 145k ops/sec average (339k for simple elements, 2k for 50-row tables). Even worst case is 0.5ms - way below database/network latency, so no caching layer needed, at least not for now.
What's next: Besides the Redis-backed job queue and rqlite-based ORM mentioned in the full post, I'm working on improving route handling with automatic path parameter extraction:
Schematra is a Sinatra-inspired web framework for CHICKEN Scheme. Still pre-1.0, API is evolving based on real-world use.Full post: https://schematra.com/blog/whats-new-in-schematra-0-4
Source: https://github.com/schematra/schematra
Benchmarks: https://github.com/schematra/schematra/tree/main/benchmarks
dannyobrien•2h ago