117 karma · joined October 17, 2015
Also I'm not on fecebook and don't want to create a user account, please don't force me to create one.
The alternative is to use data shapes that do not require something to be in a certain place. Hence the use of maps as the most basic data shape: you either have an entry in it, or you don't, no need to have a null entry. Expanding that thinking to databases, and you realise tables is not the right aggregate, instead you need to go one level down to something that datomic calls datom, or RDF calls a fact.
To summarise, PLOP forms that package together a set of slots to be filled magnify the issue of NULL/null/nil. Instead make the slot your primary unit of composition and make sure you use aggregation of slots that does not force you to have slots filled with a null value when there is no value in the first place.
- paths as data
- navigators as transducers
First I started using plain clojure code, then played with using xml-in [1], then created my own transducers and channels to build a dataflow-like pipeline manually, and finally started using specter because I wanted paths to be a data structure I can use to build the pipeline programmatically instead of manually. For that I needed a way for paths to become tranducers (which specter traverse-all does [2]), and I also needed paths to be a sequence of literals or "interned" elements [3] such as keywords or symbols, but not functions created on the fly. That way I can create a tree from a sequence of paths, using something similar to this SO answer [4], and build the pipeline. I'm almost there, I should end up in a situation where I can specify a list of paths to extract from an XML document, and the dataflow pipeline needed will be built automatically, with an input channel for the parsed XML, and output channels for each given path. If you use clojure.data.xml instead of clojure.xml, my hope is to have a one pass XML parsing of larger-than-RAM XML docs.
[1] https://github.com/tolitius/xml-in
[2] https://github.com/nathanmarz/specter/wiki/List-of-Macros#tr...
[3] http://www.yourdictionary.com/interning
[4] https://stackoverflow.com/questions/49515858/clojure-convert...
I'd argue Clojure is setting some new standard here with its powerful literal notation for basic data structures (list, vector, set, and maps) and its practice of integrating/composing first on data. Most of the time that's enough to get some libraries work together. If not enough, integrating/composing on functions is the next stage. Only after having covered data and functions should you consider macros, which should be easier to write if you have done a good job at the data and function levels.
If such powerful and ubiquitous data structures work so well for programs written in clojure(script), why would that not be true in the larger picture for integrating systems? JSON worked much better than XML because it actually represents simple data structures, not objects talking to each other. Redis, Avro, and similar tech are continuing that story while Kafka adds a fantastic transport and storage mechanism. Sounds like we're closer to having better foundations for integration in the small and in the large.
Data is a first class citizen of the language: data literal is part of its syntax, and it uses powerful persistent data structures behind that.
Programming with Clojure is what has made me realise that data is really what matters after all. None of that FP or OO discourse should deviate us from that reality check that computing is all about data-in/data-out. Pull the plug and/or battery of your computer and see what remains next time you power it up.
So yes, Clojure may not be revolutionary in itself, it does rely on the shoulders of giants. It is however setting a new standard in terms of being successful in bringing together a very well thought out set of features and philosophy to bring the focus of programming back towards the real complexity, instead of the accidental one created by how we think.
It is on this second half I'd like to comment.
It shifts the focus on form rather than content. Sure form has its non-negligible role, but in politics and most domains it should never take precedence over content, the actual message itself. And here lies one part of the problem Lessig is trying to go after: the corruption of our mind in its ability to be seduced by form at the expense of content. It is that kind of corruption that makes it possible for movie actors without real political substance to become president. It is that kind of corruption that makes the present political system a democratic farce.
If we want him to succeed we have to do our part too, and it's precisely because we haven't for ages, that we have such situation today. Even if he succeeds and changes the rules of the political game, if we the people also don't change the way we think, then this can start all over again in 4 years without us even realizing.
So maybe he could do with another pair of glasses, but we the people also need another pair of glasses.
Deal?