This is study note for two videos: Solving Problems the Clojure Way and Transparency Through Data.
Learning Tasks
To learn Clojure, one needs to learn the following things:
- Syntax
- Common libraries
- Structural editing
- REPL workflow
- Clojure idioms
Functional Programming
- Minimize mutable states and side effects using derived values, immutable data structure, lambdas, and recursion.
- Put state mutation and side effects in one or a few places: concentration.
- Defer execution: describe and execute later.
Data-driven Programming
The formula is data > functions > macros
- programs as data flows
- use “plain data”
- data defines control flow: code generation from data
- making DSL
- configuration-driven
Some data-driven examples:
Hiccup
: reprsent HTML using vectors and maps.noprompt/garden
: render CSS.metosin/reitit
: define routes.
Transparency Through Data
Transparency is about understanding, which is about prediction. More constraints result better transparency. Use data and DSL to add constraints:
- avoid loops/recursion
- look for matching and destructuring
- look for static structure
- use namespace and keyword
- use different and specific data types
- use spec for complex grammars and validation