Transducers for total beginners

December 5, 2016

"Transducer" has to be the most intimidating name in all Clojure-land. For everyday use, however, they're really simple. (I don't get the truly fancy stuff, like writing one's own transducers, or getting them to hold state.)

The simple "for beginners" (recommended experience level: you know how to use map and reduce and function composition and the threading macro) flavor of transducers is: like function composition, but with some more fancy.

Continue reading →

Using macros to get data into Clojurescript front-end pages

December 4, 2016

Suppose you want to construct pure front-end static pages that will be as fast as possible. Optimum speed at least arguably involves minimizing server round trips. Ideally, everything should be one round trip, which should fetch all code and data for the entire site (so long as it isn't huge). This minimizes network latency, permits aggressive caching strtegies, the use of services like cloudflare to optimize the stink out of everything, etc.

But that comes at a cost. If everything is bundled up together, that means instead of, say, having your SPA application go fetch some markdown from the server with an AJAX request and render it to the user (network round trip! oh noes!), you get to mix the code and the data. But that's just ugly, and hard to maintain. For example, this is what some of the code from gowder.io, which is just a personal static site built with Reagent, looks like:

Continue reading →

Devcards for Testing Clojurescript Projects: A Beginner Introduction

December 3, 2016

Devcards is an amazing library that basically lets you create a separate test build of a Clojurescript project. The documentation is pretty clear, but if you're a relative Clojurescript beginner like me, you'll need a little bit more hand-holding. So here's my mini-walkthrough for getting Devcards integrated into a CLJS project, targeted at people who know the basics. (Recommended background knowledge: can set up a small Clojurescript project, perhaps with help of a lein template, and get it to compile. It will also help to know how testing works on JVM Clojure-side with clojure.test.).

Why?

Continue reading →

Figwheel + Spacemacs

December 2, 2016

I've been trying to figure out how to get Figwheel and Spacemacs to play nicely together for a while. It turns out it's much easier than it looks (required knowledge level: reasonable comfort with front-end Clojurescript and leiningen, prior use of Figwheel, successful installation of Spacemacs and use of Clojure mode).

Relevant documentation: Using the Clojure layer in Spacemacs, using Figwheel in nREPL.

Continue reading →

Cryogen + Github pages + Klipse

October 17, 2016

Hello world, and all that jazz. I've decided to start a tech blog.

The first challenge: getting it up. Static site generators seem to be fashionable these days, and I'm a big fan of Clojure, so naturally I went with Cryogen, which is a dead simple static site generator where you literally fire up a lein template and then edit a bunch of markdown files and simple Selmer templates plus a single config edn. And Github Pages is both free and convenient name recognition for code-oriented things, so that's the obvious choice for a host.

Continue reading →