Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
ghostwheel
Hassle-free inline clojure.spec with semi-automatic generative testing and side effect detection
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
I haven't tried it myself. I generally just use truss for runtime constraint checking. I use a modified version that integrates scope-capture. And malli validation for more complex cases, but I try to limit that. For me it is better to validate individual attributes as needed, vs validating an entire "type"/collection of attributes. So each function only cares about the attributes that it needs, and validates only as needed.
I haven't tried it myself. I generally just use truss for runtime constraint checking. I use a modified version that integrates scope-capture. And malli validation for more complex cases, but I try to limit that. For me it is better to validate individual attributes as needed, vs validating an entire "type"/collection of attributes. So each function only cares about the attributes that it needs, and validates only as needed.
if all you care about is information / documentation, and maybe validation, then spec or malli are fine. using spec during runtime to simulate a type system is a poor choice in most cases, because you are doing runtime type checking (something akin to dependent types or even esoteric contracts that are hard/impossible to express statically). There are some libs that help bolt a typed facade (using spec) onto the familiar defn / fn, https://github.com/gnl/ghostwheel https://github.com/Provisdom/defn-spec .
if all you care about is information / documentation, and maybe validation, then spec or malli are fine. using spec during runtime to simulate a type system is a poor choice in most cases, because you are doing runtime type checking (something akin to dependent types or even esoteric contracts that are hard/impossible to express statically). There are some libs that help bolt a typed facade (using spec) onto the familiar defn / fn, https://github.com/gnl/ghostwheel https://github.com/Provisdom/defn-spec .
I like spec-tools data specs. I never got into schema, although I was aware of it. spec came along and swept a substantial portion of the crowd (I think the interleaving of parsing and regex style operators is slick/useful). Malli looks excellent though, and I think it's worthy of learning. I have no opinion on spec2 as of yet.
Meta comment: Many complex tree shapes are actually projections of a graph. Graphs are shapeless and normalized; it is the query that projects the graph into tree shapes that are denormalized. Thus massive python/java nested OO data models with rigid and denormalized shapes can be collapsed into a flattened, normalized graph. Do you have a graph? Clojure has easy graph data structures through https://github.com/tonsky/datascript
This library https://github.com/plumatic/plumbing, a predecessor of spec, has variants of defn and fn that allow you to specify the schema inline, sort of similar to type hints.
Related posts
- FlowStorm a omniscient time travel debugger for Clojure/CLJS
- build.simple: tools.build without the DIY – install, sign and deploy libraries easily and securely like with Leiningen
- What I Have Changed My Mind About in Software Development
- Playback – Interactive Programming and Print Debugging Reimagined (successor to Ghostwheel's tracing component)
- XTDB on Mobile Possible?