Fork me on GitHub
#clojure
<
2020-03-23
>
dabrazhe12:03:04

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.

souenzzo13:03:26

(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?

dabrazhe13:03:16

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

souenzzo13:03:38

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
slipset14:03:00

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))

ak-coram16:03:35

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

ak-coram16:03:42

@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

ak-coram16:03:03

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

ak-coram16:03:30

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

ghadi16:03:50

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)

ak-coram16:03:03

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

ak-coram16:03:16

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

ak-coram16:03:01

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.

ghadi16:03:25

you can always call the record constructor

ghadi16:03:48

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

ghadi16:03:12

Foo<T> <---- common

ghadi16:03:17

Foo<? extends Record> probably uncommon

ak-coram16:03:03

@ghadi maybe they'll even make them sealed

ghadi16:03:07

Foo<SomeRecord> common

ghadi16:03:34

I'm years away from caring

ak-coram16:03:42

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

ak-coram16:03:37

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

ghadi18:03:59

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. https://github.com/DeLaGuardo/setup-clojure

ghadi18:03:15

are there reliable 3rd party actions for it?

mike_ananev18:03:24

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

ghadi18:03:34

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

ghadi19:03:43

cool -- I only am deploying uberjars to s3

ghadi19:03:58

not pushing things to clojars

kwladyka19:03:05

the example link is for clojars

kwladyka19:03:17

but this will be very similar

njj23:03:31

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

seancorfield23:03:41

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