Fork me on GitHub

Hi. Is there a performance or another difference between core.set and into #{} ? Their implementations are different but it boils down to reduce, it seems.


(set coll) is preferred over (into #{} coll) But they do the same thing (both create a set and inserts elements on it, using transients when available )

Daniel Stephens13:03:28

Doesn't set skip the work if it's already a set, whereas into does the work regardless?


Yes, based on the implementation set does skip 'the work' if the coll is a set


I don't think you should worry about that kind of thing ATM. I would only change from one to another if I had a real application problem if it showed a performance problem

💯 4

If I want to distinguish between lists/vectors/sets on the one hand and maps on the other hand, is there a predicate that fits better than (complement map?) . What I'm after is something that conveys many-ness as in something like this:

(if (not (map? foo))
   (map bar foo)
   (bar foo))
where if foo is a list/vector/set I'd like to map bar over it, but if it's a map?, I'd just like to call bar on it

Alex Miller (Clojure team)14:03:20

no better pred. why not just remove the not and flip the clauses?

Darin Douglass15:03:13

or you could

(if-not (map? foo)
  (map bar foo)
  (bar foo))


has anyone tried creating Java records (JDK14 preview feature) via gen-class?

Alex Miller (Clojure team)16:03:38

Clojure records are remarkably similar to Java records (not a coincidence I think) so if you want them, I'd just use Clojure records


@alexmiller I just wanted to play around with them, not use them for anything

Alex Miller (Clojure team)16:03:44

I suspect that since records are mostly a compiler construct (they emit classes that must extend a special type, and have other special flags in the class files), you would need an ASM that supports Java 14 to properly emit these classes

Alex Miller (Clojure team)16:03:23

so it's probably not possible to make them with Clojure class construction in current Clojure

Alex Miller (Clojure team)16:03:32

but I have not closely inspected the bytecode to know for sure


I think they're regular classes extending java.lang.Record


there may be no new bytecode involved at all

Alex Miller (Clojure team)16:03:56

the object methods are implemented with invokedynamic, which you won't get out of the clojure compiler right now

Alex Miller (Clojure team)16:03:42

I mean with some small changes, Clojure's records could probably be Java records


I like how the equals+hashcode are dynamically generated by indy

Alex Miller (Clojure team)16:03:24

given that Java is planning to build things like destructuring on top of these down the line, that might be worthwhile (can't say it would do much right now afaict)


yeah, I was thinking about future interop with them too, but since they're not final it's a bit early for supporting them anyway in Clojure

Alex Miller (Clojure team)16:03:29

way too early, unlikely we will do anything about these for years

Alex Miller (Clojure team)16:03:37

from an interop perspective, there's nothing new here - you're still just accessing fields/methods/constructors etc

Alex Miller (Clojure team)16:03:31

being able to make any possible class is a non-goal of gen-class or the other clojure class generation facilities


future Java libraries might require you to provide your own records though, which could be a possible interop use-case


thanks for the info

Alex Miller (Clojure team)16:03:24

possibly, but the whole deal with records is they're just classes

Alex Miller (Clojure team)16:03:21

until there is syntax built on it, I don't think it's critical. the whole "special extension of a concrete class", bleh.


you can always call the record constructor


providing your own record classes is weird and I don't think will be common


Foo<T> <---- common


Foo<? extends Record> probably uncommon


@ghadi maybe they'll even make them sealed


Foo<SomeRecord> common


I'm years away from caring


I'd care more about them too if they had unboxed fields 🙂


I mean if they didn't add overhead because of the boxing

Alex Miller (Clojure team)17:03:51

clojure records have unboxed fields for doubles and longs


I haven't looked in a few months, but what are people doing with Github Actions for Clojure? specifically w/ tools.deps

👀 4
Eamonn Sullivan18:03:24

I've only recently started using Actions, but I've used this one with a couple of recent small projects and it seems to work well.


are there reliable 3rd party actions for it?


@ghadi example: if commit contains tag then Github Actions can make: build, test, deploy release to clojars. No external CI/CD.


I have a homerolled thing that builds a jar and drops it into S3, but I want to get rid of the homerolled part


cool -- I only am deploying uberjars to s3


not pushing things to clojars


the example link is for clojars


but this will be very similar


Any resources for Clojure jobs? Unfortunately some of us are losing jobs because of the "situation".


There are #jobs and #remote-jobs channels -- plus #jobs-discuss for discussion of jobs and resources.