Fork me on GitHub
#off-topic
<
2021-01-18
>
clyfe08:01:36

There are a lot of .thing configs piling up in a project root; the convention .config/thing would be better (if all would follow it, not some).

hkjels08:01:36

If you mean in general for all software, that’s a big ask. Some use such dotfiles to discover project root as well

clyfe09:01:37

In linux ~/.config dir became more established in recent times. Good point on discovery; but I'd guess if the folder is hidden (starts with ".") is less relevant to such use (at least compared to, say, deps.edn).

clyfe09:01:41

Also, on discovery & such, .config/thing can still act as an indicator

hkjels09:01:13

it would definitely be cleanlier

hkjels09:01:30

I guess if you have strong feelings about it, you must create a blog-post and get hype on hackernews and similar for people to start adopting the convention

sP0re10:01:19

Hi, I have a question that is not related to Clojure but more to functional programming in general. How can you make dependency injection? And If you have 2 modules, how will you make the first one to use the second one with dependency inversion? I haven’t covered this topic with clojure yet (I’m studying the basics) but I’m sperimenting something with Spring and Java Reactor with Functional interfaces. In a OO world I usually inject an interface in module 1 (defining a Bean that returns an instance of Module 2) and then I implement that in the module 2. I cannot use Suppliers, Functions and Bifunctions instead regular methods in this way in Java. I can’t use the interface. So What is the right approach based on your experience with func programming in general? Thank you a lot

rakyi10:01:53

in general, pass function as a parameter 🙂 this might give you some ideas, if you are new to FP http://mishadoff.com/blog/clojure-design-patterns/

rakyi10:01:52

if you need to manage stateful things look at https://github.com/stuartsierra/component (and its alternatives)

sP0re11:01:33

Ok, but if I don’t want module 1 knowing module 2, if I pass a function as parameter it has to know that module, or not?

sP0re11:01:07

I’ll look for clojure design patterns, thanks :)

simongray12:01:20

@mircoporetti You can pass a function or a piece of mutable state or whatever you need. Your modules don’t have to “know” each other. They just assume that the passed in arg is e.g. a function and therefore call it as a function. In OOP you typically bundle functions and state as an object. In Clojure, you might simply use a map or a record instead of an object if you need to conform to some kind of complex interface. Clojure Spec (or malli or schema) can be used to describe the shape of the data if you also need to validate it.

sP0re12:01:03

Interesting!

simongray12:01:33

A lot of Clojure-style functional programming is enabled by decomposing what you are used to with objects into data (mutable and immutable) and functions operating on the data (side-effecting and pure). It is much more useful to have this separation.

simongray12:01:48

So the pure functions operate on immutable data, while side-effecting functions (often marked with a !) operate on your mutable state. You generally want to expose the smallest possible surface area of your data as mutable state. Less mutable state leads to fewer side-effecting functions.

👍 6
emccue13:01:56

@mircoporetti Maybe this code example will make sense

emccue13:01:30

(ns user.persit
  (:require [next.jdbc :as jdbc]))

(defn for-id [db id]
  (jdbc/select "users" {:id id}))

emccue13:01:36

first, you have functions that take what they want explicitly as parameters

emccue13:01:11

(defn create-system []
  {:db (connect-to-database)
   :redis (connect-to-redis)})

emccue13:01:33

you have some procedure that returns a map of all the stateful "system like" stuff in your app

emccue13:01:52

(there are a few approaches to this, but for now just imagine you do it manually in one place)

emccue13:01:18

then at the service level you have functions that take this map

emccue13:01:09

(possibly wrapped in some context for stuff like http)

emccue13:01:46

(defn figure-out-first-user [request]
  (let [{:keys [db]]      (:context request)
        {:keys [user-id]} (:json-params request)]
    (p-user/for-id db user-id)))

emccue13:01:10

and functions at the top level take out the parts of the system that they care about

emccue13:01:18

"declare their dependencies"

emccue13:01:43

the wiring changes depending on how you structure your app, but thats the gist of it

emccue13:01:06

"look for the keys in a map that you care about"

emccue13:01:54

That is the clojure specific answer

emccue13:01:19

As far as statically typed functional languages go,

emccue13:01:49

Scala uses "implicit parameters" for DI

emccue13:01:18

Haskell uses the power of imagination and something something partial function application

Stuart15:01:07

looking at this john hopkins map of the US coronavirus infctions. How come the big around the middle west ish seems to have got away with relatively few infections? Is this infections map starting to be like a representation of population density? (I'm not from the US) Is the east coast and eastern middle far more densly populated, or something going on?

Stuart15:01:29

are people in the west of the country generally more careful or maybe those states tend to have tighter controls?

manutter5115:01:51

Yeah, it’s looking a lot like a population density map lately. The Plains states are generally more sparsely populated.

andy.fingerhut15:01:17

That map looks a lot like a population density map of the USA. There are very few people living in the Rocky mountains compared to the west coast

andy.fingerhut16:01:23

Depending upon what kind of info you are looking for, a map that showed different colors for percentages of local population with some property you are interested, might be more useful.

emccue16:01:24

@qmstuart There are honestly too many conflating factors in infection data

emccue16:01:49

a lot of states artificially make getting tests hard for either everyone or just certain populations

emccue16:01:17

and looking at absolute numbers won't tell you much specifically because its just a population density map at a certain point

emccue16:01:06

covid deaths per capita by state might be more useful

emccue16:01:28

but even that is somewhat inaccurate and won't tell you much without more specific time slices

emccue16:01:05

the most accurate data will be excess deaths

emccue16:01:42

or if your locale has something similar to this

emccue16:01:15

which can work as a proxy for testing for determining the relative magnitude of community spread

emccue16:01:29

since everyone poops

seancorfield19:01:26

Folks, we have a #covid-19 channel where aspects of that can be discussed. We'd rather folks "opted in" to that discussion rather than have it in a big channel like this.

👍 12
🙏 6
thanks2 3