Fork me on GitHub

Hi all, please the recording of "REPL-Driven Development - Clojure's Superpower by @seancorfield" is available on our YouTube channel:

👍 75
💯 12

It's only showing 360p, quite fuzzy


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


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


@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


ah, perfecto! 🙂


@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.


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.


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?


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


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


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.


: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.


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.


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.


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.


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.


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


(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)


Yep, $HOME/.config/clojure


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


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.


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


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.


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


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.


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.


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


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.


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


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.


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


;; 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


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


It's like a set of LEGO bricks!


Well put.


@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.


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?


@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)


Not sure what you mean about - t ?


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


And then you get the results in a Reveal window


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


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


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


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


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


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


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.


Will do. Thanks Sean


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.


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


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


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


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:


: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\"))"]}


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


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


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!


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


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

Intrested in Kafka, Clojure and Distributed Systems?? Sign up for this talk

yes 39