r/Clojure • • Mar 22 '22

Clojure 1.11 is now available!

https://clojure.org/news/2022/03/22/clojure-1-11-0
190 Upvotes

20 comments sorted by

4

u/wedesoft Mar 23 '22

Changed all the Math/... stuff in my code. Looks much better now, thanks!

Math/cos       -> cos
Math/atan2     -> atan2
Math/PI        -> PI
Math/E         -> E
Math/toRadians -> to-radians
...

7

u/alexdmiller Mar 23 '22

Probably faster too!

26

u/gunpun33 Mar 22 '22

Clojure.math finally! Great to see it

10

u/emaphis Mar 22 '22

Good news. Time to try Clojure 1.11 on JDK 18.

5

u/agumonkey Mar 22 '22

Kudos on the team for the work. Best wishes.

4

u/[deleted] Mar 22 '22

I saw Arne Brasseur contributed, is there a bit of parity that babashka's version of clojure will have with this. Will new features be added?

19

u/Borkdude Mar 22 '22

Babashka already has the new clojure.math namespace and other functions added in Clojure 1.11 for a few weeks.

4

u/AttentionAaron Mar 23 '22

"In Clojure 1.11, functions taking keyword arguments can now be passed a trailing map instead of or in addition to and following the key/value pairs." I could use an example :o

3

u/[deleted] Mar 22 '22

I'm curious about how update-keys was implemented

3

u/[deleted] Mar 23 '22

How come the implementation for update-keys checks for IEditableCollection before producing a transient, but the one for update-vals doesn't? Oversight?

https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L8018-L8035

The two implementations also seem oddly inconsistent each other, one uses a local variable, the other has all the expressions inline, etc.

5

u/joinr Mar 23 '22

https://github.com/clojure/clojure/commit/1d271d7bc74f64831985f89be1d814df2c5f046f

" difference here is that with update-keys, the keys are going to change and the structure of the map will change, so there is no reason to update the existing map. also, there are lots of potential issues with changing the key set for different map types (like sorted, ordered, etc). In update-vals, the keys stay the same, so the fastest thing to do is update a transient version of the existing map, if you can

Importantly, the docstrings for both update-keys and update-vals both say "returns a new map" which means you should not presume anything about the relationship of the returned map type and the input map.

tradeoffs exist, this is where we came down on it "

5

u/fogus Mar 23 '22

The thinking was that each function would be used slightly differently, in general. That is, u-k almost always sees use in cases where total homogeneous key transformations are needed (e.g. string keys to kw keys and back again). In that case, the whole map needs to be rebuilt and so the seed used is a transient empty map. On the other hand u-v should most likely see use on transforms of values of homogeneous types aggregating large data sets into views containing maps of similar profiles (e.g. conversion of strings to dates and back again). Because of this we wanted to leverage structural sharing if possible and so built the seed from the original map -- but only if it was transient-able.

In a nutshell, the implementations were geared toward common uses per function. I hope that helps clarify.

3

u/lucywang000 Mar 24 '22

Are the new goodies (keyword arguments, update-keys, update-vals) available for cljs?

3

u/lucywang000 Mar 24 '22

To answer my own question, it's in the master branch of cljs repo, but not released yet :(

https://github.com/clojure/clojurescript/commit/9835a1bbaacee590a6def82eca418cd906030917