├── .gitignore
├── .gitpod.dockerfile
├── .gitpod.yml
├── .vscode
└── settings.json
├── README.md
├── deps.edn
└── src
└── mini
└── hello.clj
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /classes
3 | /checkouts
4 | pom.xml
5 | pom.xml.asc
6 | *.jar
7 | *.class
8 | /.cpcache
9 | /.lein-*
10 | /.nrepl-history
11 | /.nrepl-port
12 | words-alpha.txt
13 | .clj-kondo/.cache/
14 | .lsp/.cache/
15 | .lsp/sqlite*.db
16 | .calva/output-window/
17 | .DS_Store
18 | .portal/
--------------------------------------------------------------------------------
/.gitpod.dockerfile:
--------------------------------------------------------------------------------
1 | FROM gitpod/workspace-full
2 |
3 | RUN brew install clojure/tools/clojure
4 |
5 | # rebuilding dockerfile by updating this comment #1
6 |
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | image:
2 | file: .gitpod.dockerfile
3 |
4 | vscode:
5 | extensions:
6 | - betterthantomorrow.calva
7 |
8 | tasks:
9 | - name: Prepare deps
10 | init: clojure -P -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}'
11 | #- name: Open README
12 | # command: open -g README.md
13 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "gitpod.enableReleaseNotes": false,
3 | "editor.lightbulb.enabled": false,
4 | "editor.hover.delay": 1300,
5 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Clojure Get Started Mini(mal) Project
2 |
3 | This is a mini(mal) [Clojure](https://clojure.org) project that you can start hacking from. The instructions are for using [Calva](https:/calva.io), a Clojure IDE for Visual Studio Code. You can use it both in VS Code on your machine or directly in the browser, with full editor tooling.
4 |
5 | NB: This is not a meant as *Your First Clojure App* project. It is meant as an easy way to take Clojure for a spin in the development environment it is designed to be used: *the Editor*.
6 |
7 | Use this project to learn just enough about how a Clojure program is developed, and to check if Clojure might be for you. Then head to the [Where to go Next?](#where-to-go-next) section below for pointers on how you might continue your Clojure journey.
8 |
9 | ## Usage
10 |
11 | Depending wether you will use this in the web browser or on your computer the initial steps differ:
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | In the browser |
21 | On your machine |
22 |
23 |
24 |
25 |
26 |
27 |
28 | When used in the browser all you need is a Github account, that's all.
29 |
30 | [](https://gitpod.io/#https://github.com/PEZ/minimal-clojure)
31 |
32 | You will be prompted to log in, choose to use Github login.
33 |
34 | This will open the repository in a Gitpod workspace in the browser. (Might take a while.) You'll find VS Code and Calva running there, ready to let you edit the files in the project.
35 | |
36 |
37 | When used on your own machine you will need:
38 |
39 | 1. Have Java installed (procedure will vary with platform and your preferences)
40 | 1. Have [Visual Studio Code](https://code.visualstudio.com/) installed
41 | 1. Install Calva from VS Code's Extension pane.
42 | 1. A copy of this repository
43 | 1. Fork it or make a hard copy
44 | 1. Clone your copy to your computer
45 | 1. Open the project folder in VS Code
46 | |
47 |
48 |
49 |
50 |
51 | ### Start the minimal program
52 |
53 | With Clojure you hack on the running program that you are developing. We call this **Interactive Programming** (some refer to it as REPL Driven Development, but it is rather a Developer Driven REPL). You start a programming session by starting the program, and it's REPL, then connect your editor to it. With Calva this can be done with a command we refer to as **Jack-in**
54 |
55 | 1. From the VS Code command palette, use the command **Start a REPL in your Project and Connect (aka Jack-in)**.
56 | * Choose the `deps.edn` project type.
57 | * This will start a minimal Clojure program and connect Calva to it.
58 | * In fact it will be so minimal that it is _only the Clojure REPL_. To build a larger program ...
59 | 1. Open the file [src/mini/hello.clj](src/mini/hello.clj) and load it in the REPL
60 | * (There are instructions in this file for how to do this.)
61 | * This will define the function `hello` in the `mini.hello` namespace. Your app now has function! You added it without restating the program.
62 |
63 | From here you can modify the program further, while it is running, to something more interesting than it is currently with its only function. A very small step from Hello World, there is Fizz Buzz. Please see this video for an example of how to use the REPL for Interactive Programming:
64 |
65 | * [Clojure Workflow in VS Code, coding FizzBuzz](https://www.youtube.com/watch?v=d0K1oaFGvuQ)
66 |
67 | ## New to Clojure?
68 |
69 | There is not much guidance in this repository for Clojure beginners. You might want to check out Calva's *Getting Started REPL* first:
70 |
71 | 1. Open a new VS Code Window
72 | 2. Issue the command: **Calva: Fire up the Getting Started REPL***
73 |
74 | This will guide you to interactively pick up some basic Calva and Clojure knowledge by using the REPL.
75 |
76 | You can read a bit about this guide here: https://calva.io/get-started-with-clojure/
77 |
78 |
79 | ## Where to go next?
80 |
81 | This will depend on what your goal is. If you want to:
82 |
83 | | If you want to... | Check out |
84 | | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
85 | | Get help and ask questions in the **friendliest programming community** on the planet Earth | [The Clojurians Slack](http://clojurians.net) |
86 | | Be **inspired** by cool videos about Clojure | [On The Code Again Youtube channel](https://www.youtube.com/@onthecodeagain) |
87 | | Learn Clojure in an **entertaining** way | [Clojure for the Brave and True](https://www.braveclojure.com/) |
88 | | Start a **new app** or library, from scratch or from templates | [deps-new](https://github.com/seancorfield/deps-new) |
89 | | Beginner friendly **app creation**, that stays with your project as it grows | [neil](https://blog.michielborkent.nl/new-clojure-project-quickstart.html) (uses **deps-new**) |
90 | | Start a new full stack app with **batteries and opinions included** | [Kit Framework](https://kit-clj.github.io/) |
91 | | Try a **lean and flexible**, full stack framework, aimed at tiny teams (solo devs even) | [Biff](https://biffweb.com/) |
92 | | Get introduced to a **beginner friendly** full stack development | [Donut](https://www.youtube.com/watch?v=PMat9Wdt-pk) |
93 | | Spin up a small, yet complete **RESTful API app template** | [startrek](https://github.com/dharrigan/startrek) (uses **Donut**) |
94 | | Create a **Single Page Application** | [Kit Framework](https://kit-clj.github.io/) (again) |
95 | | Give your Clojure app a scalable **architecture** | [Polylith](https://polylith.gitbook.io/polylith/) |
96 | | Build a **mobile** (and desktop) app from a template | [React Native using shadow-cljs in 3 minutes](https://github.com/PEZ/rn-rf-shadow) |
97 | | Get your **mind blown** and start building _fully reactive_ full stack apps. _You do not mind cutting yourself on the bleeding edge_ | [Electric Clojure](https://hyperfiddle.notion.site/Electric-Clojure-progress-Dec-2022-5416dda526e24e5ab7ccb7eb48c797ed) |
98 |
99 | ## Create your own copy of this repository
100 |
101 | **If you are using this project from the browser**: In order to be able to version control your edits, you will need to create your own copy of the repository. It's a template project so you can use the green **Use this Template** button above for this.
102 |
103 | * **Note**: The URL to use the project in Gitpod changes. What you'll need to do is to prepend the URL of your Github repository copy with `https://gitpod.io/#`. (If you look at the link for the **Open in Gitpod** button above, you'll see that this is how it is constructed.)
104 | * **Note**: The first time you open your copy in Gitpod, it can take quite a while.
105 |
106 | ## License
107 |
108 | The code in this project is open and free to use as you wish. 🗽🍺 (There's not much code here, anyway. 😄)
109 |
110 |
--------------------------------------------------------------------------------
/deps.edn:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/src/mini/hello.clj:
--------------------------------------------------------------------------------
1 | (ns mini.hello)
2 |
3 | ;; Start by loading this file in the REPL: Ctrl+Alt+C, ENTER
4 | ;; (Alt is labeled `option` or `opt` on many Macs)
5 |
6 | (println "When loading the file, this is printed in the Output/REPL Window")
7 | ;; You can print it again, by evaluating the expression (aka form)
8 | ;; Place the cursor in the expression and press: Alt+ENTER
9 | ;; This is referred to as ”Evaluating a top-level form”
10 |
11 | ;; This function will also be defined
12 | (defn hello [s]
13 | (str "Hello! " s))
14 |
15 | ;; Call it, and print the result by evaluating this
16 | ;; top-level form (Alt+ENTER, remember?)
17 | (println (hello "When loading the file, this will be printed"))
18 |
19 | ;; You can redefine the `hello` function by editing it,
20 | ;; and with the cursor still inside it, evaluate top-level form.
21 | ;; Then call the function again to see the new result.
22 |
23 |
24 | ;; This is a so called Rich Comment, nothing in it will be evaluated
25 | ;; when you load the file
26 | (comment
27 | (println (hello "This will NOT be be printed when you load the file"))
28 | ;; You can print it by evaluating it as a top-level form
29 |
30 | ;; This call (evaluate top-level form) will give an error
31 | (println (hello2 "The function hello2 is not defined by the file load"))
32 |
33 | ;; Evaluate this top-level form, and then try the above call again
34 | (defn hello2 [s]
35 | (str "Hello again! " s))
36 |
37 | ;; There is also a command for evaluating the Current Form: Ctrl+ENTER
38 | ;; Try it at some different places in the below expression
39 | (println
40 | (str 0 1 "foo"
41 | :bar [1 2 3]
42 | (inc 41)))
43 | )
44 |
45 | ;; Now you know the most important things about Calva, enough to follow
46 | ;; along what is happening in this video: https://www.youtube.com/watch?v=d0K1oaFGvuQ
47 | ;; (Clojure Workflow with Calva coding FizzBuzz)
48 |
49 | ;; To learn more about Calva, and some basics about Clojure, use the command:
50 | ;; **Calva: Fire up the Getting Started REPL**
51 | ;; Please visit https://calva.io for Calva documentation
52 |
53 | (println (hello "This will also be be printed when you load the file"))
54 |
55 | "When loading the file in the REPL, this string will be the result"
56 |
--------------------------------------------------------------------------------