It took me about 6 months to really think it through all the way, and get the design just right, so it feels good to finally publish it.
TLDR of 'why deft'
The problem is that:
- Clojure records use single-colon (unnamespaced) keyword access to lookup record fields
- Clojure records do not allow you to define abstract classes, or things that rely on complex dispatch behavior.
- Clojure records do not reload easily in the REPL, so you have to re-instantiate the object to see changes to method defs.
- Clojure maps are difficult to nail down. Even with libraries like Malli, it's hard to declare interfaces that explain "what can I do with this thing?" and "what multimethods do I need to implement?"
- Defining maps with Malli schema is not as enjoyable and ergonomic as the syntax of defrecord
The library is basically just plain maps, multimethods, and malli schema, but adds macros to allow you to use the same syntax as defrecord, and to define interfaces and implementations as lists of multimethods a type must implement.
The goal is to give something that's still enjoyable to work with, but lets you really nail down the behavior when you want to (and still keeps it ergonomic and fun).
A secondary goal was to make something that is reliable and stable, and is (hopefully) easy to adopt in existing codebases.
(more detailed explanation in video and on github)
announcing Deft: A new replacement for defprotocol and defrecord, using plain maps + malli schema
on youtube: https://www.youtube.com/watch?v=dlW6YzwUZ-M on clojars: https://clojars.org/org.clojars.sstraust/deft
Today I'm releasing deft!
It took me about 6 months to really think it through all the way, and get the design just right, so it feels good to finally publish it.
TLDR of 'why deft'
The problem is that: - Clojure records use single-colon (unnamespaced) keyword access to lookup record fields - Clojure records do not allow you to define abstract classes, or things that rely on complex dispatch behavior. - Clojure records do not reload easily in the REPL, so you have to re-instantiate the object to see changes to method defs.
- Clojure maps are difficult to nail down. Even with libraries like Malli, it's hard to declare interfaces that explain "what can I do with this thing?" and "what multimethods do I need to implement?" - Defining maps with Malli schema is not as enjoyable and ergonomic as the syntax of defrecord
The library is basically just plain maps, multimethods, and malli schema, but adds macros to allow you to use the same syntax as defrecord, and to define interfaces and implementations as lists of multimethods a type must implement.
The goal is to give something that's still enjoyable to work with, but lets you really nail down the behavior when you want to (and still keeps it ergonomic and fun).
A secondary goal was to make something that is reliable and stable, and is (hopefully) easy to adopt in existing codebases.
(more detailed explanation in video and on github)
check it out!
> 8000 programming languages in existence
> picks JVM family of languages
> picks the one functional language on JVM with bad typesystem
> why doesn't it have good types?
> builds own type system
> hmm.javac