We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
clojure.spec - Rich Hickey (from LispNYC, 2016)
"Rich Hickey presents Clojure.spec, a library for defining structural predicates and generating random data to test and ensure robustness in programming, while also improving code maintainability and error handling."
- Spec is a small tool for defining specifications
- A spec is a predicate that describes a data structure
- Spec is not runtime type checking, rather a way to define and test structural predicates
- Structural predicates are a way to specify the structure of a data structure
- Generators are used to generate random data that conforms to a spec
- Conform returns a new data structure that satisfies a spec
- Conform always returns a data structure, not a sequence
- One way to look at spec is as a logic library
- Spec is not just for single specs, but can be used with collections of specs
- Spec does not check for runtime type checking
- Spec is about describing what data must be true, not just what is possible
- The goal of spec is to be a better way to communicate and work with data, not just to define it
- Spec is used to generate random data that conforms to a spec, which can be used for testing
- The origin of spec is in logic systems and the desire for a way to communicate about what data means
- Spec is used in Clojure to make programs more practical and idiomatic
- Spec is not just for data structures, but for functions and arguments as well
- A spec for a function is what input it expects and what output it returns
- Spec is used to catch typos and errors in code
- Spec is used to make programs more robust and easier to maintain
- The community wanted a better way to get errors and exceptions, and spec is a response to that
- Generators are used to generate random data that conforms to a spec, and testing is a primary use of spec