Skip to content
Tech News
← Back to articles

Show HN: Prela – Purely Algebraic Relation Combinators

read original more articles
Why This Matters

Prela introduces a novel, algebraic approach to querying that emphasizes clarity, efficiency, and mathematical elegance. Its focus on relation algebra and shallow embedding in host languages positions it as a promising tool for advanced data manipulation and analysis, potentially influencing future database query languages and data processing frameworks.

Key Takeaways

Prela: Purely Algebraic Relation Combinators

"The calculus of relations has an intrinsic charm and beauty which makes it a source of intellectual delight to all who become acquainted with it." —Alfred Tarski

Prela is an embedded query language based on Tarski's Algebra of Relations. Its queries are concise, clear, and fast. It is implemented by shallow embedding in a host programming language: Prela operators are regular functions in the host. The implementation follows continuation-passing style which compiles to efficient columnar execution.

Note Prela is a research prototype in early development. Expect constant and sweeping changes to both language design and implementation. I'm currently focused on polishing the Julia implementation, and there are vibe-ported experimental Rust and Zig ports on separate branches.

Example

Prela queries are readable even to those new to the language. Consider Join Order Benchmark 22a:

movie : (info → (Info . type == " countries " ) ∧ (Info . info in ( " Germany " , " German " , " USA " , " American " ))) ∧ (keyword in ( " murder " , " murder-in-title " , " blood " , " violence " )) ∧ (production_year > 2008 ) ∧ (kind in ( " movie " , " episode " )) → title × (data : (Data . data < " 7.0 " ) ∧ (Data . type == " rating " ) → Data . data) × (company : (Company . note ≁ r" \( USA \) " ) ∧ (Company . note ~ r" \( 200.* \) " ) ∧ (Company . country != " [us] " ) ∧ (Company . type == " production companies " ) → Company . name)

Intuitively, the query looks for movies satisfying several conditions:

It's German or American

It's a thriller

... continue reading