A super cool routing library for Clojure’s Ring web framework

Once of the great philosophies in the Clojure community is to build small independent specialised libraries which can be nicely composed to solve problems. So rather than build solutions from massive complex web frameworks with various tradeoffs and opinionated solutions, Clojurians’ prefer to pick the right tool for the task at hand.

There are a few different options out there for routing, including gudu, bidi, Reitit, and playnice, as illustrated in 10+ Frameworks For Building Web Applications In Clojure by Nordic API’s. …


Less Boilerplate, more productivity!

I thought I would share some of the key changes that I discovered when using an updated NgRx Store, elabourate on some of the basic components and features covered in the documentation and highlight some of the newer ways of working with NgRx Store (version 9.2.0).

We will cover some basics of setting up NgRx for a new project and then take a look at the new-ish createAction and createReducer higher-order helper functions that simplify a lot of the common boiler-plate that was previously required.

Better Tooling

One of the first cool features is that we can now add new feature stores via the angular command-line client. …


In this post we will be exploring reducers and Clojure’s high-performance reducer library. It can be tempting to skip learning about or using reducers when first getting to grips with Clojure, as the recursive nature, higher-order functions and general nomenculture can appear daunting at first.

The key to making things easier to understand is to learn how the main reduce function iterates over a collection to produce a value. …


Collectively these broadcasts are known as number stations and many countries operate them. Let’s open that curiosity door…

Like most people who grew up on a diet of 1980’s culture, I am a huge fan of Stranger Things Season 3. At the beginning of Season 3 we find out that Dustin has managed to intercept a top secret radio broadcast, which features a strange coded message in Russian:

The silver cat feeds when blue meets yellow in the west…

Admittedly the Russians probably wouldn’t have been so naive as to broadcast directions to their secret base without some form of encryption, but creepy Russian broadcasts using cryptic code words do actually exist. …


Higher level abstractions for asynchronous things in Clojure

In this piece and I am going to explore the Manifold library to take a look at Manifold’s Deferred, Stream and Event Bus features. This is a really handy tool kit for anyone doing asynchronous programming in Clojure[Script]. We can use deferred values to helps us to manage and abstract away some of the complexity of dealing with values that might arrive asynchronously, streams to connect all sorts of things together and an Event bus to provide a simple event driven messaging architecture.

Towards the end of the article we will also look at how these tools can be combined to perform asynchronous communication between the front and back-end of our app using a web-socket. Although we won’t be going into any topic in particular detail, it might be helpful to get an overview of the library and what it has to offer. …


Should we be using Monads in Clojure?

In this piece I am going to explore the world of Monads for functional programming. We will look at what the basic Monads are and how to use the Cats library and I will also be looking at why we perhaps shouldn’t be using them, and should instead be looking at Clojure’s spec library or Clojure’s other language features.

Image for post
Image for post
Photo by Raul Varzar on Unsplash

“A person who understands what a monad is instantly lose the ability to explain it to others” — Duglas Crockford

To get started I will focus on the practical application of using some Monads from the excellent Clojure[Script] cats library by Andrey Antukh and Alejandro…


How stolen ideas, patent wars and scandal changed the world…

1943 was an interesting time in history. World War II was causing death and destruction around the world, Alan Turing was over at Bletchley Park cracking the German Enigma code, and the US Army were hard at work perfecting the designs for the first Atomic Bombs.

We have all heard the tale of Alan Turing and his famous Enigma cracking machine. Most people however, are completely unaware that the blueprint of the modern computer was not designed by Turing or the scientists at Bletchley Park. …


How do Reactive Forms work under the hood?

It is time for another deep dive into Angular dear reader. In this article we are going to look at Angular’s Reactive Forms library under the hood, to see how it models forms and GUI elements.

I thought I would take a slightly different approach and poke around in the Angular source code to try to understand how the form controls and directives work, as there are plenty of tutorials on Reactive forms already available online, including the excellent tutorial in the Angular docs.

Let’s start by looking at the @angular/forms library on github.com. …


Getting started with channels and the core.async library

Core.async is Clojure’s main library for asynchronous programming and communication. It makes asynchronous programming a lot easier by doing much of the heavy lifting for you.The library has a few objectives which you can read about here, but chiefly it aims to:

  • To provide facilities for independent threads of activity, communicating via queue-like channels
  • To support both real threads and shared use of thread pools (in any combination), as well as ClojureScript on JS engines
Image for post
Image for post
Photo by nima hatami on Unsplash

Channels

The basic building block is the Channel. Core.async provides a number of channel types off the shelf; buffered channels, dropping-buffer channels and sliding-buffers.

You can think of a channel as a conveyer belt of items that you can add at one end of the conveyer belt and take from the other end. You can only take one item at a time and occasionally you might have to queue up outside of the conveyer belt if there are other people adding items on in front of you. Sometimes you might have to also queue up to collect your items too. The belt can vary in size as well. Small conveyer belts can result in large queues building up outside, especially once the belt becomes full and there are no more people to collect their items. …


Backend API development made simple with Clojure

I am going to write this up for anyone who is just starting to get into Clojure or for anyone else who is curious to see how a simple API server could be built.

Clojure is a really great functional programming language with many cool features. Hopefully you will find this tutorial useful if you have skimmed through the Clojure documentation to get a feel for the basic datatypes and language, or perhaps dabbled in the REPL writing some simple functions.

Image for post
Image for post
Photo by Ana Martin on Unsplash

We are going to build a simple REST API to get a feel for what a simple API back end might look like. To do this I will be using the fantastic HTTPKit Compojure and data.JSON …

About

Functional Human

Functional Programming for Humans

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store