Fork me on GitHub

Not a huge fan - but I did watch the match, it was entertaining.


mogge 😼


I had a really weird dream last night... a non-java programmer friend was somehow convinced they needed to install Kafka and run it.... and they weren't looking forward to that. And in my dream I tried to convince them to use an Isomorphic programming language. I am not even sure that actually makes any sense :thinking_face:


The only surprising thing about that dream is that you managed to convince them! I’ve never managed to convince anyone to use something like Clojure!


I am not sure I managed to convince them....


in your dreams

😂 8

and remember... it was a dream after all 😉




Noob clojure question


(defn list*
  "Creates a new seq containing the items prepended to the rest, the
  last of which will be treated as a sequence."
  {:added "1.0"
   :static true}
  ([args] (seq args))
  ([a args] (cons a args))
  ([a b args] (cons a (cons b args)))
  ([a b c args] (cons a (cons b (cons c args))))
  ([a b c d & more]
     (cons a (cons b (cons c (cons d (spread more)))))))
What does :static true do?


I guess it’s a java interop thing?


good morning all

👋 4

I think it means that the generated Java method is a static method


Thats what i was thinking


alright cheers!


but I am sure someone else can give you a much better explanation.

👍 4

it’s useless


it’s a no-op since clojure 1.2


it used to be an experimental flag for manual direct linking


Whats direct linking?


clojure infers automatically now if a function can be direct linked or not


alright thanks!


see... I was at least correct on one thing... (that someone else can give a better explanation 😉 )

😂 4
Rachel Westmacott09:06:33

knowing the limits of one’s own knowledge is possibly the most important thing you can know


Morning All... Sorry to ask the same question again, but I could really do with finding out the answer... Does anyone remember how much Conj tickets were in 2017, Early Bird and / or Standard Price..? I am trying to firm up support for me to attend this year, now that the dates are known...


