Fork me on GitHub

HEllO. thanks everyone for being on this channel. Does anyone know how to install leiningen on a ec2 instance? I need to set it on its path, import the script, and then make is executable. the help would be appreciated. (i am running linux, ec2 t2 mirco)


I guess it's the same as for every other system. Either follow the instructions ( manually or using some kind of configuration management (puppet, ansible, etc.).


leiningen is probably available for your linux distro's package manager if you're not using anything too exotic.


Also you can use SDKman for install/manage differents versions


i have a clj(s) library that handles the construction and execution of scientific queries via web services. the vast majority of the functions require a data model as their first argument, and the assumption is that the parent application using my library fetches the data model (using the library itself), stores it somewhere, and passes it back to the library with every call. is it entirely against the spirit of clojure to let the library itself fetch the data model and store it in a big honking atom at the top of the namespace? my worry is that every function that references the atom would become impure. reference:


functions would first check to see if the atom is populated. if not, fetch the asset, then continue.


your worry is justified I’d say. In my experience, having the fetches like that as a side effect makes interactive development harder, it makes testing harder, and it makes reasoning about the code harder


just imagine if you want to run multiple fetches in parallel. with explicit passing another chunk of code can handle the fetching and then pass it to the functions, no problem. how would you solve that with fetching as a side effect?


good question! i don't know. if func-a and func-b both require the asset, and both are called one after another, then func-b would probably also fetch the model before func-a returned it.


the library could have a core function that fetches all the assets when called, perhaps.


the question is: what happens when you want to use multiple assets at the same time?


maybe i'm not understanding the question then. if the atom doesn't contain the key for all needed assets (and yup, there are many assets) then the primary purpose of the function gets paused and a call to fetch the assets is made?


i think there are advantages and disadvantages for both scenarios. tough call.


@joshkh there always is 🙂 what do you see as the advantages of the atom method?


and to explain what I meant about multiple assets: I understand that there are many assets, but what if you want to use an entirely different set of assets? For instance, you might want to run the code with test or staging assets. Or you might need to use multiple sets of assets at the same time for different parts of the application. If you store all the assets in an atom and fetch them in the functions, you tie these functions to a specific dataset which makes them less flexible.


i have a much larger re-frame application that connects to many different servers, each with its own data model. those data models end up getting passed all over the place just so they can make their way back to the library that fetched them. there are even cases where the model comes from a dereferenced subscription within a handler (gross, but i guess no different from the library/atom idea). i could make the library itself more complex in exchange for making the larger application less complex. i also want to get some data scientists excited about using the library from a repl, and i'm worried that manually prefetching and managing the assets might scare them away.


oh, i see what you mean now. that sounds like a nightmare too.


If you want to make it easy for use for your data scientist, you can build the easy-to-use interface with automatic data fetching on top of the functional implementation. you can have a different namespace that wraps the functional one. that way you get the best of both worlds.


good point. i think you've stopped me from doing a bad thing. thanks for the input. 🙂


anyway, those are my two cents 🙂 as I said earlier, in my experience I have rarely regretted being more functional and more explicit. On the other hand, I have ended up regretting being implicit and relying on too much on side effects for the reasons mentioned


anytime! 👍


doc strings for anonymous functions. useful?


(thinking of form 2 reagent components where arguments are collected within the returning function)


i guess what i really mean is that defn accepts a docstring where as fn does not. i'm assuming that defn's docstring isn't included when the code is compiled, but a string used as a docstring in fn probably would.


I’m tempted to say a simple comment would work just as well. I know IDEs like Cursive can pick up the docstring and display it when you use a named function, but that’s tied to the name of the function, which of course an anonymous fn won’t have.


it sure would be nice for an idea to tell me what parameters a reagent component accepts .

New To Clojure17:12:43

What is the recommended logging library for Clojure? seems to be a bit outdated


Timbre for me


(it's available as a library separate from pedestal)


Pedestal log dependency for those who are looking [io.pedestal/pedestal.log "0.5.3"]


I thought pedestal was a webserver?


It's certainly timbre that we use


@carr0t Pedestal is primarily a web server library, but there's a lot of useful things that have been broken out into other libraries. For example logging, interceptors, and the routing library. The prefix routing tree in that library is pretty much the fastest routing algorithm in the Clojure ecosystem.


I use the pedestal logging api as well, and use unilog to configure the logback upon which it runs underneath


What’s the best beginner-friendly library for desktop GUIs in Clojure?


seesaw is fairly popular


I have a single file with two namespaces - is.jonathan.metapng and is.jonathan.metapng.tests. its in the root of this directory. Do I need it to be src/is/jonathan/metapng.clj or define something in deps? what is the current best practice for making my first module


@slack1478 in order for require to work, you need the classpath relative path to match the namespace


typically src is on classpath (leiningen calls this :source-paths)


@slack1478 also the typical convention is to have two classpath entries one for source code and one for tests, which simplifies packaging source separate from tests for example


so the typical clojure project with what you have would look kind of like this:

  | is
     | jonathan
      | metapng.clj
  | is
    | jonathan
      | metapng
        | tests.clj


though it would be more common to name the test file metapng_tests.clj and have it in the same relative path (from test vs. src though)


then if you run clojure as something like java -cp clojure.jar:src:test:{other-deps} clojure.main you would get a repl where you can require both your primary code and your test file


leiningen and boot are tools that automate a lot of this setup by creating a project from a template and auto-calculating your classpath


yeah i made a boot template for a quil project recently, but after seeing 1.9.0 using deps.edn and packaging clj, I wanted to see what would be the simplist for new users


especially because this library is so small


it seems weird to have all those nested folders


it’s the only way for libraries to work together reliably


but the metapng and metapng_tests.clj seem fine


how would require know where to look for your namespace?


nothing says you can’t use load-file but that’s kind of hostile to anybody else that might try to build on top of your code


if you are making a top level tool that you don’t intend for people to extend… it might be worth it maybe


all it does is have a function to extract metadata from a png filename, and a function to add/modify png chunk metadata


seems pretty standalone, though maybe thats because i haven't designed it to be composable


so, with load-file you can give your file any name or location you like, as long as you can reliably pass the right path to load to clojure on startup


usually though one would make a self-contained uberjar that can just be executed directly with java, including all your deps, and in that case it’s still more convenient to make sure your code is findable in an automated way based on the namespace


So what I would like, ideally, is something like is.jonathan/metapng for what people require


since it seems that is what I do with other people's libraries


like quil, then using quil.core and quil.middleware


right, and in that case you need a project structure like the tree I described above


that’s the only way require knows how to find things


so whats the difference between . and / ? Anything else change?


to call is.jonathan/metapng there needs to be an is/jonathan.clj file, with a defintion of metapng in it, probably a defn


for example you can call clojure.core/conj and there’s a file clojure/core.clj on your classpath, with (defn conj ...) in it somewhere