clojure

oyakushev 2025-10-30T10:36:43.019819Z

Performance riddle anyone?

(crit/quick-bench (NaN? 37.648145389078360M))

             Execution time mean : 4.465326 ns
    Execution time std-deviation : 0.015779 ns

(crit/quick-bench (NaN? 37.648145389078361M))

             Execution time mean : 162.714021 ns
    Execution time std-deviation : 2.788535 ns

p-himik 2025-10-30T10:41:25.181549Z

Something to do with converting BigDecimal to double.

oyakushev 2025-10-30T10:46:13.680199Z

It has indeed, and yet so tricky if you only test with smaller bigdecimals thinking it is fine.

vijaykiran 2025-10-30T10:47:22.788169Z

We need a new type SmallBigDecimal

oyakushev 2025-10-30T10:49:44.168069Z

bigLITTLEdecimal for that ARM compatibility

borkdude 2025-10-30T10:50:10.501079Z

can bigdecimals be nan though? I guess not?

oyakushev 2025-10-30T10:50:23.719829Z

The docs say they can't be nan nor infinite

p-himik 2025-10-30T10:57:49.646549Z

Here's where the difference comes from:

user=> (long (double 37648145389078360))
37648145389078360
user=> (long (double 37648145389078361))
37648145389078360
For values for which the roundtrip value is the same, a fast conversion path is used.

igrishaev 2025-10-30T12:36:39.368079Z

Numeric types auto-cast is the issue, indeed. Quite annoying

p-himik 2025-10-30T13:22:54.126269Z

It's not about auto-casting per se. A manual cast leads to the same exact behavior. Just calling (.doubleValue big-dec) is enough.

igrishaev 2025-10-30T13:25:34.279379Z

Hm, and I though it's autocast: NaN? -> Double/isNaN that accepts native double . So BigDecimal gets coerced to native double

p-himik 2025-10-30T13:33:06.530419Z

Well, yes. But it's just a way to surface the issue, it's not the root cause itself. The root cause is the implementation of BigDecimal.doubleValue. It can indeed be called by auto-casts, but it can also be called by something else.

Neil Hooey 2025-10-30T19:35:11.725359Z

I made a GitHub Community suggestion: “Rainbow parenthesis” for Clojure and Lisp dialects: https://github.com/orgs/community/discussions/178446

🆒 1
➖ 1
👌 1
jyn 2025-11-01T08:00:27.196629Z

i find rainbow parens useful when writing code but not really when reading it

👍 1
jyn 2025-11-01T08:00:42.089389Z

i dislike parinfer and don’t use it, it messes with the vim undo log

reefersleep 2025-10-30T19:46:30.535629Z

I thought I would love rainbow parentheses when I first learned of them, both due to making scope clearer and due to added playfulness of the colors 🤗 took me a little while to figure out that it really only distracted and confused me when I read code. So I would personally be sad if this became the default for GitHub. As an opt-in per-user setting, sure.

➕ 12
Neil Hooey 2025-10-30T19:58:46.452829Z

It helps a lot when indentation is done well, by lining up maps, vectors, function parameters, etc. Use the latest version of: weavejester/cljfmt (https://github.com/weavejester/cljfmt) and the following highlighting options in .cljfmt.edn:

;; Requires `github:weavejester/cljfmt:0.15.2`
 :align-form-columns?             true
 :align-map-columns?              true
 :align-associative?              true
This was only possible within the last couple of weeks because he just released the features.

Karthik 2025-10-31T04:30:49.427839Z

I think people from other programming languages won't like it. Say in ruby and python, we intend the code so that the parenthesis align, so just by looking at the code we know which bracket matches which one. But ya, if GitHub can make this stuff exclusively for Clojure, it might be good 👍

tatut 2025-10-31T06:34:31.055679Z

ime rainbow parens just look too noisy

tatut 2025-10-31T06:36:04.141499Z

probably individual differences in color perception affect it as well, but I don't want to draw attention to parens, because I don't think about them, paredit keeps them "right".

➕ 3
hkjels 2025-10-31T07:43:11.402609Z

I prefer to highlighting only relevant context like current symbol, strings/documentation, numbers, problems and "dangerous" commands. Everything else I have just turned off. For me it is calmer and more productive, so I very much agree with @reefersleep that this should be configurable.

hrtmt brng 2025-10-31T12:39:00.676679Z

I don't like rainbow parenthesis. But for GitHub I would find it cool. If you read code in a web page, I dont mind if it has colored parens. It looks nice. It makes Clojure more colorful, friendly and attractive for people who don't know it yet.

ghadi 2025-10-31T18:18:58.314079Z

imagine all your sheet music was annotated to show where the beats were 1 e & a 2 e & a 3 ....