Fork me on GitHub
#events
<
2021-01-13
>
bruno.bonacci10:01:47

Hi all, please the recording of "REPL-Driven Development - Clojure's Superpower by @seancorfield" is available on our YouTube channel: https://www.youtube.com/watch?v=gIoadGfm5T8

👍 75
💯 12
dharrigan11:01:12

It's only showing 360p, quite fuzzy

yogidevbear12:01:46

Shows 1080 for me now. Might just have been YT processing the video after initial upload.

yogidevbear12:01:35

Thanks @seancorfield for doing the talk and thanks @U0LCHMJTA for hosting, recording and sharing 😄 💯

bruno.bonacci12:01:27

@U11EL3P9U It takes a few minutes after a new upload of a video for YouTube to postprocess the HD video. It should be there now

dharrigan13:01:09

ah, perfecto! 🙂

Chase18:01:16

@seancorfield Is this where we can ask more questions about the video? I've been trying to explore reveal more too so want to follow along with you.

Chase18:01:22

I'm looking at your dot-clojure repo. So I think what's happening is that in you called the :reveal and :dev aliases at the command line.

Chase18:01:05

The :dev alias actually calls out to this dev.clj file which is where all those other reveal options are coming in from. Is that correct?

Chase18:01:31

So to recreate I would create that dev.clj file and throw it next to my deps.edn file?

seancorfield18:01:41

Probably easier to follow-up either in #tools-deps or via DM but I guess some of this deserves a broader audience...

seancorfield18:01:54

The dot-clojure repo has a whole bunch of (opinionated) tooling that works together. The dev.clj file lives in that repo -- i.e., it goes into your .clojure folder with the (user) deps.edn which is assumed to contain all the various aliases I regularly use.

seancorfield18:01:51

:dev (and now, preferred, :dev/repl) is an alias that uses :main-opts to load the dev.clj script. :reveal pulls in Reveal and would run it as well, if it were the last alias on the command-line that contained :main-opts.

seancorfield18:01:52

To explain that: when you use multiple aliases, their bodies are combined. Mostly they are merged: either a merge of hash maps or a conj of vector contents (`:jvm-opts`) but with :main-opts it is "last one wins" so only one alias's :main-opts end up being used.

seancorfield18:01:18

clj -M:reveal would start Reveal as the main REPL. clojure -M:rebel would start Rebel Readline as the main REPL. clj -M:reveal:rebel will start Rebel Readline but also make Reveal available as a dependency -- because the :main-opts for :rebel "wins" by being the last alias.

seancorfield18:01:09

clojure -M:reveal:rebel:dev/repl uses the :main-opts from :dev/repl as the last alias to have any main opts, so Reveal and Rebel Readline are on the classpath but their -main functions are not called. The code in dev.clj runs, looks at what is available via the classpath, and decides which REPL to start up and how to combine the various utilities.

Chase19:01:38

Mostly! Still wrapping my head around the last alias wins. Is it only in the case of a conflict that it wins because otherwise why use more than one alias.

Chase19:01:55

Oh wait, so only the :main-opts part pertains to this last one wins.

seancorfield19:01:52

(one important thing to note is that my :dev & :dev/repl aliases will not work on an XDG system because they assume $HOME/.clojure -- on an XDG system that's most likely to be $HOME/config/clojure as I recall)

Chase19:01:51

Yep, $HOME/.config/clojure

Chase19:01:29

So your :add-libs alias has a :main-opts section and you still use that even though it's not the last alias you call

seancorfield19:01:55

Several aliases have :main-opts but those options are not used if a later :main-opts is present. The aliases still bring in the specified dependencies.

Chase19:01:29

ahh, ok, so you are using everything in the :add-libs alias except for the :main-opts

seancorfield19:01:58

With :add-libs it's just a bit of "magic" to ensure a DCL (DynamicClassLoader) context for any REPL that is started -- but my dev.clj also contains that code.

Chase19:01:50

Yeah, I'm trying to parse your dev.clj to see if I can yank it wholesale or if it's going to conflict because I'm using cider nrepl vs your socket approach. hahaha

Chase19:01:43

So basically whatever alias that will have the call to this dev.clj file has to come last right. My apologies if I'm being super dense about this.

seancorfield19:01:49

The issue I'm working around with that DCL stuff is that a Socket REPL does not use a DCL context (and neither did Cognitect's REBL). Now that I have dev.clj, any Socket REPL started by it will have a DCL. But I left it in :add-libs (and :rebl) so that I can start a more barebones REPL and still have the DCL context that add-libs (the function) needs.

seancorfield19:01:16

Yes, clojure -M:lots:of:aliases:and:then:load-dev.clj

Chase19:01:01

Cool, I will try to pilfer what I can. I use your's and practicalli's. That install-reveal-extras function is a bit intimidating but I think I want it. Haha.

Chase19:01:38

I kind of wish it was just an option to throw in to the reveal main opts. "corfield-reveal-extras" or whatever