(I've looked on the Conj 2017 site, but no joy)


@maleghast i’ve done a bit of googling i cant find a price anywhere, best to alex miller i reckon


Thanks @guy - I Googled about a fair bit as well, I was hoping to happen on someone who remembered what they paid 🙂


You mean Alex Miller at Cognitect?


Okie dokie - I will have to just @ him on Twitter or something; I don't know__ him...


nah hes in slack lol


I’ve moved ur question to #clojure-conj hopefully that was what you were looking for 👀 @maleghast


Oh thx

👍 4

@maleghast 500$ for a late registration (sept for oct)


Morning everyone

👋 8

@reborg - Thanks for that, very helpful 🙂

👍 4

Hello 👋 , wondering if anyone can help? I have a question about how to run a script written in clojure on my server. I have a webapp that I’ve packaged into an uberjar using lein. This is deployed on my server and is happily running with java -jar xxx-standalone.jar. I have now written a script that I want to run on the server too. How would I go about getting this script included in the uberjar, and how do I run the script on the server?


include it in the project and rebuild the uberjar?


@cfeckardt yeah, sorry this is a really newbie question. I think I’ve included it in the uberjar, but what java command do I run on the server to run the script. Eg. I run java -jar xxx-standalone.jar to run the webapp, what do I run to call the script that is contained within the uberjar?

Rachel Westmacott13:06:17

are you trying to start a new JVM process on your server, or do you want your currently running server to execute some code?

Rachel Westmacott13:06:49

if you want a new Java process then this might be helpful:

Rachel Westmacott13:06:10

if you want it in the same process then you probably want to be running an HTTP server and respond to some HTTP request?


I don’t want to run it in the same process - not trying to expose it via HTTP or anything. It’s just a one off script that I want to run on the server. I took a look at this:, but the script uses dependencies. The dependencies are all included in the uberjar (as is the script). Is there a way of calling the uberjar and telling it to run the script contained within in, eg. java -jar xxx-standalone.jar -run-this-script


The link says to run the script with java -cp clojure.jar clojure.main /path/to/myscript.clj arg1 arg2 arg3 but I don’t have the clojure.jar on the server, or the myscript.clj. All I have is the uberjar (which should hopefully contain the myscript.clj)


@jamescroft sounds like it would be simpler to make two different uberjars, one for the webapp and one for your script.


@thomas ok thanks. Still finding my feet with this stuff. I’d considered that option but it seemed like overkill and I wondered if there was a better way. Thanks


one advantage would be that you could update either independently


would java -cp xxx-standalone.jar clojure.main /path/to/myscript.clj do it? i'm fuzzy on how uberjars work


so myscript.clj is not a compiled java class file


if you include the class inside the uberjar


then you can invoke it using the java command


the synopsis and description of man java explains it quite well i think


if you are unsure if your class is inside the jarfile you can run jar -tvf jarfile


(and if it's not in there it could be that you are missing (:gen-class) in your (ns at the top of your script


ok, thanks for the pointers


no worries

Rachel Westmacott15:06:34

I would have thought you wouldn’t need to compile the script to java class files if you’re running it via the clojure.main entry point.


oh shoot you're right

Rachel Westmacott15:06:53

There are certainly more options in this area now due to the ‘tools.deps’ work that is ongoing.

Rachel Westmacott15:06:07

options for eg. standalone scripts with dependencies


If you use pack, you don't need to :gen-class for your main 🙂 feature


I don’t know about uberjars, but I assume they are like normal jars - “java -jar foo.jar” loads foo into the classpath, then uses a default Main class (from distant memory) that is in the foo.jar metadata.


So you should be able to somehow specify a different entry point - you’d need to :gen-class to make it exposed as a class. Hmm.


if I unzip an uberjar I can see the file META-INF/MANIFEST.MF containing:

Manifest-Version: 1.0
Built-By: korny
Created-By: Leiningen 2.5.3
Build-Jdk: 1.8.0_162
Main-Class: cloc2flare.cli


and in the jar there’s a cloc2flare/cli.class file.


So I strongly suspect if you make a new namespace with a :gen-class in the ns header, and a -main method, you can then run it from the uberjar just fine. Something like:

(ns mypackage.cli
(defn -main [& args]
  (puts "Hello world!"))


then java -cp MyUberjar.jar mypackage.cli should load clojure (as it’s in the uberjar) and run your -main


You can do it without :gen-class and AOT: run the clojure.main class and then specify the namespace whose -main you want to run: java -cp foo.jar clojure.main -m my.namespace


(we actually run all our code that way and we don't AOT anything and we don't use :gen-class)


We commonly have multiple namespaces containing -main functions in a single JAR.


AOT and :gen-class are the slippery slope to madness 🙂

👍 8

Please tell us more about this..


@U7ANZ2MTK So many problems... unfortunately, since the default Leiningen templates include AOT and :gen-class, and that's perpetuated in most of the tutorials and books, it tends to be the way most beginners get started -- and then continue with until they start tripping over problems. Stale class files, incompatible versions of a class being loaded, transitive compilation (so the whole world ends up getting compiled), weird breakages in REPL-based workflows, incompatibilities with the maven-shade-plugin, conflict between "source" and "binary" artifacts (e.g., Cursive issue 234), confusion over differences between e.g., lein run behavior and running the result of lein uberjar when not all of the fiddly bits line up, etc.


AOT is sort of OK as a way to minimize start up time if you really need to do that for a complete application just at the very last step when building an uberjar for deployment.


that's really helpful


:gen-class is sort of OK if you absolutely must generate a Java-compatible .class file for Java-calling-Clojure scenarios where you want the Clojure namespace to look exactly like a Java class (e.g., providing a library that can be used directly from a Java application -- and you don't want the Java code to have to use the Clojure Java API).


Personally, I think the Clojure Java API is far and away the more powerful way to integrate Clojure into a Java application as it opens up the whole of Clojure, dynamically. That's how we use it at work, from our legacy apps.


BTW, that also means you can start a REPL with all your code/dependencies available using an uberjar: java -cp foo.jar clojure.main -- with no -m argument will start a REPL.


Is that java -jar foo.jar or java -cp foo.jar ?


Very handy to run a REPL against an uberjar!


Oh, sorry, yes, -cp.