Hello! I’m trying to get started with ClojureCLR with a simple "Hello World" program, but am having trouble finding resources to get a ClojureCLR project up and running. Can anyone point me to a resource or example project for this? Compile/run commands would be helpful as well.
I think I found a working solution, using https://github.com/anderseknert/ring-clr as an example (thank you).
Still, a couple significant differences between Clojure JVM:
• No deps.edn – Looks like this is what https://github.com/clojure/clr.core.cli aims to solve?
• The cljr file extension isn’t recognized by Clojure.Main – still trying to figure out how this was achieved in ring-clr.
There's a cljr command-line tool that supports deps-cljr.edn and deps.edn (EDN has no reader conditionals so if you need different deps, you have to have different files).
Unfortunately, I don't remember how/where I installed cljr and can't find docs for it in the repos.
Ah, I scrolled back to May here and found the command to install it:
dotnet tool install --global Clojure.Cljr --version 0.1.0-alpha2PS C:\Users\seanc\clojure\clojure-clr-starter> cat .\deps.edn
{:paths ["src"]
:aliases {:dev {:extra-paths ["dev"]
:extra-deps {org.clojure.clr/tools.nrepl {:mvn/version "0.1.0-alpha1"}}}}}
PS C:\Users\seanc\clojure\clojure-clr-starter> cat .\src\starter\hello.cljr
(ns starter.hello
(:require [starter.utils :as utils]))
(defn hello-world []
(println "Hello, World!"))
(defn -main [& args]
(hello-world)
(println (utils/square 5)))
PS C:\Users\seanc\clojure\clojure-clr-starter> cljr -M -m starter.hello
Starting main
Hello, World!
25
PS C:\Users\seanc\clojure\clojure-clr-starter>So there's basic nREPL support as well.
Still early days with the command-line stuff.
and
PS C:\Users\seanc\clojure\clojure-clr-starter> cat .\src\starter\utils.cljr
(ns starter.utils)
(defn square [x]
(* x x))
Just to show multiple nses.And here are my versions (of Clojure.Main and cljr):
PS C:\Users\seanc\clojure\clojure-clr-starter> cljr
Starting main
Clojure 1.12.0-alpha9
user=> ^Z
PS C:\Users\seanc\clojure\clojure-clr-starter> cljr -version
ClojureCLR CLI Version: 0.1.0.0This is awesome–feels way more like the traditional clojure process. Thank you!
A slight correction on the .edn conditionalization file: the file cljr looks for first is deps-clr.edn:
However, we cannot just read-conditionalization the deps.edn file because read-conditionalization is not supported in EDN files. The workaround is that cljr will look for a file named deps-clr.edn first, then look for deps.edn. This provides an override that cljr can see and the JVM tools will ignore.
As you work with it, observations/comments/suggestions are welcome.
(I'm especially interested in the items mentioned under [Things that need work](https://github.com/clojure/clr.core.cli?tab=readme-ov-file#things-that-need-work).