Fork me on GitHub
#clojure
<
2021-04-18
>
seancorfield01:04:38

@jayzawrotny Interesting that, so far, it’s a 50/50 split between “other” and A+B.

jaide22:04:08

Wasn’t expecting that! Wanted to know how to best update https://github.com/eccentric-j/cljs-tui-template. Sounds like the path forward is to support clj-new and generate a blank version into a separate repo people who use neither can reference.

seancorfield23:04:48

I think quite a few people take the approach of "clone a similar project and then hack it into what I want" which isn't really how OSS projects are intended to be used but... ¯\(ツ)

seancorfield23:04:48

Are you aware of the changes both clj-new and lein new have made recently to better support the Clojars VGNs policy?

jaide00:04:38

Oh good, I wasn't aware those libraries made any changes. I'll read up on that. Thanks for the heads up.

seancorfield01:04:37

LMK if you have any Qs -- I drafted them first for clj-new and then worked with Phil on Leiningen's changes.

jaide01:04:13

Thank you, will probably start focusing on that one I switch blessed + react-blessed -> ink 3.

jaide01:04:26

btw working on it live at https://gather.town/i/kcWbjU1O for another hour or so. Password is enclojure if you or anyone wishes to see progress or chat.

macrobartfast01:04:31

When I call function A with function B inside it, function B doesn’t evaluate. When I evaluate function B outside function A with cider, it evaluates. Thoughts?

macrobartfast01:04:40

I’m wondering if it’s a lazy evaluation thing, as function B has a map in it; but trying doall and dorun doesn’t help.

seancorfield02:04:35

@macrobartfast Guess we’d have to see the code?

macrobartfast02:04:12

haha definitely… I’m trying to isolate/reproduce it as it’s a huge bloated not-my-code mess I can’t post here…

macrobartfast02:04:24

I’ll see if I can do that, though.

macrobartfast02:04:44

I was just praying you were psychic, is all.

seancorfield02:04:54

You would at least need to provide a bit more precision around terms like “doesn’t evaluate” etc, and explain how you reached the conclusions about what is and what is not happening, i.e., what you tried, what behavior you got, what behavior you expected.

seancorfield02:04:35

Debugging should be a scientific endeavor, after all…

macrobartfast02:04:46

no, totally fair enough… I’ll do my homework.

yuhan05:04:43

Are there any downsides to using a library like https://github.com/bsless/clj-fast to unroll core functions for performance? It seems like almost a no-brainer to me to get some extra performance for free.

Ben Sless06:04:10

As the author (hi 🙂 ), I can think of a few: • bugs. You trust me and my library instead of clojure.core which is better tested and has many more eyes looking at it • load time. If you don't AOT compile your code namespaces will take longer to load and an application will be slower to start • API drift. If the API of any function or macro I implemented changes, I have to keep track of it, otherwise the implementation will become incompatible with time.

yuhan06:04:01

Hi and thanks for the reply 😄 I'm least worried about the last point given how famously stable Clojure's API has been over the years, and I see how macroexpansions can hurt load times although it's not a concern in my case. Hopefully this library gets more users / contributors to iron out any bugs!

Ben Sless06:04:28

I also copied tests from Clojure's core which helped me catch a few edge cases

yuhan06:04:48

I tried applying it to a portion of my code which deals with lots of nested maps, and immediately got a 35% speedup out of nowhere 😮 Always assumed that the JIT was optimizing away things like this in the background, but apparently simple macroexpansion-time analyses like this can have such a big effect

😮 3
Ben Sless09:04:38

It depends on a few things. First, the JIT needs some time to warm up. Secondly, there's only so much the JIT can do whenever iteration is involved. If you do lots of "get-in" you can't JIT away the iteration unless it's a pretty simple case, usually involving numerical computation

Ben Sless12:04:11

btw, I'm very curious about you you checked this

yuhan01:04:48

I actually wrote a small macro which uses clojure.walk to replace any function-head invocations with the inlned macros, then used it to wrap a few high-churn functions (according to the flame graph profiler)

(defmacro inline
  "Rewrites clojure.core fns in head positions
  to their inlined macro versions"
  [form]
  (let [mapping {'get       `inline/get
                 'get-in    `inline/get-in
                 'assoc     `inline/assoc
                 'dissoc    `inline/dissoc
                 'assoc-in  `inline/assoc-in
                 'dissoc-in `inline/dissoc-in
                 'update-in `inline/update-in
                 'merge     `inline/merge}]
    (walk/postwalk
      (fn [x]
        ;; Only replace if it's in function head position
        (if (seq? x)
          (if-let [[head & tail] (seq x)]
            (if (contains? mapping head)
              (cons (mapping head) tail)
              x)
            x)
          x))
      form)))

yuhan01:04:29

Total execution time went from about 7 seconds down to 5, I didn't use Criterium to measure rigorously but it was on a long-running REPL with I assume the JIT being fully warmed up.

Ben Sless06:04:50

Interesting. Thank you. Is that a one-off program? I'd be interested in seeing the run-time for a 100 executions before/after inlining, if you find time

grounded_sage08:04:37

Is there a tool for getting a diff of two large CSV’s?

pavlosmelissinos08:04:49

define "large" 😛 There's https://clojuredocs.org/clojure.data/diff Not sure if directly calling git diff --no-index a.csv b.csv would be faster/lighter

rakyi12:04:18

there is https://linux.die.net/man/1/comm but the files must be sorted

rakyi12:04:10

and of course the general diff

grounded_sage12:04:53

Probably a few million rows. But I’m thinking of a solution which could handle large datasets. Perhaps tech.ml.dataset is the solution. Bit of a sledgehammer though

wombawomba13:04:03

So I have a weird problem where Leiningen checkouts have stopped working since I made some of my (checked out) libraries .cljc instead of .clj. Basically, requiring some.lib-ns from some.other-lib-ns fails when some.lib-ns is in a .cljc file and is part of a library symlinked to checkouts in my project. However, I can still require that ns from a REPL just fine (i.e. (require 'some.lib-ns) works). Any idea what's going on here? Is there anything I can do about it?

wombawomba13:04:57

FWIW the error I get is

java.lang.Exception: namespace 'some.lib-ns' not found
clojure.lang.Compiler$CompilerException: Syntax error compiling at (some/other_lib_ns.clj:1:1).

vemv18:04:48

I don't think .cljc makes a difference at all lein checkouts basically places an entry into the classpath. You can debug it with e.g. lein classpath, or ps aux | grep java which will show your clojure process + its classpath

vemv18:04:22

if the desired folder is in the classpath, that allows you to rule out some things

manutter5116:04:02

Might be a problem with your indexes. Have you tried File -> Invalidate Caches / Restart... ?

tcrawley19:04:25

FYI: The work to require verified group names on Clojars has been released. See https://groups.google.com/g/clojure/c/cWG-V_4uv90/m/EDx0Fqn_AgAJ for more details.

6
👍 7