Clojure

ClojureInstallationHello WorldGUI Hello WorldGUI hello world fxmlShadow CLJS (Browser target) Hello WorldFulcro hello worldQuick start

Installation

https://clojure.org/guides/getting_started

Hello World

Create a new file as ~/code/hello-world/core.clj

Inside that file create the following:

Then create a new file ~/code/hello-world/deps.edn

With:

Then return your current directory to ~/code/hello-world then run

You should get the following as your result:

 

Hello world in Cursive

 

GUI Hello World

Create ~/code/$project-name/deps.edn and add the following to it:

Go back to ~/code/$project-name/src/$project-name/core.clj and change it to:

Then return your current directory to ~/code/$project-name then run

After a short wait you should see a window open with the contents "Hello world!" inside

Hello world

Associated documentation: Frame documentation

 

GUI hello world fxml

Open the hello-world-fxml project

 

Shadow CLJS (Browser target) Hello World

Create a new project name, this will be a ClojureScript project as $project-name

Inside ~/code run npx create-cljs-project $project-name

Create a new file at ~/code/$project-name/src/main/$project_name/core.cljs add the following:

Open ~/code/$project-name/shadow-cljs.edn add this to the :builds keyword

Create ~/code/$project-name/public/index.html with

Run npx shadow-cljs watch frontend in ~/code/$project-name to expose a development web server, if you still have the watch command running from ealier you should now be able to visit localhost:8080 to see:

Hello world

Associated documentation: ShadowCLJS Github

Fulcro hello world

Quick start

git clone https://github.com/fulcrologic/fulcro-template.git

Then run npm install in the newly created fulcro-template sub directory

To start a build run npm run client/main or visit http://localhost:9630 & run the build

To start the server run clojure -A:dev

Navigate to http://localhost:3000