A suggested study guide for those new to functional programming with Clojure.
MeetAMentor Community is hosting a Clojure Study group starting 3rd November, using this study guide. Sign up via the MaM Study Group form.
All broadcasts are available via the jr0cket YouTube channel
Briefly discuss what the Clojure programming languages is good for, some example companies using Clojure and give suggestions on how to start learning Clojure.
Cover the syntax and a few common functions,
- 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)
Discuss REPL Driven Development (my blog post on the topic)
Review the ClojureBridge London exercises homework - Github Gist - Repl.it project
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).
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.
Solving the first 15 challenges - 34.50 onwards
- 4Clojure exercises
- Install a Clojure development environment using these install guides for several Clojure aware editors
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).
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.
This week we will look at Test Driven Development and Clojure.
The 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 M-RET
.
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
- Try some of the Advent of Code challenges
- Solve 4Clojure challenges from #16 onwards
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.
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
Creating a very simple front end website with ClojureScript. ClojureScript is Clojure that runs on JavaScript engines, such at the one in your browser or node.js. The project included reagent, a react.js style framework for ClojureScript. The web page is made up of one or more components that are managed by the reagent library, so if there are updates to the components the reagent library will refresh the web page.
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
Solving the 4Clojure challenges from 16 to 32.
We solve the first 15 challenges in study group #3 from 34.50 onwards
jr0cket/four-clojure repository - discussions of 4Clojure solutions
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 😸
A hangout link will be posted to the MeetAMentor Slack channel and London Clojurians meetup page about 30 minutes before broadcast.
- 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.
Demonstrate how to use the REPL in Spacemacs and Atom.io with ProtoREPL. Demonstrating evaluation of code, structural editing, refactoring, etc.
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.