PurelyFunctional.tv Newsletter 289: More Spec, Fewer Classes, Threading Macros

Sign up for weekly Clojure tips, software design, and a Clojure coding challenge.

Issue 289 - August 27, 2018 · Archives · Subscribe

Hi Clojurers,

I've got a new addition to the family, so this editorial is going to be short. Done!

Please enjoy the issue.

Rock on!
Eric Normand <eric@purelyfunctional.tv>

PS Want to get this in your email? Subscribe!

Why is making something first-class the key to expressivity? Podcast

We talk about making things first-class in functional programming. But why is it so important? Making something first-class is also known as reification, which means to make real. Philosophers name ideas and that makes them real. You can now have a discourse about them. We do the same in code, where we reify an idea and then it can participate in the program.

spec-tools GitHub

I missed this library from Metosin that is chock full of useful stuff for Spec. A lot of it looks like things to duplicate the coercion facilities of Schema.

spec-coerce GitHub

I also missed this library. Because we often coerce JSON values into edn, we often have to use strings to represent different types, like keywords, dates, and uuids. This library gives you a way to parse those strings, even if they're deeply nested, and have it match the spec (if it can).

Stop Writing Classes YouTube

I always come back to this talk. We abstract too much. Abstraction compounds. You make a couple of abstractions, and soon your code is swamped with indirection. You've got thousands of classes. So you need more documentation, you need dependency injection, you need to name things well, and you need complex IDEs to help you manage it all. The answer? Stop writing classes.

I Published an iOS App with ClojureScript and React Native

A nice experience report about a mobile app with ClojureScript and React Native.

The title is in the first-person. It was not me who did it.

Database Structure in Re-frame From the archives

Re-frame gives you a database that is essentially globally shared, mutable state. That could normally be a problem, but the other constructs Re-frame gives you make it work well. Subscriptions are your queries to that database, and Events are your writes.

Those two constructs create an interface around your database. That interface isolates the structure of the database from the rest of your code, which means the database can evolve over time independently of your other code. This is my recommendations for structuring your database so that it can evolve over time.

I'm honored that this guide is frequently recommended by the core Re-frame team.

How to deal with dirty side effects in your pure functional JavaScript

If you start learning about functional programming, it won't be long before you come across the idea of pure functions. And as you go on, you will discover functional programmers appear to be obsessed with them. "Pure functions let you reason about your code," they say. "Pure functions are less likely to start a thermonuclear war." "Pure functions give you referential transparency". On and on it goes. And they have a point. Pure functions are a good thing. But what do you do with the impure bits of your code?

Threading with Style

Stuart Sierra has some great recommendations for using the threading macros.

From Zero to Game Designer: how to start building video games even if you don't have any experience

Even though I'm not a gamer, I've always dreamed of making my own games. I love the idea of making my own world. This guide makes it sound pretty easy.

Clojure Collections Currently recording

While recording these lessons, I was struck by how much practical wisdom is bakes right into the access patterns. The access patterns correspond to Java interfaces that the collections implement (or Clojure protocols in ClojureScript). They define the "grain" of the material. If you go with the grain, things start to align, and your coding gets easier. Do check out this course. It's always good to revive your skills with the fundamentals.