clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2021-01-02T00:00:17.263300Z

in fact, since they are just being used for side effects, the files they are in don't need ns forms, and you could use load instead of require

2021-01-02T00:00:34.263500Z

(that's not really a great design choice, but it would emphasize the role of that file)

emccue 2021-01-02T06:18:29.263800Z

Its also important to remember that the standard library has a policy of "if you give the wrong thing, who knows what will happen?"

2021-01-02T06:45:51.264200Z

If you use the map as a function, you get an error as well. That's what I do when I want it to fail if not a map

2021-01-02T06:47:21.264400Z

Granted, there's an off chance a different type also can be used as a function of one argument, but that's rare.

Timofey Sitnikov 2021-01-02T11:48:31.265700Z

Good morning Clojurians, have a question, if I had aliases with the same name in the global and project deps.edn, do the extra-deps get merged or replaced? For example: ~/.clojure/deps.edn:

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}}
         :aliases {:dev {:extra-deps iced-nrepl/iced-nrepl {:mvn/version "1.1.1"}}}}
~/clojure/my_app/deps.edn
{:deps {org.clojure/clojure {:mvn/version "1.10.1"}}
         :aliases {:dev {:extra-deps com.wsscode/pathom {:mvn/version "2.3.0-alpha17"}}}}
When running clj -A:dev, should clj merge, meaning include both the com.wsscode/pathom and iced-nrepl/iced-nrepl or should clj only use the extra-deps: map in the project folder, meaning it would not include the iced-nrepl/iced-nrepl? In my system it does not merge, but replaces with the project deps.edn, wonder if my system is not setup correctly to source global deps.edn.

dharrigan 2021-01-02T11:58:35.266500Z

My understanding that the project level is more specific, so it will replace the "root" level.

Timofey Sitnikov 2021-01-02T12:15:54.266800Z

Ok, that makes sense. Wish there was a way to merge, or globally include deps for :dev alias.

dharrigan 2021-01-02T12:16:18.267Z

I believe these things (and more!) are being discussed in #tools-deps 🙂

dharrigan 2021-01-02T12:16:48.267200Z

Things akin to merging etc...you can always ask there if you want to query something 🙂

pavlosmelissinos 2021-01-02T12:21:32.267600Z

For the record, (indeed) it seems like it does a shallow merge: https://github.com/clojure/tools.deps.alpha/blob/85d24dfbd6ef7221bc5a8cc63c1b0b16da828c52/src/main/clojure/clojure/tools/deps/alpha.clj#L135

Timofey Sitnikov 2021-01-02T12:30:13.268Z

@pavlos, thats interesting, I did not know about tools.deps.alpha. I am assuming that it will be part of the clojure once it is released?

pavlosmelissinos 2021-01-02T12:32:21.268300Z

You're already using it, it's what drives deps.edn files 😉

pavlosmelissinos 2021-01-02T12:37:41.268500Z

Not sure if it's a recommended approach but, as a workaround, you might be able to "simulate" the behaviour you want by using qualified keywords as alias names, e.g. https://github.com/practicalli/clojure-deps-edn/blob/65a48e1547d289a3d647d9f32bf3d2cc7fe8d5d3/deps.edn#L117 uses :env/dev In which case you could load the equivalent of clj -M:env/dev:dev in your REPL and have the dependencies of both aliases (I haven't tested it but I think it should work)

👍 1
Timofey Sitnikov 2021-01-02T13:05:40.269Z

I agree, it would work, but the challenge is with shadow-cljs. Although there may be command line arguments that I can use when starting shadow-cljs.

seancorfield 2021-01-02T18:00:32.269600Z

I really should rename some of the aliases in my dot-clojure deps.edn file so they don't collide with common names used in projects. @jr0cket’s approach is better there since he uses qualified alias names in his dot-clojure deps.edn file so they are less likely to collide. :dev is probably my worst offender.

practicalli-john 2021-01-02T18:11:30.269800Z

As mentioned, I use :env/dev and :env/test for the user wide alias. I find qualified aliases also provide more context, so it's easier to remember what the alias does.

seancorfield 2021-01-02T18:51:36.270200Z

