Fork me on GitHub
#clojure
<
2021-05-31
>
Alex Miller (Clojure team)01:05:38

If you have main-opts in any of those aliases, then they are winding up in the wrong order

Alex Miller (Clojure team)01:05:05

Better in that case to pass the jvm system property version of that flag using -J

Alex Miller (Clojure team)01:05:02

-J-Dclojure.main.report=stderror

p-himik08:05:25

Yeah, that's what I ended up doing, thanks.

svt04:05:43

I want to intercept all incoming calls in my application, for incoming calls I’m using ring and for making outgoing calls I’m using clj-http, what is the preferred way to do it?

indy05:05:52

What is the goal? For intercepting incoming calls you could use a ring middleware. For outgoing calls you could wrap the clj-http client with your logic and use a https://github.com/dakrone/clj-http#custom-middleware there too.

dpsutton05:05:24

For ring the standard pattern is middleware. For outbound my first solution would be to make a namespace that exposes vars that do whatever else needs to be done around calls to clj-http

Lyderic Dutillieux06:05:08

Hey, I would like to start a clojure analysis tool. I need to parse clojure code and metadata. Would you recommend writing a specific parser myself, or is there an already existing generic parser that I can build onto?

Lyderic Dutillieux07:05:30

I think I'll use carocad/parsera

Lyderic Dutillieux08:05:12

Wonderful, thanks! Exactly what I needed

Nom Nom Mousse08:05:11

How can I make Clojure print seqs as vecs (`("hi") -> ["hi"]`) so that I can easily copy-paste them into the REPL?

Alex Miller (Clojure team)12:05:31

it might be easier to instead just ' the data structure that you copy

magra09:06:26

