paint-brush
Getting Started with Clojure on Mac OSby@swlkr
2,071 reads
2,071 reads

Getting Started with Clojure on Mac OS

by Sean WalkerSeptember 14th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<em>Hey, psssst, I made an updated version </em><a href="https://medium.com/@swlkr/getting-started-with-clojure-1-9-on-macos-701d367fa777" target="_blank"><em>of this post here</em></a>

Company Mentioned

Mention Thumbnail
featured image - Getting Started with Clojure on Mac OS
Sean Walker HackerNoon profile picture

Hey, psssst, I made an updated version of this post here

There are a few things you need to run clojure on your Mac, the first thing is called leiningen and it works like npm for nodejs or bundler for ruby, or the dotnet cli for c#, it’s a project runner and a dependency manager (sort of).

Here’s how you install it:

brew install leiningen

That’s it! That was painless. Unless it wasn’t in which case you don’t have homebrew installed, and you should do this first:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

There we go, run that first thing again, now it was painless. Next step, start a new clojure project:

lein new my-project

Hey, this lein thing is pretty simple and pretty easy. Next step is to actually run the project. Open up your favorite text editor, scratch that, go ahead and install intellij community edition. I’ll wait. Now that it’s installed, install the cursive plugin. Now you’re ready to edit some clojure with zero configuration!


cd my-projectidea .

Open up src/my_project/core.clj and add a new function


(defn hello [name](str "hello " name))

Now click the project name in the tree view on the left and press ctrl + shift + R. A REPL should show up on the right. Move the cursor to the function you just made, type cmd + shift + P (or ctrl + shift + T, depending on your keymap). The function will be sent to the repl. Now below your function type

(hello "world")

And hit cmd + shift + P (or ctrl + shift + T) again.

Sending “forms” to the REPL (the stuff in parens) from your editor is a great thing, you don’t have to type out things directly in the REPL, where I think a lot of people think that’s what a REPL is. You can build up a lot of state in the REPL without closing it for weeks and without directly typing in it at all. I also made another small screencast showing going from lein in the terminal to cursive and sending forms to the REPL. It’s pretty raw, and it’s only a minute, but hopefully it will convince you to give clojure a shot!