I just updated my dot-clojure file to have :dev/repl to avoid conflicts (`:dev` still exists and is the same code, because it'll take a while for my muscle memory to catch up!).

seancorfield 2021-01-02T18:52:22.270400Z

(and my :dev/repl alias now works with Figwheel Main and can be used in combination with Reveal!)

Timofey Sitnikov 2021-01-02T19:35:23.270600Z

@seancorfield, do you use Figwheel? What about shadow-cljs?

seancorfield 2021-01-02T19:46:30.270800Z

I have used Shadow a bit, when I was hacking on Chlorine (the Clojure package for Atom). I'm very allergic to JavaScript so I want something less node-adjacent than Shadow.

seancorfield 2021-01-02T19:47:11.271Z

This week I started using Figwheel and I really like it. And re-frame.

Timofey Sitnikov 2021-01-02T19:52:30.271300Z

It seems like shadow-cljs is closer to deps.edn, I thought it was simpler? But I do see what you mean, most of figwheel is in clojure.

seancorfield 2021-01-02T20:03:47.271500Z

Although shadow-cljs can be used as a Java library, that's not the primary supported approach and folks are just like "Embrace Node.js! It's fine that Shadow uses npx/npm!" but I really don't want to go into the JS swamp if I can avoid it and Figwheel seems to keep me further away from that swamp 🙂

p-himik 2021-01-02T20:11:14.271700Z

FWIW going with shadow-cljs does not mean that you have to use NPM in your projects. It just means that you can use NPM to install shadow-cljs itself, that's it.

GGfpc 2021-01-02T20:18:53.272800Z

Has anyone used travisCI with with the clojure command line tools instead of leiningen? It keeps trying to run lein deps on my builds

seancorfield 2021-01-02T20:19:54.272900Z

@p-himik It means I have to have node etc installed -- which I don't want.

seancorfield 2021-01-02T20:21:19.273100Z

I don't know how much more clearly I can say "I do not want node.js on my machine!" 🙂

seancorfield 2021-01-02T20:24:37.273700Z

@ggfpc12495 Any reason to use TravisCI rather than CircleCI?

Timofey Sitnikov 2021-01-02T20:25:31.273800Z

Well, I chose shadow-cljs, because it was so active and popular (not the best way to make a choice) but looking at figwheel, it is a bit newer (first commit in April, 2018) and it looks like Shadow first commit was in October 2015!

GGfpc 2021-01-02T20:26:48.274200Z

I just use it because it's really easy to configure with github, would you recommend switching?

GGfpc 2021-01-02T20:27:12.274400Z

And it's free for private repos for students, at least it was when I first started

Timofey Sitnikov 2021-01-02T20:27:15.274600Z

Figwheel commits are more Clojure like, it seems more stable.

seancorfield 2021-01-02T20:32:19.274800Z

CircleCI is much more Clojure-friendly (the company uses Clojure). Don't know about the private repo integration tho'. There's also GitHub Actions -- which is what most of my project use now...

p-himik 2021-01-02T20:32:41.275Z

@seancorfield It wasn't an attempt to persuade you - it was an attempt to convey to others that Node won't "pollute" your projects (your statements above can be read as implying the opposite).

seancorfield 2021-01-02T20:36:41.275500Z

@p-himik Fair enough. Every time I mention anywhere that I'm using Figwheel, everyone immediately suggests Shadow and then seems to want me to justify why I'm not using Shadow. It's a bit annoying.

Timofey Sitnikov 2021-01-02T20:37:12.275700Z

@seancorfield did you notice reduction in start up time?

seancorfield 2021-01-02T20:37:45.275900Z

Start up time of what?

GGfpc 2021-01-02T20:40:59.276100Z

I'll take a look, thanks!

Timofey Sitnikov 2021-01-02T20:42:19.276500Z

For figwheel to startup. For shadow, from the time I type in shadow-cljs watch main to the time it all compiles it takes about a minute. When I am exploring projects, waiting a minute is annoying, I wish it was faster.

p-himik 2021-01-02T20:45:01.276700Z

@timofey.sitnikov Just in case, if you switch between the projects often, you can use the server mode to reduce the startup time: https://shadow-cljs.github.io/docs/UsersGuide.html#_server_mode

seancorfield 2021-01-02T20:48:21.277200Z

@timofey.sitnikov I tend to start a REPL and leave it running for days (or even weeks) so the startup time of the REPL doesn't matter to me. I've had clojure -M:reveal:fig:build:dev (a combination of the Figwheel aliases and my own dot-clojure stuff) running since Tuesday on my laptop 🙂

practicalli-john 2021-01-02T20:53:31.277400Z

Figwheel-main works for me, its simple to use and I dont need the features or added complexity of shadow-cljs, especially configuring the projects. Figwheel-main has a nice template to get started and as Sean mentioned, startup time is almost irrelevant during development. Figwheel-main recently added bundles for npm packages, so I'd probably look at that first before changing to shadow-cljs. Nothing wrong with shadow-cljs, its just not what I am familar with and I dont see the need to adopt it as yet. I might try shadow-cljs one day, but dont have any motivation to do so soon. Much more likely to spend time learning re-frame a bit more, as I have tooling that works already.

Timofey Sitnikov 2021-01-02T21:15:18.277600Z

@seancorfield, Understand, that makes sense.

Timofey Sitnikov 2021-01-02T21:18:36.277800Z

@jr0cket, the words simpler resonate with me, I am a neovim/tmux/terminal type of a guy, love to keep things simple and minimize the abstraction layers. I will have to give figwheel a try.