Since I have seen you in the cider channel, there is clojure-convert-collection-to-vector, normally bound to C-c C-r [

Nicolas Estrada09:05:20

Hi, anyone know how to enforce required options (ie. not missing) with tools.cli?

delaguardo10:05:57

could be a combination of :default and :validate {:default ::not-present :validate [#(not= % ::not-present) "Required option!"]}

Nicolas Estrada13:05:00

I've tried :validate and :validate-fn but they don't seem to be invoked for the value specified by the :default key

Nicolas Estrada13:05:57

I guess options are really optional 😅 I'll have to do my validation without resorting to the :errors key

souenzzo13:05:43

@U0230KNPHDM just report on http://ask.clojure.org or in #tools-deps channel. If required, Alex should open a ticket.

🙏 3
Nicolas Estrada08:06:34

@U04V70XH6 I heard through the grapevine that you are the one maintaing tools.cli? Any thoughts?

seancorfield15:06:43

Look in the tools.cli category on http://ask.clojure.org — there have been discussions about this recently.

Nicolas Estrada14:06:38

Thanks, I used the :missing keyword and it worked just fine, that one was missing from the README or example, but was in the doctstring! Thanks!

Nicolas Estrada09:05:39

Or must they be required as positional arguments

craftybones13:05:17

Is there any conceivable reason that a reductions like fn can’t have an equivalent transducer version?

delaguardo13:05:57

they can but it has a strong dependency on the usecase for example:

(defn xf-reductions
  "Stateful transducer that mimics clojure.core/reductions.

  DIFFERENCE:
    1. There is no one-arity form.
    2. init value will not be added to the reductions list as already known."
  [f init]
  (fn [xf]
    (let [acc (volatile! init)]
      (fn
        ([] (xf))
        ([result] (xf result))
        ([result input]
         (let [res (f @acc input)]
           (vreset! acc res)
           (xf result res)))))))

craftybones13:05:36

@U04V4KLKC - right. Exactly as I was thinking about it.

craftybones13:05:02

Every stateful transducer then can be written in these terms right? As in, aren’t all stateful transducers, reductions essentially? Or do I have this wrong?

delaguardo13:05:29

I can’t say “every” but most of them can be written like that. And I think the only problem with reductions not having transducer equivalent is only because of it’s interface.

craftybones13:05:04

Right. Thanks.

roklenarcic13:05:53

Is there some EDN reading library that has similar performance profile to JSON libraries? Or should I try to use Transit for storing basic Clojure datastructures to text?

Alex Miller (Clojure team)15:05:24

edn is generally going to be much slower to parse than transit. If you want data for people to read/edit edn is better. If your concern is sending data or reading/writing data between programs, transit is better/faster

Nom Nom Mousse13:05:26

What would be a good way of getting elements 0 1 3 from each element of this list?

(def ls  '([73 62 15 3] [10 94 91 66] [44 24 4 23] [30 34 24 80] [46 58 60 56])))
This works, but I am wondering whether there are other ways:
(for [l ls] (vals (select-keys l [0 1 3])))

Alex Miller (Clojure team)15:05:41

juxt is a good thing to consider for “get multiple things from the same data”. It’s certainly not going to be shorter than what you have here though

Nom Nom Mousse15:05:22

Thanks 🙂 But numbers cannot be used with juxt, right?

((juxt 0 1 3) "abcdefg") ;; error

p-himik15:05:25

Each index should be wrapped in #(nth % index).

👍 3
Alex Miller (Clojure team)16:05:23

Like I said, it’s not shorter :)

simongray10:06:38

@U0232JK38BZ (for [[a b _ d] ls] [a b d])

simongray10:06:48

just use destructuring if you want it shorter

Nom Nom Mousse10:06:00

That is a good suggestion! Since I am parsing java exceptions I think I can be sure each row has four elements.

vncz13:05:02

(defrecord Square [l])

(->Square 10)
(Square. 10)

vncz13:05:27

Is there any meaningful difference between the two ways of constructing a record? Which one should I privilege? I know that the latter is Java interop (and we should stay away from it as much as possible) but other than that, is there a difference under the hood?

Alex Miller (Clojure team)14:05:17

You should definitely prefer the constructor function over interop

Alex Miller (Clojure team)15:05:22

They do ultimately do the same thing but the constructor will be more portable and may have features the interop does not at some future point

vncz15:05:21

@U064X3EF3 Are you referring to anything specific regarding missing features? (This is out of curiosity)

Alex Miller (Clojure team)15:05:53

But if I imagine where I’d put features as a language implementor, that’s one place

👍 3
vncz17:05:45

Makes sense. Thank you!

borkdude14:05:27

Is there a reason this trailing metadata syntax should be supported in newer clojure dialects, other than compatibility?

(defn foo
  ([])
  ([_ _])
  {:x true})
vs metadata on the front:
(defn foo
  {:x true}
  ([])
  ([_ _]))

Alex Miller (Clojure team)14:05:50

Compatibility seems like the main concern

Nicolas Estrada16:05:18

I say print compiler warnings for next release, then kill it... 😅

Alex Miller (Clojure team)16:05:38

There is no reason to break people for no reason

ghadi21:05:29

That's catchier than Linus Torvalds's quote about this subject

Alex Miller (Clojure team)23:05:44

Well you can put quotes around that and attribute it to rich

borkdude14:05:48

clj-kondo also isn't able to deal with the first (currently) and nobody every complained about it so far, but I see it's being used in a library called omniconfig

indy15:05:28

Just out of curiosity, did you search for this by using a regex with http://grep.app?

indy15:05:20

Mind sharing how you found that the library uses metadata that way? 🙂 Just want to hone my searching skills too

borkdude15:05:00

someone tried to use it with #babashka and bb didn't support that syntax yet

borkdude15:05:19

If you want to search code using clojure.spec regexes, you can use: https://github.com/borkdude/grasp

❤️ 3
indy15:05:30

Sweet, I do know about this lib from one of the clojure podcasts ✌️:skin-tone-4:

sandeep16:05:46

what would be the bestway to handle maps(google maps/ mapbox) in clojure -> integrate it in js or handle it with clojure

kwladyka16:05:14

Can someone share article / thoughts about reasons of consistent google trends Clojure dropping? It can be subjective, but I also see less traffic on slack, than a few years ago. What is happening? Do (Don’t) developers have fun using Clojure or only developers which should stay with Clojure? What changed in September 2020 Clojure trends drop so much? Pandemic? How?

Ben Sless17:05:35

This is just a guess but let's break it down by region:

Ben Sless17:05:10

Let's narrow down on China:

Ben Sless17:05:39

Very sharp drop off. Can it possibly account for the largest part of it?

Ben Sless17:05:34

Interest in Clojure in Finland seems pretty consistent (go metosin!)

Ben Sless17:05:33

Israel Most of the traffic is probably from Appsflyer and during the pandemic our management took a very very conservative fiscal strategy and almost froze hiring. New hires do lots of googling

Ben Sless17:05:19

I think that explains most of it

Ben Sless17:05:57

Curious to know what changed in China

kwladyka17:05:43

Do you know website with statistic how many developers use Clojure each year?

Ben Sless18:05:22

No, but you could refer to the annual Clojure survey

Alex Miller (Clojure team)19:05:17

I think people are not generally aware what a high percentage of traffic tracking is being blocked by browsers these days which makes me look skeptically at these numbers

👍 9
👀 3
Alex Miller (Clojure team)19:05:05

We recently found as much as 90% of traffic to Datomic sites was being blocked from tracking so things like Google analytics were fairly inaccurate

kwladyka20:05:57

good point too

Christoffer Ekeroth22:05:46

My take is that Clojure has entered the “Plateau of productivity” phase of the hype cycle. I mean it’s been around for 14 years now so I think most of the novelty factor has worn off. (Although this doesn’t account for the sudden drop in Sept. 2020) (Also worth remembering is that if Google Trends is a valid quality metric we should all be coding in Java / JavaScript 😉)

Christoffer Ekeroth22:05:07

Another thing is that mainstream adoption takes time; after the novelty factor has worn off you have to scale a way larger hill, which is to become a battle-tested language that’s regarded as “production-ready”. Erlang lingered in obscurity for about two decades before the rise of instant messaging created a demand for the same kind of throughput and robustness that was a solved problem in telecom. TBH I don’t think the world “at large” is ready for Clojure; Python has begun to overtake Java / .NET in just the last few years, so I think it’ll be a while before “the industry” is ready for functional programming

Christoffer Ekeroth23:05:02

That said, I personally believe that Clojure is uniquely well-suited for what’s going to be standard application development in a few years, which is to move yet more towards data processing and enabling systems to talk to each other. Most of my work nowadays is just building APIs that string together other APIs. Strong type systems and OOP are not much help here, but “interactive” (e.g. REPL-driven) development, persistent data structures, easy serialization and schemas / data-driven systems sure are.

👍 6
Nom Nom Mousse08:06:19

I guess Lisps are always going to be something for the initiated. It would be interesting to see Clojure compared to other Lisps in such a graph.

magra09:06:55

I still say "I google" but i do not use google anymore but alternative search engines. I also block analytics, third-party cookies etc. And all the (not)"googling" I do for clojure rarely includes the word clojure as a search term. When I go to clojure cheatsheet, clojure toolbox or clojureverse they open from my browsers history. Then libraries in clojure have names which don't give away what the do, so (not)"googling" for "fulcro" "luminus" "reagent" will rarely include the search term "clojure". Even "clj-pdf" or "clj-http" will not show up as the searchterm clojure.

magra09:06:15

As an aside: The red-monk, or whatever, popularity of programming languages index only uses searches, I suspect google only, for "x programming language". Now, who would ever google "clojure programming language"? In real life you google "java" then find out the search was to wide and then try again googling "java programming language". With clojure you google "clojure" and you got it. No need to ever refine the search.

kwladyka16:06:11

> (Also worth remembering is that if Google Trends is a valid quality metric we should all be coding in Java / JavaScript 😉) Not really. Java doped too. Bur Rust is going up.

kwladyka16:06:10

BTW What do you use to block cookies? Do you block all of them in web browser or user adblocker?

Joel15:06:27

I thought I just saw Clojure as 45th most popular language, which is higher than I've seen it before. (TIOBE maybe?)

Nom Nom Mousse15:06:45

I use the Brave browser. It prevents plenty of tracking by default. I think newer versions of Safari do too.

magra17:06:11

uMatrix. It has something like a spreadsheet of all the connections a website requests and I tell it which ones are ok. Not everyones cup of tea ;-)