This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-12-19
Channels
- # adventofcode (82)
- # beginners (70)
- # boot (34)
- # boot-dev (13)
- # cider (45)
- # clara (4)
- # cljs-dev (3)
- # cljsrn (2)
- # clojure (91)
- # clojure-art (8)
- # clojure-czech (1)
- # clojure-dusseldorf (3)
- # clojure-france (11)
- # clojure-germany (1)
- # clojure-greece (39)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-norway (2)
- # clojure-spec (7)
- # clojure-uk (31)
- # clojurescript (56)
- # core-async (7)
- # cursive (8)
- # data-science (10)
- # datomic (41)
- # duct (7)
- # emacs (1)
- # events (1)
- # fulcro (83)
- # graphql (6)
- # klipse (1)
- # leiningen (28)
- # lumo (67)
- # off-topic (14)
- # om (9)
- # onyx (3)
- # perun (4)
- # re-frame (22)
- # reagent (11)
- # ring-swagger (2)
- # rum (1)
- # specter (46)
- # sql (13)
- # uncomplicate (17)
- # unrepl (114)
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 (https://leiningen.org/) 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 http://sdkman.io/
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: https://github.com/intermine/imcljs/blob/master/src/cljc/imcljs/path.cljc#L37
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.
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?
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.
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.
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
(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 .
What is the recommended logging library for Clojure? https://github.com/clojure/tools.logging seems to be a bit outdated
what I use and prefer: https://github.com/pedestal/pedestal/blob/master/log/src/io/pedestal/log.clj
(it's available as a library separate from pedestal)
Thank you, @admay, @tbaldridge, @noisesmith, @carr0t!
@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
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:
src
| is
| jonathan
| metapng.clj
test
| 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
it’s the only way for libraries to work together reliably
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
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
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