Chase19:01:20

And so you aren't getting any of the :main-opts from :test either? Hahaha, this seems to be tripping me up. I'm assuming the main opts just aren't that important.

seancorfield19:01:58

:runner is the alias I use to run tests. :test just brings in some useful stuff.

seancorfield19:01:39

;; testing and debugging tools (this would normally be overridden
  ;; by a :test alias in the project deps.edn file -- but it's a
  ;; useful default):
  :test {:extra-paths ["test" "src/test/clojure"]
         :extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}}
:test has no :main-opts

Chase19:01:17

got it! Awesome. The more I use these tools the more I like them but it definitely takes some tweaking

seancorfield19:01:43

It's like a set of LEGO bricks!

Chase19:01:00

Well put.

Chase16:01:00

@seancorfield I'm back! During your "testing" demo I love that are able to run your tests from your source file and seeing it in Reveal. It was fun seeing @U05254DQM's response too.

Chase16:01:39

It seems you are saying you use - t so it seems to be an editor thing? What exactly does that run? Should I check with my editor tooling or cider tooling (I use a cider nrepl with vim/conjure) to get that setup?

practicalli-johnny17:01:53

@U11EL3P9U so called standard definition video for YouTube uploads are available straight away. It take several hours to process full HD video of this length. (This is one reason I stream the Practicalli live broadcasts)

seancorfield17:01:03

Not sure what you mean about - t ?

Chase17:01:30

It sounds like you are saying "I hit the hotkey dash test"

Chase17:01:50

And then you get the results in a Reveal window

Chase17:01:11

"side-running" Is that what these test runners are?

seancorfield17:01:56

Ah, right. I have three hot keys bound to running tests: * ctrl-; t -- runs just the test under the cursor (i.e., you have your cursor on the name of a test in a test namespace) * ctrl-; x -- runs all tests in the current namespace (so you're editing a test namespace) * ctrl-; X -- runs all tests in the associated test namespace

seancorfield17:01:06

I think the latter is what you're referring to?

Chase17:01:23

So when I go back to my own editor tooling I should be looking for whatever command calls the "associated test namespace"?

seancorfield17:01:35

The code behind that looks at the current ns, say foo.bar, and then tries to require foo.bar-test (and if that fails, it tries foo.bar-expectations, which is a convention for Expectations users like me), and if the require succeeds, it then runs all the tests in that associated namespace.

seancorfield17:01:05

I don't know how (or even if) CIDER supports that out of the box -- check its (copious) docs and/or ask in #cider

seancorfield17:01:53

I would be surprised if CIDER did not support that -- and I would expect Cursive would also support this -- but I don't use CIDER or Cursive.

Chase17:01:07

Will do. Thanks Sean

seancorfield17:01:28

If you’re in an implementation namespace (e.g. some.ns), CIDER will try to find a matching test namespace (by default some.ns-test) and run the tests there.

If you’re in something that already looks like a test namespace (e.g. some.ns-test), CIDER will simply run the tests in that namespace.

Chase17:01:29

Ahh, you don't have to look that stuff up for me. ty!

seancorfield17:01:59

Your question made me curious. Now I know the answer and can respond to others who ask that question 🙂

Chase18:01:19

Looks like my editor tooling does have it built already as well!

Chase19:01:59

So I'm trying to pilfer your reveal extras. I cut your dev.clj file down to just the install-reveal-extras function and edited my deps.edn reveal alias to this:

Chase19:01:11

:reveal {:extra-deps {vlaaad/reveal {:mvn/version "1.1.171"} nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.5"} com.bhauman/rebel-readline {:mvn/version "0.1.4"}} :jvm-opts ["-Dvlaaad.reveal.prefs={:font-size,20}"] :main-opts ["-m" "nrepl.cmdline" "--middleware" "[vlaaad.reveal.nrepl/middleware,cider.nrepl/cider-middleware]" "-i" "-f" "rebel-readline.main/-main" "-e" "(load-file,(str,(System/getProperty,\"user.home\"),\"/.config/clojure/dev.clj\"))"]}

Chase19:01:42

I hope that is readable. But I don't seem to be getting any of those extras that you show in your video.

Chase19:01:00

So I suspect something is being pulled in or added in your start-repl function for reveal huh?

Chase19:01:02

Ahh yep, "If Reveal is picked, add some custom code to automatically display tap>'d values with metadata and in table view." I will see what I can do to pull that out of there. I'll leave you alone now. Haha. Great video btw!

clyfe11:01:37

Is it just me or that's 360p for everyone? Can hardly see the code.

bruno.bonacci12:01:51

It takes a few minutes after a new upload of a video for YouTube to postprocess the HD video. It should be there now

👍 3
bruno.bonacci20:01:26

Intrested in Kafka, Clojure and Distributed Systems?? Sign up for this talk https://www.meetup.com/London-Clojurians/events/275730307/

yes 39
3