Clojure
ClojureScript Tutorial
Learn about ClojureScript and how to set up a project using shadow-cljs.
How to install Clojure
Easy to follow installation guides for the three main platforms: macOS, Linux, and Windows. This guide shows you how to install everything you need: Java, Leiningen, and the Clojure CLI tool.
Learn to build a Clojure web app - a step-by-step tutorial
Learn to build a Clojure web backend from existing components, step-by-step.
Clojure Tutorial
Learn Clojure syntax, set up a development environment, then build a fun project.
Clojure Web Servers
How do you choose which web server to use for a Clojure web application? I share my recommendations. There are two excellent choices—both fast and reliable.
The Ultimate Guide to Learning Clojure for Free
There are many great resources out there for learning Clojure. Some resources are paid, but fortunately, many of the best resources are absolutely free.
10 Programming projects to boost your resume
When NOT to put personal projects in your resume; tips for choosing programming projects; and how to present your projects to maximize your chances.
13 hours of Lisp
My personal notes from the Lisp50 event at OOPSLA 2008.
2 Features of Clojure Editors Professionals Won't Do Without
Professional Clojure programmers rely on certain features of their editors to help them program. When choosing an editor, it's important to pick one that has these two important features: REPL integration and structural editing.
3 Things Java Programmers Can Steal from Clojure
Many of the cool parts of Clojure are written in Java. That means you can access those parts from any Java code. Just include the Clojure JAR, import the classes, and you've got better tools.
4 Features Javascript can steal from Clojure(Script)
ClojureScript adds a lot of value on top of the Javascript platform. But some of that value can be had directly in Javascript without using a new language.
4 Things Java Programmers Can Learn from Clojure without learning Clojure
5 Differences between clojure.spec and Schema
Schema and clojure.spec aim to solve similar problems. There are significant differences, though, that might not be obvious at first.
5 features of Clojure let
Clojure let is used to define new variables in a local scope. This article describes a few things you probably know about let, and a few you don't.
5 ways to tweak your resume
5 functional programming ways to impress a hiring manager with your resume.
6 things Reacters do that Re-framers avoid
Down on React? You should check it out from the ClojureScript perspective.
A Model of Interceptors
A reduce Example Explained
A deep-dive into a single reduce example shows how much can happen in a short bit of code.
All about clojure.set
clojure.set is part of the standard library that comes with Clojure. It has functions for doing set operations and relational algebra.
Annotated map
map is one of the staples of functional programming. It's totally useful and also surprisingly simple. Let's look at some examples and annotated code.
apt-get install leiningen - Elana Hashman
What does it take to have a one-command install for Clojure on Debian? Recorded at Clojure Sync 2018, New Orleans.
Are there any DOM manipulation libraries in ClojureScript?
ClojureScript has some nice DOM manipulation options, including jQuery and more idiomatic libraries.
Are there enough functional programming jobs?
Is functional programming a fad? We cut through the buzz cycle and answer the question once and for all.
Atom code explanation
I go over a real-world example of how atoms and immutable values allow you to compose constructs in ways that are easy to reason about and less prone to error.
Building a World Class (Clojure) Team - Rebecca Kinsella
I asked Rebecca to talk about the topic of hiring and getting hired. Funding Circle has built a great team and so they must have a lot of knowledge to share. How do you find good Clojure programmers? What do you look for? What should candidates be prepared for when starting their job search? Hiring is a persistent, perceived barrier to Clojure adoption. This talk should help crack that nut. Recorded at Clojure Sync 2018, New Orleans.
Can building ClojureScript assets be integrated into my build process?
ClojureScript's official build process is a simple shell command. There is also integration into Leiningen and Boot.
clj-refactor cheatsheets
I've made some cheatsheets to help me learn clj-refactor, some Emacs software that helps you make systematic changes to code.
cljs.main - David Nolen
We were honored to have David announce cljs.main, then a new tool to run ClojureScript from the command line. Recorded at Clojure Sync 2018, New Orleans.
Clojure + Ruby
If you're a Rubyist and you've heard some buzz about Clojure, these videos and links will be just for you. Rubyists teaching Clojure, Clojurists introducing Clojure to Ruby programmers, and Rubyists pontificating on Clojure.
Clojure Atom: A Complete Guide
Learn how to use Clojure's most popular concurrency primitive. Atoms let you safely read and modify mutable state across multiple threads.
Clojure Concurrency Tutorial
From Agents to Executors, this guide covers all of the important concepts for concurrent programming in Clojure. It includes a comprehensive catalog of concurrency primitives.
Clojure Data Structures Tutorial
Clojure's collections are central to Clojure programming. While in most languages, you might find collections somewhere in the standard library, in Clojure, they are front and center.
Clojure Error Messages are Accidental
I've recently shifted my thinking about Clojure error messages. It is more useful to think of them as non-existent than to think of them as bad. We end with the role Spec can play in improving error messages.
Clojure for dummies: a kata
Clojure HTML Templates
Clojure is a better Java than Java
How is it possible that Clojure is better than Java at its own game? Hear me out, then decide for yourself.
Clojure is Imperative
Clojure is an imperative language. Its operations are defined in terms of concrete actions. But those actions are often the same actions available to the programmer at runtime. This makes it easy to bootstrap.
Clojure Jobs Resources
A big list of sites with Clojure job listings. If you're looking for a job in Clojure, these are the best places to look. Includes many remote jobs.
Clojure Regex Tutorial
With a few functions from the standard library, Clojure lets you do most of what you want with regular expressions with no muss.
Clojure Routers
How do you choose which Clojure routing library to use in your web app? I share my recommendations and how to decide based on your needs.
Clojure vs. The Static Typing World
Rich Hickey explained the design choices behind Clojure and made many statements about static typing along the way. I share an interesting perspective and some stories from my time as a Haskell programmer. I conclude with a design challenge for the statically typed world.
Clojure web requests
Learn to build a Clojure web backend from existing components, step-by-step.
Clojure Web Security
Use the OWASP Top Ten Project to minimize security vulnerabilities in your Clojure web application.
Clojure's Hosted Legacy
Clojure was designed as a hosted language. So what is Clojure, the language, if it relies on the features of a host? And what are the disadvantages of choosing the JVM as a host?
Clojure's unsung heroics with concurrency
People know about the immutable data structures and the STM. But there's something going on at a much deeper level that is really hard to get right in Java. It has to do with the optimizations the JIT will run on your code.
ClojureScript + Reagent Tutorial with Code Examples
Reagent is a ClojureScript wrapper around React. It makes it easy to create React components using functions and hiccup, and state managed in Atoms.
Conveyor Belts: Nature's core.async Channels
Conveyor belts are strikingly similar to Clojure core.async channels. While it could be a coincidence, there is speculation that conveyor belts were influenced by a deep understanding of core.async.
Convince your boss to use Clojure
Clojure has been successfully adopted by many companies. There are many resources available by people who did the hard work of introducing Clojure to their team.
core.async Code Style
If your functions return `core.async` channels instead of taking callbacks, you encourage them to be used within `go` blocks. Unchecked, this encouragement could proliferate your use of `go` blocks unnecessarily. There are some coding conventions that can minimize this problem.
core.async in Browsers
Javascript's concurrency model forces code to give up control of when a callback will be called. `core.async` gives you back that control and hence lets you code in a more natural style.
Data > Functions > Macros. But why?
"Prefer data over functions" is a common adage in Clojure circles. It is poorly debated because it is a terse statement in generalities. A valuable perspective is that data is transparent at runtime, while functions are not. This perspective gives a firm ground for discussion and design.
deftype vs defrecord
There are two commonly used ways to create new data types in Clojure, deftype and defrecord. They are similar but are intended to be used in two distinct use cases. deftype is for programming constructs and defrecord is for domain constructs.
Elm FRP in Clojure core.async
Elm is an exciting FRP language. I implemented the FRP part in Clojure using core.async.
Example-based Unit Testing in Clojure
Unit testing in Clojure is straightforward. Here are a few testing ideas as they apply to Clojure.
Exponential Backoff
A common failure in distributed systems is a server with a rate limit or with no limit but begins failing due to load. A standard solution is to retry after waiting a small time, increasing that time after each failure. We create a macro to handle this waiting and retrying.
Functional JavaScript
Many of us have to use JavaScript. But does that mean we can't use functional programming? Sure, with discipline. But can we make it even easier?
Hiccup Tips
Hiccup is a Clojure DSL for generating HTML. If you're using it, you might like these tips.
Hindley-Milner in Clojure
I wrote a lambda-calculus interpreter and an implementation of Hindley-Milner to type check it.
How can more layers be more efficient?
It's common that adding more layers of abstraction or indirection will make things slower. However, React and ClojureScript make web pages faster than doing it by hand — essentially programming the bare web. The lesson is that if you choose your layers well, they can actually make your system faster.
How can you test ClojureScript applications and libraries?
Although it's still early, ClojureScript is rapidly maturing its testing story. There are a Leiningen plugin and a Boot task for autocompiling ClojureScript as it changes and running tests in a variety of engines.
How do Clojure Programmers Deal with Long Startup Times
Clojure startup times suck. Let's just be honest. How do Clojure programmers live with that? Maybe that's the wrong way to think about it.
How I made my Clojure database tests 5x faster
Setting up and tearing down a test database can be slow. Use a rolled back transaction to quickly reset the database to a known state. You can do that in an `:each` fixture to run each test in isolation.
How to leap past 90% of applicants
Josh Doody (Salary Negotiator) and Eric Normand critique a functional programming résumé and give advice for making it better. They also talk about preparing for the interview and the salary talk.
How to Read Clojure Code Like an Expert
As you get better with Clojure, it becomes easier to read. Why not jump ahead of the learning curve and read like an expert? Focus on the first thing, use the indentation, and read the evaluation order.
How to Use New Relic with Clojure on Heroku
New Relic lets you get more out of Heroku. Install it in 7 steps.
How to use React Lifecycle Methods in Re-frame
Learn the 4 React Lifecycle Methods you'll need to know for Reagent/Re-frame and why the other 6 are not needed.
Idiomatic way to represent sum type (Either a b) in Clojure
Infinite Application
Function application is a key concept in lambda calculus. While it is commonly expressed using parentheses in Clojure, it is also reified into a function which itself can be applied to another function.
Is core.async Against the Clojure Philosophy?
Clojure core.async is a way to manage mutable state. Isn't that against functional programming?
Java Generational Garbage Collection
The JVM's garbage collector allows for Clojure's persistent data structures to be practical. It's one of the benefits of being a hosted language: you can take advantage of the millions of dollars invested into the JVM's development.
Job application action plan
A complete massive action plan to get a functional programming job.
Join and build a social network
Getting to know people who can help you get functional programming jobs.
JSON Serialization for APIs in Clojure
Clojure is well-suited for processing JSON, but there are some decisions you have to make to suit your application. The major decisions are actually easy, though they took me a while to figure out.
JVM Deployment Options
When you're working at a company, you usually inherit their deployment system. And that's great because then you just do what they do. But what if you are on your own? What are the options for deploying a Clojure server?
JVM JIT Optimizations
The JVM JIT is a highly optimized compiler. I present some resources for learning what it does.
Knowing this one ClojureScript gotcha will save you hours
ClojureScript optimizes names by replacing them with shorter ones. Usually, that's a good thing. But it can get carried away. Externs are how you help it know what's unsafe to optimize.
Lambda Abstraction
Lambda abstractions are always leaky, but some are leakier than others. Clojure programmers recommend keeping most of your functions pure and containing the leaks as much as possible.
Let's TDD clojure.core/map
Learning to write map is a good lesson because it has recursion, list building, and higher order functions. It's everything that makes Lisp great.
Let's TDD clojure.core/reduce
`clojure.core/reduce` is a powerful function, yet the code for it is so simple. It's four lines! We TDD our own implementation.
Locks vs Concurrency Primitives
Many people have asked me why Clojure has concurrency primitives. Aren't locks good enough? A humorous metaphor is elaborated.
Nil Punning (Or Null Pointers Considered Not So Bad)
Null pointers are still a problem in Clojure, but several design decisions have made them less problematic than other languages.
Object-Oriented Dispatch is the Dual of Functional Dispatch
Object-oriented dispatch is contrasted with functional dispatch, but they are shown to be two one-dimensional projections of the same two-dimensional data. Clojure does not provide the two-dimensional representation, but does interesting things to transcend the one-dimensional views.
Optimistic Update in Re-frame
How do we deal with that little bit of time between when the user clicks and the server confirms the change is saved? Well, like many things in life, there are two ways: optimistically and pessimistically.
Parens vs Brackets in Clojure
Clojure uses both parentheses and square brackets as part of its syntax. It might at first appear to be arbitrary, but it's actually systematic. What's more, it reveals one of the coolest things about Clojure: expressions define how they interpret their arguments.
Problems with the JVM
The JVM is great but far from perfect. Here are some problems with the JVM that Clojure has to work around.
Re-frame Database Best Practices
Your Database is going to contain a lot of important information. When you’re first starting out your app, you don’t know exactly what you’re going to store in there. In addition, you don’t know how you’re going to want to access it. Both of these will evolve over time as you understand more of the domain and you uncover the complexities of your UI. We want some help from the framework (Re-frame) to help us deal with this evolution.
Re-frame Tutorial with Code Examples
Re-frame adds a beneficial amount of structure to your frontend app. This guide goes over all of the pieces of that structure and how to use them.
Re-frame, a Visual Explanation
We look at a sequence diagram to organize the parts of Re-frame.
React: Another Level of Indirection
React provides a better abstraction over the DOM than MVC frameworks ever can. React is the last piece of the puzzle for ClojureScript web frontend development.
Recommendations for Next-Level Clojure
There are many classics of functional programming that can help you take your thinking to the next level. My recommendations are for making you think in a new way.
Reduce Complexity with Variants
The structure of our data should match the relevant structures in the real world. And to ensure that our data is structured well, we should reduce the potential for incorrect structure. Variants provide a great solution for it.
Reification
Reification means making an abstraction into a concrete value that can be manipulated at runtime. Reification is the core of what makes a language dynamic. Three types of reification in Clojure are discussed.
Revenge of the Pragmatists - Baishampayan Ghose
BG has been a part of the Clojure community for a long time. I asked him if he could talk about the reality of building a company on Clojure--the good, the bad, and the ugly of the business-side of things. Recorded at Clojure Sync 2018, New Orleans.
Review: Clojure Programming by Chas Emerick, Brian Carper, and Cristophe Grand
Ring 1.0.0 Released
Should Cognitect do More for Clojure?
Poor open-source development practices, neglect for the beginner experience, and lack of communication have come up as complaints against how Cognitect stewards Clojure. I address the complaints with a plea that we do more as a community.
SOLID Principles in Clojure
The SOLID principles are guidelines for writing good Object-Oriented code. It turns out that these principles are followed and embodied in Clojure.
Some Annotated clojure.core/reduce Examples
reduce is a very useful function. You can use it for many calculations over a collection. Code annotations are useful, as are physical metaphors.
TDD Workflow in Clojure using Emacs with CIDER
TDD is about fast feedback. CIDER tightens the feedback loop with quick commands for running tests and a powerful test reporting system.
The 100 Most Used Clojure Expressions
Would you like to optimize your learning of Clojure? Would you like to focus on learning only the most useful parts of the language first? Take this lesson from second language learning: learn the expressions in order of frequency of use.
The 5 hurdles of hirability
Find out the two types of jobs that tell you how much you need to learn to be hirable.
The DCI Architecture: Lean and Agile at the Code Level
The Definitive Guide to Clojure on the JVM
The Java ecosystem is big and it can be daunting. But fear not! You don't need to learn everything, and once you learn enough, it will be worth it. You will realize that it is not so intimidating. This guide will be your . . . guide.
The Most Important Idea in Computer Science
Computer Science has ideas that are important to the broader world. The most important is the Universal Turing Machine. From one perspective, Lisp embodies the idea at its core. To really understand how, I ask you to implement your own Lisp interpreter.
The Parts of Ring
Ring, the Clojure Web library, defines three main concepts that you use to construct web applications.
Timeout Effect in Re-frame
Sometimes you need to delay an Event a certain amount of time. We need to turn setting a timeout into an Effect.
Token Buckets with core.async
Token Bucket is a simple algorithm for rate limiting a resource. It's easy to understand because you can reason about it in terms of real-world objects. core.async makes this algorithm very clear and easy.
Tricks for Java interop
There are several features of Java that generate weird classnames. We look at how to refer to them from Clojure.
Try Three Times in Clojure
Distributed systems fail in indistinguishable ways. Often, retrying is a good solution to intermittent errors. We create a retry macro to handle the retries in a generic way.
Virtual Threads in Clojure
How to use Project Loom from Clojure and take advantage of millions of threads.
Warty Lists in Clojure
Lists are kind of warty in Clojure. Care should be taken, especially by those coming from other Lisps.
What are macros?
Macros are one of the most talked about features of Lisp. They are a powerful way to extend the language without modifying the compiler.
What do you really need to know to be hireable?
Find out the two types of jobs that tell you how much you need to learn to be hirable.
What is Clojure?
Clojure is a general purpose programming language designed for the fast-approaching future.
What is ClojureScript?
ClojureScript is Clojure that compiles to JavaScript. It combines the power of Clojure with the reach of JavaScript.
What is React?
React is a view library for web pages that makes DOM rendering in a functional style really easy. React makes web programming fun again.
What my daughter's blocks teach us about learning
My daughter's blocks taught her to match shapes with a lot of fast feedback. Fast feedback is a powerful tool to learn any skill. I analyze how the blocks helped my daughter learn and compare it to learning Clojure.
What should a Clojure framework look like?
After exploring why frameworks and why not frameworks, I dive into the design priorities I think a web framework should have.
What Web Framework Should I Use in Clojure?
In this guide, I describe the available Clojure web framework options and give my recommendations.
What's the fastest way to get started using ClojureScript?
If you know Clojure already and just want to experiment writing ClojureScript, using Figwheel can really help get you there quickly. I show you how in a few commands.
When To Use a Macro in Clojure
Macros should be avoided to the extent possible. There are three circumstances where they are required.
Where do you find the time to get productive in functional programming?
Why we don't need to be productive in functional programming before we get a job.
Where do you put your Clojure tests?
Where to put your tests is a common question. You could put them anywhere, but you want to pick a place that makes it easy to find, easy to exclude from production, and work well with your tools. My recommendation is to follow what most projects do, which takes care of all of these requirements.
Where to find functional jobs
There has never been a better time to be a professional functional programmer. More and more companies are recognizing the value of functional programming. And companies are more open than ever to a polyglot workforce.
Where to find time to learn and practice Clojure
Learning any new language is a challenge, and Clojure is no different. Finding the time to learn and practice is a real challenge, so we need to make the most of what time we have. These tips will help you immerse yourself in Clojure.
Where to Store State in Re-frame?
This guide goes through the different ways of storing state in Re-frame and how to choose between Re-frame components.
Why Clojure starts up slowly — is it really the JVM?
One of the most common complaints about the JVM is the long startup time. But what is really taking so long? We analyze some commands to find out.
Why do we use Web Frameworks?
While contemplating a Clojure web framework, I explore the reasons we use web frameworks in general. I conclude that the framework should support a learnable development process.
Why does Clojure's conj add to the end of vectors but the beginning of lists?
conj can be confusing if you're used to other languages. It is not a commonly defined operation. Most languages define common positional adding operations. conj, however, has more useful semantics. How do you use conj usefully if you can't guarantee the position?
Why I start teaching Clojure with Imperative Programming
LispCast Introduction to Clojure starts with 30 minutes of imperative programming. We write programs for their effects, so imperative is a great place to start.
Why Re-frame instead of Om Next
I had to choose between Re-frame and Om Next when building a course. Here are the reasons why.
Will having ClojureScript, yet another asset type, slow down my deploys?
ClojureScript builds can take a long time. But the extra time is worth it. It reduces the download size significantly.
Willy Wonka and the core.async Guidelines
There are a few conventions in core.async that are not hard to use once you've learned them. But learning them without help can be tedious. This article presents three guidelines that will get you through the learning curve.
Won't it be hard to debug ClojureScript in my browser?
Even though ClojureScript adds another layer of abstraction, the tooling makes it easier to debug that plain JavaScript.
Wrangling Clojure Stacktraces
Clojure error messages and stacktraces are the number one most complained-about feature of Clojure. We look at some tips and resources for dealing with them.