Clojure Study guide
A suggested study guide for those new to functional programming with Clojure.
MeetAMentor Clojure Study Group - 3rd November 2018 onwards
Week1: Overview of Clojure
Briefly discuss what the Clojure programming languages is good for, some example companies using Clojure and give suggestions on how to start learning Clojure.
- Simple Clojure exercises from ClojureBridge London workshop
- Understand the principles behind the design of the Clojure language by watching Simple made Easy by Rich Hickey (the author of Clojure)
Week2: REPL Driven Development overview and ClojureBridge London exercise review
Discuss REPL Driven Development (my blog post on the topic)
Week 3: Using the REPL and Structural editing
Part 1: Structural Editing
The first part of the video covers Structural Editing for Clojure development and the concept of code as symbolic expressions. Demonstrating the basic of structural editing using Spacemacs
Briefly covers the different editors that give a good Clojure experience. http://practicalli.github.io/clojure/development-tools/
Visit http://practicalli.github.io/spacemacs to learn more about Clojure development with Spacemacs (Emacs and CIDER).
Part 2: 4Clojure exercises 1 to 15
At 34.50 onwards we discuss solving the first fifteen challenges of 4Clojure, a website that gives you Clojure code snippets to complete. Entering the missing code and the website will run the code and tests, showing if you got the answer correct.
- 4Clojure exercises
- Install a Clojure development environment using these install guides for several Clojure aware editors
Clojure Loves Data: A 40 minute sessions at London Java Community conference
Live coding session covering the basics of using data structures (collections) in Clojure, mostly focusing on Vectors (arrays) and Maps (hash-map, dictionary). I will also attempt to broadcast live a lightning talk on how to broadcast live (because I like being quite meta some times).
Week 4: Clojure maps, ascii code generator and clojure test
Working with Clojure maps (hash-map) and writing a simple ascii code generator.
- Test driven development for the Clacks messages converter. See 61 minutes onwards for ideas how to create the tests.
Week 5: Test Driven Development - Clacks messenger
This week we will look at Test Driven Development and Clojure.
clojure.test library is part of Clojure and is the simplest way to start with TDD and Clojure. We will take a small challenge and solve it by first writing a failing test, then writing some code to make the test pass, then refactor the code if necessary.
We will start by creating a new project on the command line with Leiningen, which creates parallel source and test branches.
lein new my-project
Open the source code file from the project (
SPC f f) and start the REPL -
, ' or
Toggle between source code and test code with
SPC p a. Or open the other in a new window using
SPC p f, highlight the filename and use
C-c o to open in new window.
Run all tests using
, t a or
M-RET t a.
To automate running of tests, toggle cider-auto-test-mode using
, T t and then evaluate either source or test buffer using
, e b and tests will run for that namespace
Source code examples
Week 6: Advent of Clojure
Solving day one of the Advent of Code challenges. The first part of the problem is solved with a simple
reduce function. The second part we investigate several different approaches, becoming more functional and using higher abstractions in Clojure.
If you understand the progression of the solutions, you are a good way on to creating very clean Clojure code at a good level of abstraction.
Advent of Code
jr0cket/advent-of-code-2018 repository contains documented descriptions of the solutions to Advent of Code created so far.
Advent of Code is a yearly coding challenge that sets one challenge per day, just like an advent calendar.
Tim Pote will be live streaming their solution to the advent of code each day at 12 noon (UTC-5 timezone) on Twitch.
Borkdude also has a Github repository where advent of code solutions will be published, with all solutions checked with Clojure spec
Week 7: Simple website with ClojureScript, reagent, bootstrap and SVG
The project also used Bootstrap as a Cascading Style Sheet library, to help structure the layout of the page and add visual components. The reagent library also lets us define graphics using markup, creating Scalable Vector graphics.
The project was created with the Leiningen figwheel template, to give instant feedback in the web page as we update the code.
lein new figwheel simple-website -- --reagent
Week 8: 4Clojure challenges 16 to 22
Solving the 4Clojure challenges from 16 to 32.
4Clojure challenges up to 15
jr0cket/four-clojure repository - discussions of 4Clojure solutions
Week 9: Tic-Tac-Toe
Building a simple command line tic-tac-toe game in Clojure in a very functional style.
No frameworks were harmed (or used) in the making of this broadcast :smile_cat:
Joining the Live discussion
A hangout link will be posted to the MeetAMentor Slack channel and London Clojurians meetup page about 30 minutes before broadcast.
Additional concepts to cover
- Understanding how to model the world with immutable data (values)
- Writing your own (pure) functions
- using sequences
- lisp comprehension
- higher order functions
- functional composition.
Homework: various small challenges and 4Clojure exercises.
Resources for practising Clojure
Finding your own learning path
As there are many ways to study, please feel free to carve out your own learning path and share what you found useful if you wish. Learning Clojure section describes important steps you should take on your journy into Clojure.