Fork me on GitHub

why to build tools exist, boot and lein?


this is weird for the eco.


Leiningen was created first, and served the purposes of many many developers. Some developers decided they wanted something significantly different. I haven't used boot myself, but my impression is that the build "scripts" you create with it are just Clojure code, leveraging useful libraries provided by boot. Many developers decided they liked that style of tool better, and used it instead of Leiningen.


The development of boot did not cause everyone to switch to it from Leiningen, and some fraction of people use neither Leiningen nor boot.


I, on the other hand, think it's rather impressive that there are only 2 😁

😁 4

there are more 🙂


some fraction of people use leiningen, boot and clj 🙂


The "What tools do you use" question on the 2019 State of Clojure survey shows what the responders use: (Question 17)


(xml/parse-str "<book><!-- i can see you--></book>") produces #xml/element{:tag :book} but i want to keep the comment. what should i do?

Alex Miller (Clojure team)11:06:33

You can tell it which infoset types to keep while parsing. There’s a default set, but you can override it.


@alexmiller you are super helpful, thank you very much


I’m trying to call this (GLFW/glfwCreateWindow (int 300) (int 300) title nil nil) but I get a reflection warning call to static method glfwCreateWindow on org.lwjgl.glfw.GLFW can't be resolved (argument types: int, int, java.lang.CharSequence, unknown, unknown)


the last 2 arguments really have to be nil


what is the signature(s) of that method @stathissideris? (include all if there are different types for the same arity)


public static long glfwCreateWindow​(int width,
                                    int height,
                                    java.nio.ByteBuffer title,
                                    long monitor,
                                    long share)

public static long glfwCreateWindow​(int width,
                                    int height,
                                    java.lang.CharSequence title,
                                    long monitor,
                                    long share)


so you can't pass a nil into a long arg -- the Java wouldn't compile


send in 0, 0


which is the default value for a long


ooooooh I just realized that the java example I’m translating uses NULL instead of null, probably a static member of some class. Thanks, let me investigate


maybe it's the constant 0


it seems to be that 🙂


is Clojure pre-installed on MAC OS ?

Alex Miller (Clojure team)17:06:47

but if you have brew, it's just a "brew install clojure" away


Yup. That's my plan

Dave Goodchild17:06:55

They took away telnet they wouldn’t want something as awesome as Clojure in there it might give people ideas


I am just getting into Clojure, setting up my dev env ...


i just started with clojure too, found this to be really helpful


Dog, how do you feel today. I know it's been a bad day


sorry i dont believe i know you, anything that made your day bad?


oh okay 🙂


Guess you didn't hear the news


did we declare war against iran or something


whats the bad news


i looked up google news, nothing extremely bad, just the regular varity of depressing lol


Is there a good tutorial or article or whatever about functional patterns of interop with java?


i guess the heavily depends on what you want to do in java


I can think of a few from StuartSierra that apply don't wrap side effects in laziness and the one about "it isn't mutation if the consequences don't escape scope"


maybe that was someone else's


@markx my tl;dr version is don't build "pure" facades over impure things unless the scope of the thing ends with the return of your function


but there are plenty of things in java (that one would use via interop) that are immutable / functional


Thanks I’ll read it later. My problem is that I found everything I want to do requires some java interop, which is very sad. (I wish Clojure didn’t encourage java interop) Recently I’ve been using Jline and I can’t find a comfortable pattern to integrate it to my clojure code. I basically create an object from the class and store it into an atom, and then all functions refer to that atom. I feel if I have to do it this way why don’t I just write java.


why an atom?


if you mutate the object, the atom isn't safe


what else then? A var?


swap! etc. guarantee to retry on conflict, you can't retry operations on a stateful mutable thing


you could use an agent (operations are guaranteed not to overlap, no retries)


well I don’t use swap! to call methods of that object. I just use atom to keep a reference.


you could only use the object in one thread, and not create a global handle to it


What if, say I have a tcp connection, and I need to write to it in different threads?


then you need some sort of locking scheme to prevent interleaved partial writes


or make a worker thread with the sole job of writing, and a queue that pulls requests from other threads


it's still not safe to simply put the connection in a global without other infrastructure


stateful objects shouldn't be global, and if they are global, they need some other infrastructure in order to be used correctly


Ah I see your point. Thanks!


and I was overgeneralizing - there's such thing as thread safe mutable objects - it's just not the norm (and you usually need to fill in some details about what to do in conflicts in surrounding code, or understand the possibility of deadlocks...)


anyway, atoms are meant for safely updating contents that are immutable, so are a mismatch for holding a mutable object


(not using swap! or swap-vals! or compare-and-set is a sign an atom is the wrong container to me)


libraries like stuartsierra/component, and integrant, etc. are designed for managing stateful objects (doing initialization as you spin up your system, and shutting them down cleanly when done, handing references to the parts of the system that need to use them without relying on globals)


@markx "Functional programming with immutable values is wonderful, but sooner or later every program has to deal with mutable, stateful, imperative tasks."


What if, say I have a tcp connection, and I need to write to it in different threads?


@mikerod Regarding one of your comments about the cljol library I mentioned in the announcements channel recently, there is certainly more that could be done with it to programmatically analyze a collection of Java objects, and in fact the JOL library itself already contains some code to print summary statistics of a collection of objects in a few different ways. The graph drawing parts of cljol are nice for small to medium sized things, but quickly become too much for a person to make use of.

👍 4

@andy.fingerhut yeah, it makes sense. It looks like something interesting to look at though. I could see it being valuable to be able to navigate over these things


The graphing part is cool indeed. Of course, that could get huge obviously.


Definitely. I have already written some code that does sanity checks on the Java object graphs obtained using the JOL library. For example, if a GC occurs in the middle of walking a structure, the addresses of objects can change, and memory addresses is the way that JOL remembers which object is which while doing the walks, so in those cases you can end up with much less useful results.


I do not know yet. Thanks for pointing it out. I may be able to answer that question later, but at first look, the graphs that clj-memory-meter are ASCII art only, but it definitely seems better at giving total stats for a single object or all objects reachable from there within a REPL.

👍 4

As it is now, the code looks for such inconsistencies, and if it finds one, runs (System/gc) and tries walking the structure again, up to 4 times.


The Clojure data structures created as an intermediate step would be straightforward to do other kinds of analysis on, other than drawing graphs.


Nice. Makes sense.


has anyone been having issues with the maven repository? Or perhaps anyone that uses Travis having any issues running lein deps?