# Clojure programming language

- Page: https://shared.btbytes.com/p/clojure
- Date: 2020-04-07
- Tags: jvm, clojure, lisp, programming-language

[Clojure](http://www.clojure.org) is a Lisp that runs on the Java Virtual Machine (JVM).


## Learning resources

- [Maria](https://www.maria.cloud/) a coding environment for beginners.
- [nerdy + lanky | The Practice of Clojure](http://bbrinck.com/post/133112722153/the-practice-of-clojure) Advice for beginners. -- " I highly recommend using a structural editing mode like [Parinfer](https://shaunlebron.github.io/parinfer/). I avoided code insertion / code completion tools in Ruby, but structural editing is a massive productivity boost in Lisps."
- [JUXT Radar](https://juxt.pro/radar.html) for Clojure
- [Getting started with Clojure](http://news.ycombinator.com/item?id=1033503)
- [Clojure Docs](http://clojuredocs.org/) is a community-powered  documentation and examples repository. Very neat looking website. Navigate namespaces and functions to see description and typical usage.
- (another) [Clojure Docs](http://clojure-doc.org/) -- this website is more about tutorials, articles and cookbooks.
- [Guide to programming in Clojure for   beginners](http://blackstag.com/blog.posting?id=5)
- [Aphyr's Clojure from the ground up](http://aphyr.com/posts/301-clojure-from-the-ground-up-first-principles)
- [10 minute emacs for clojure](http://web.archive.org/web/20120430010100/http://www.unexpected-vortices.com/clojure/10-minute-emacs-for-clojure.html) guide.
- [Clojure for the Brave and True, an Online Book for Beginners](http://www.braveclojure.com/) -- very nice tutorial on emacs.
- [Clojure links by Lee Phillips](https://lee-phillips.org/Clojure/)
- [Learning Clojure: coping with dynamic typing](https://blog.frankel.ch/learning-clojure/1/) Sept 2018.
- [Clojure Design Patterns](http://mishadoff.com/blog/clojure-design-patterns/)
- [Clojure Concurrency Tutorial for Beginners with Code Examples](https://purelyfunctional.tv/guide/clojure-concurrency/) by Eric Normand, "In this tutorial, you'll learn 16 ways for doing concurrency in Clojure including how to start threads and how to communicate between them."
- [Lambda Island | Screencast series about ClojureScript and Clojure](https://lambdaisland.com/)

### Clojure as a Lisp

- [Symbolic Programming with Clojure](https://news.ycombinator.com/item?id=34936878)


### Courseware

-  [Poetry of Programming - Puzzle Based Introduction to Functional Programming | popbook](https://egri-nagy.github.io/popbook/). The [Reading exercise](https://egri-nagy.github.io/popbook/PoP_reading_xs.pdf) (PDF) are great.

## Presentations

- [The Simplicity of Clojure](http://bridgethillyer.github.io/simplicity-ws/#/) at OSCON 2014.
- [ClojureTV Youtube Channel](https://www.youtube.com/channel/UCaLlzGqiPE2QRj6sSOawJRg)
- [Philly ETE 2016 #2 – Dmitri Sotnikov – Transforming Enterprise Development with Clojure – Chariot Solutions](https://chariotsolutions.com/screencast/philly-ete-2016-2-dmitri-sotnikov-transforming-enterprise-development-clojure/) a good demo of lumius framework with a "guestbook app" example (both clj and cljs.)
- [The spirit of Clojure](http://media.thi.ng/2018/talks/clojurex/index.html#0) by Karsten Schmidt about [thi-ng](https://github.com/thi-ng/geom)

## Clojure like languages

* [chr15m/flk: A LISP that runs wherever Bash is](https://github.com/chr15m/flk)

## IDE and infrastructure

- [Lightmod](https://sekao.net/lightmod/) -- Lightmod is a tightly integrated tool for making full stack Clojure and ClojureScript web apps. It is fully self-contained -- no need to install the JDK or any build tool. It hot reloads both client and server code automatically with zero setup.
- [Nightlight](https://sekao.net/nightlight/) is an editor you run inside your Clojure projects. Instead of being a separate application like traditional editors and IDEs, it's just a library that you add to your project. It spins up a web server and provides a completely browser-based interface to edit your code.

- [CIDER](https://github.com/clojure-emacs/cider) is the successor to nrepl.
- [Cursive Clojure IDE](http://web.archive.org/web/20131010204349/http://cursiveclojure.com/) -- is an IDE built on IntelliJ
- [Parinfer](https://shaunlebron.github.io/parinfer/)

### REPL

* [Fancy Clojure REPL - asciinema](https://asciinema.org/a/296507)
* [eval/deps-try: Try out Clojure libraries via rebel-readline](https://github.com/eval/deps-try)

### online playgrounds

* [small clojure interpreter playground](https://borkdude.github.io/sci.web/)
* [glisp](https://baku89.com/glisp/) for generative-art. 2020-06-11

### Getting started with Lighttable

[Via](https://news.ycombinator.com/item?id=7043109)

Basic instructions. I use cmd for the shortcuts below, substitute ctrl
on non-mac platforms.

1.  Install Leiningen <http://leiningen.org/> you do not need to install
    clojure, lein will grab clojure for you.
2.  lein new playground from the command line to create a 'playground'
    project
3.  Open Light Table
4.  ctrl-space woto for "Toggle Workspace tree"
5.  Add the playground project folder you just created
6.  cmd-o core.clj to open the main clojure file for the project
7.  On an empty line type (+ 1 1) and hit cmd-enter

Things will grind away for a while as all the dependencies are
downloaded and the JVM starts up. Get a cup of coffee or something.
Eventually you'll see a green 2 show up.

You can then type anything in the tutorial and hit cmd-enter to evaluate
it or cmd-shift-enter to evaluate the entire file. Think of the file as
a shell with an editable history instead of something you'd want to
commit to source control.

Documentation is searchable via ctrl-shift-d or moving your cursor on
top of a function name and hitting ctrl-d. Autocomplete is available on
tab, you can jump to definition with cmd-. and back with cmd-,

TODO: Explore CIDER + AC(autocomplete) + ritz.

## Applications

- [Clojure for Data Science: an Overview](http://clojuredatascience.com/posts/2015-09-05-regression-classification-clustering-clojure.html)

## Libraries

- [Clojure libraries I recommend - quanttype](https://quanttype.net/posts/2018-10-14-clojure-libraries-i-use-and-like.html) Oct 2018.
- [Javelin](https://github.com/tailrecursion/javelin) --  Spreadsheet-like dataflow programming in ClojureScript.
- [Ring](http://github.com/mmcgrana/ring) inspired by Python WSGI. [Primer](http://web.archive.org/web/20100401084523/http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html)
- [Clojure toolbox](http://www.clojure-toolbox.com/) -- categorised directory of libraries and tools for Clojure.
- [boot](http://boot-clj.com/)
- [Quil: animation in Clojure](http://quil.info/)
- https://polylith.gitbook.io/polylith/ is a software architecture that applies functional thinking at the system scale. It helps us to build simple, maintainable, testable, and scalable systems.
- [Defold - Cross platform game engine](https://defold.com/) written in Clojure.

### Spec

* [What Spec is](https://www.pixelated-noise.com/blog/2020/09/10/what-spec-is/); Sep 2020.  [HN](https://news.ycombinator.com/item?id=24432461)

> the biggest win from spec has been with parsing. This completely changes how you'd write a library that takes a data structure and parses it into something meaningful (for example, what hiccup does for html or what honeysql does for sql). In the past, this required a lot of very ugly parsing code and manual error-checking. With spec, you write specs and call s/conform. If it failed, you get a nice error, especially if you pair it with expound. If it succeeded, you get a destructured value that is really easy to pull data out of. I've done this in a half dozen different libraries and i'm pretty sure i wouldn't have even written them without spec.

> Malli[malli] and specmonstah[specmonstah] are my favourite Clojure(Script) libraries built on top of Clojure Spec.

[malli]: https://github.com/metosin/malli

[specmonstah]: https://github.com/reifyhealth/specmonstah

## Clojure books

- [Learn to Program the World's Most Bodacious Language with Clojure for the Brave and True](http://www.braveclojure.com/)
- [Programming Clojure, 3rd Edition](https://www.safaribooksonline.com/library/view/programming-clojure-3rd/9781680505719/) by Aaron Bedra, Stuart Halloway, Alex Miller
- [Practical Clojure](https://www.safaribooksonline.com/library/view/practical-clojure/9781430272311/) by Luke VanderHart, Stuart Sierra
- [Living Clojure](http://www.amazon.com/dp/1491909048/)
- [Clojure from the ground up: welcome](https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome)
- [Clojure in Action, Second Edition](https://www.safaribooksonline.com/library/view/clojure-in-action/9781617291524/) by Amit Rathore et al
- [Clojure Applied](https://www.safaribooksonline.com/library/view/clojure-applied/9781680501476/) by Alex Miller et al
- [Clojure Web Development Essentials](https://www.safaribooksonline.com/library/view/clojure-web-development/9781784392222/) by Ryan Baldwin
- [Mastering Clojure Macros](https://www.safaribooksonline.com/library/view/mastering-clojure-macros/9781941222768/) by Colin Jones
- [Clojure Data Analysis Cookbook - Second Edition](https://www.safaribooksonline.com/library/view/clojure-data-analysis/9781784390297/) by Eric Rochester
- [Clojure High Performance Programming - Second Edition](https://www.safaribooksonline.com/library/view/clojure-high-performance/9781785283642/)
- [Clojure Reactive Programming](https://www.safaribooksonline.com/library/view/clojure-reactive-programming/9781783986668/) by Leonardo Borges
- [Clojure Recipes](https://www.safaribooksonline.com/library/view/clojure-recipes/9780133430097/)

- [The Joy of Clojure](https://www.safaribooksonline.com/library/view/the-joy-of/9781935182641/) by Michael Fogus and Chris Houser
- [Elements of Clojure](https://elementsofclojure.com/) WIP as of Oct 2018.
> The first chapter, **Names**, explains why names define the structure of our software, and how to judge whether a name is any good.

> The second chapter, **Idioms**, provides specific, syntactic advice for writing Clojure which is clean and readable.

> The third chapter, **Indirection**, looks at how code can made simpler and more robust through separation.

> The final chapter, **Composition**, explores how the constituent pieces of our code can be combined into an effective whole.

### Clojurescript books

- [ClojureScript: Up and Running](https://www.safaribooksonline.com/library/view/clojurescript-up-and/9781449327422/) by Luke VanderHart, Stuart Sierra
- [Learning ClojureScript](https://www.safaribooksonline.com/library/view/learning-clojurescript/9781785887635/) by Allen Rohner, Rafik Naccache, W. David Jarvis

## Experience reports and discussions

- [Fourteen Months with Clojure – Skyliner](https://blog.skyliner.io/fourteen-months-with-clojure-beb8b3e4bf00); [HN](https://news.ycombinator.com/item?id=14006242).
- [Readable Clojure @ tonsky.me](http://tonsky.me/blog/readable-clojure/)
- [Effective Programs - 10 years of Clojure](https://www.youtube.com/watch?v=2V1FtfBDsLU) by Rich Hickey

	- "situated programs" (10:30 mark)
	- "effective" (around 17:00)
- [Using Clojure in Production | Demystify FP](https://www.demystifyfp.com/clojure/blog/clojure-in-production/) Sept 2018.

- [A Year in Clojure](https://blog.taylorwood.io/2017/09/15/year-behind.html) -- this article has a nice overview of the many novel features of Clojure. The author is an experienced FP language user (F# etc.,); Oct 2017.

-  [Clojure Design Decisions](https://gist.github.com/btbytes/48c4c8b270b19d3010cbf3bf37528d9f) "Rich Already Answered That! A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (Hickey)".

- [Matthias Nehlsen](https://matthiasnehlsen.com/) has [good](https://matthiasnehlsen.com/blog/2019/02/28/meins-intro/) [blog posts](https://matthiasnehlsen.com/blog/2018/03/15/introducing-meo/) on clojure+clojurescript applications he has created. He is also writing a book - [Building a System in Clojure (and ClojureScript) by Matthias Nehlsen](https://leanpub.com/building-a-system-in-clojure)

## Articles

- [Clojure vs. The Static Typing World - LispCast](https://lispcast.com/clojure-and-types/)
* Articles submitted to [lobste.rs tagged clojure](https://lobste.rs/t/clojure)

## Talks and presentations

- [CLojure at netflix](https://speakerdeck.com/daveray/clojure-at-netflix) -- good projects to start -- "Diagnostic services".

## Tips and tricks

- [The Clojure Style Guide](https://guide.clojure.style/)
- [Readable Clojure @ tonsky.me](http://tonsky.me/blog/readable-clojure/#dont-use-use)
- [Should I use boot or tools.deps to build command line applications? ClojureVerse](https://clojureverse.org/t/should-i-use-boot-or-tools-deps-to-build-command-line-applications/3420/19) [..and this](https://i.imgur.com/O6HLihV.png) [..via](https://x.com/ericnormand/status/1101153515584536576). Seee also [frobnicate](https://gist.github.com/gfredericks/900183dae706aae6361110b2383c8639)

## Cool projects / Read Code

- [thi.ng - computational design tools for Clojure & Clojurescript](http://thi.ng/)
- [thegeez/clj-board: A drag & drop "kanban board" example with Clojure](https://github.com/thegeez/clj-board)
- [nasa/Common-Metadata-Repository](https://github.com/nasa/Common-Metadata-Repository)
- [BirdWatch](http://birdwatch.matthiasnehlsen.com/#*)
- [Inspect Example](http://inspect.matthiasnehlsen.com/)
- [matthiasn/meins: a personal and smart journal](https://github.com/matthiasn/meins)
- [Systems-Toolbox: Trailing Mouse Pointer Example](http://systems-toolbox.matthiasnehlsen.com/)

## Visualization / Notebook

- [Gorilla REPL · Gorilla REPL](http://gorilla-repl.org/index.html)
- [metasoarous/oz: Data visualizations in Clojure and ClojureScript using Vega and Vega-lite](https://github.com/metasoarous/oz)


## Web development

- [RESTful CRUD APIs Using Compojure-API and Toucan (Part-1) | Demystify FP](https://www.demystifyfp.com/clojure/blog/restful-crud-apis-using-compojure-api-and-toucan-part-1/)


## Big data

* <https://redd.it/ipij41>

## Blogs

- [Old Clojure notes | Locklin on science](http://web.archive.org/web/20140909035025/http://scottlocklin.wordpress.com/old-clojure-notes/)
- [Taylor ≈ Programmer](https://blog.taylorwood.io/)
* [Daniel Janus](http://danieljanus.pl/)
* [Understanding Clojure's Persistent Vectors, pt. 1](https://hypirion.com/musings/understanding-persistent-vector-pt-1)
* [John Jacobsen on Clojure](http://johnj.com/tags/clojure/)


## ClojureScript

- [dundalek/clojurescript-guide: My notes on ClojureScript](https://github.com/dundalek/clojurescript-guide)
- [magomimmo/modern-cljs: A series of tutorials on ClojureScript](https://github.com/magomimmo/modern-cljs) is one of the clearest tutorials I've read.
- [ClojureScript](https://clojurescript.org/index) -- Homepage
- [Austin](https://github.com/cemerick/austin) -- browser REPL.
- [om-cookbook](https://github.com/omcljs/om-cookbook)
- [ClojureScript Unraveled](https://funcool.github.io/clojurescript-unraveled/) a book.
- [Plank -- ClojureScript REPL for Mac](http://planck-repl.org/guide-all.html)
- [Transforming Data with ClojureScript](http://langintro.com/cljsbook/)


## Graal

- [Native Clojure with GraalVM](https://www.innoq.com/en/blog/native-clojure-and-graalvm/)
- [Native Clojure with GraalVM](https://www.youtube.com/watch?v=topKYJgv6qA) talk.
* This [nextjournal notebook](https://nextjournal.com/a/M4woRraF1pz1zjvjgBY9T?token=Td2LLVyNFmR6rXMEJ7bKZ6) has a recipe for building [Babashka](https://github.com/borkdude/babashka) "executing Clojure snippets or scripts in the same space where you would use Bash."


## Web development

### PCP


[alekcz/pcp: PCP: Clojure Processor -- Like drugs but better](https://github.com/alekcz/pcp)

Just use it like PHP on a webserver (say [nginx](https://shared.btbytes.com/p/nginx)):

        #new pcp config => change .php to .clj
        index index.clj index.html index.htm;
        #new pcp config => change .php to .clj
        location ~ \.clj$ {
            #default nginx config on digital ocean lemp image
            #include snippets/fastcgi-php.conf;
            #fastcgi_pass unix:/run/php/php7.0-fpm.sock;

            include scgi_params;
            scgi_intercept_errors on;
            scgi_pass   127.0.0.1:9000;
        }

PCP has following libraries built in:

    (require  '[cheshire.core :as json]
          '[clostache.parser :as clo]
          '[selmer.parser :as parser]
          '[selmer.filters :as filters]
          '[clj-http.lite.client :as client]
          '[next.jdbc :as jdbc]
          '[honeysql.core :as sql]
          '[honeysql.helpers :as helpers]
          '[postal.core :as email]
          '[clojurewerkz.scrypt.core :as sc])




## Learning Journal

* [this](https://gist.github.com/athos/b68b15b08efedffaf14d8c020b125202) is a good demo of how to use Clojure's `-Sdeps` at the command line to execute a script (even one hosted remotely on git):

```
clojure -Sdeps '{:deps
    {hello-clojure
        {:git/url "https://gist.github.com/athos/b68b15b08efedffaf14d8c020b125202"
        :sha "1c9a05106171f97f9b8e8ac8f58c7bd8dbe021f9"}}}'
    -m hello-clojure
```


----

See also: [lisp](https://shared.btbytes.com/p/lisp), [scheme](https://www.btbytes.com/scheme.html).
