kconner / mess-with-clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mess with Clojure

Assumes macOS Monterey.

With Clojure's basic tools

Install OpenJDK and wire it up to the system Java context.

brew install openjdk
export JAVA_HOME=/opt/homebrew/opt/openjdk

Install Clojure.

brew install clojure/tools/clojure

Start a REPL.

clj
user=> "Hello, world"
^D

Note that Clojure has stored data in ~/.m2, ~/.clojure, and ~/.clojure_history.

ls -alt ~

With Leiningen

Install Leiningen.

brew install leiningen

Start a REPL. Compared to clj, this REPL has tab completion that helps exploration.

lein repl
user=> "Hello, world"
^D

Scaffold a project using the default template, which makes a library.

lein new somelib
cd somelib
cat src/somelib/core.clj

On a real project you'd probably git init from there.

Start a repl within the project.

lein repl
somelib.core=> (foo "ok")
^D

Run tests.

lein test

Scaffold an app project too.

cd ..
lein new app someapp

Build and run.

cd someapp
lein run

Note that Leiningen has stored data in ~/.lein and ~/.m2.

ls -alt ~

About


Languages

Language:Clojure 100.0%