If you have main-opts in any of those aliases, then they are winding up in the wrong order
Better in that case to pass the jvm system property version of that flag using -J
-J-Dclojure.main.report=stderror
Yeah, that's what I ended up doing, thanks.
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?
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
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.
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?
I think I'll use carocad/parsera
Wonderful, thanks! Exactly what I needed
How can I make Clojure print seqs as vecs (`("hi") -> ["hi"]`) so that I can easily copy-paste them into the REPL?
Since I have seen you in the cider channel, there is
clojure-convert-collection-to-vector
, normally bound to C-c C-r [
Thanks!
Hi, anyone know how to enforce required options (ie. not missing) with tools.cli?
@seancorfield I heard through the grapevine that you are the one maintaing tools.cli
? Any thoughts?
Look in the tools.cli
category on http://ask.clojure.org — there have been discussions about this recently.
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!
Or must they be required as positional arguments
could be a combination of :default and :validate
{:default ::not-present :validate [#(not= % ::not-present) "Required option!"]}
it might be easier to instead just ' the data structure that you copy
I've tried :validate
and :validate-fn
but they don't seem to be invoked for the value specified by the :default
key
I guess options are really optional 😅 I'll have to do my validation without resorting to the :errors
key
Is there an issue tracker for https://github.com/clojure/tools.cli?
@nicolas.estrada938 just report on http://ask.clojure.org or in #tools-deps channel. If required, Alex should open a ticket.
Is there any conceivable reason that a reductions
like fn can’t have an equivalent transducer version?
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)))))))
@delaguardo - right. Exactly as I was thinking about it.
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?
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.
Right. Thanks.
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?
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])))
@endrebak (for [[a b _ d] ls] [a b d])
just use destructuring if you want it shorter
That is a good suggestion! Since I am parsing java exceptions I think I can be sure each row has four elements.
(defrecord Square [l])
(->Square 10)
(Square. 10)
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?
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}
([])
([_ _]))
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
https://github.com/grammarly/omniconf/blob/master/src/omniconf/core.clj#L272-L288 actually
https://github.com/cognitect/transit-clj/commit/b2e4bc8c95a5c14c8cae5e9edf450d61461d89dc I would go with Transit as storage.
Compatibility seems like the main concern
It’s rarely used
You should definitely prefer the constructor function over interop
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
@alexmiller Are you referring to anything specific regarding missing features? (This is out of curiosity)
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
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
No
But if I imagine where I’d put features as a language implementor, that’s one place
Thanks 🙂 But numbers cannot be used with juxt
, right?
((juxt 0 1 3) "abcdefg") ;; error
Each index should be wrapped in #(nth % index)
.
Just out of curiosity, did you search for this by using a regex with http://grep.app?
I did not
Mind sharing how you found that the library uses metadata that way? 🙂 Just want to hone my searching skills too
someone tried to use it with #babashka and bb didn't support that syntax yet
If you want to search code using clojure.spec regexes, you can use: https://github.com/borkdude/grasp
Sweet, I do know about this lib from one of the clojure podcasts ✌️:skin-tone-4:
I say print compiler warnings for next release, then kill it... 😅
Never
There is no reason to break people for no reason
Like I said, it’s not shorter :)
what would be the bestway to handle maps(google maps/ mapbox) in clojure -> integrate it in js or handle it with clojure
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?
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.
You can make your own at https://trends.google.com/
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.
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.
> (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.
BTW What do you use to block cookies? Do you block all of them in web browser or user adblocker?
I thought I just saw Clojure as 45th most popular language, which is higher than I've seen it before. (TIOBE maybe?)
I use the Brave browser. It prevents plenty of tracking by default. I think newer versions of Safari do too.
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 ;-)
This is just a guess but let's break it down by region:
Let's narrow down on China:
Very sharp drop off. Can it possibly account for the largest part of it?
Interest in Clojure in Finland seems pretty consistent (go metosin!)
good point
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
I think that explains most of it
Curious to know what changed in China
Do you know website with statistic how many developers use Clojure each year?
Makes sense. Thank you!
thank you
No, but you could refer to the annual Clojure survey
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
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
good point too
That's catchier than Linus Torvalds's quote about this subject
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 😉)
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
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.
Well you can put quotes around that and attribute it to rich