This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-09
Channels
- # asami (10)
- # babashka (11)
- # beginners (24)
- # braveandtrue (1)
- # cider (4)
- # cljs-dev (4)
- # clojure (88)
- # clojure-europe (19)
- # clojurescript (6)
- # code-reviews (7)
- # conjure (2)
- # core-async (2)
- # css (3)
- # cursive (11)
- # expound (81)
- # fulcro (2)
- # hoplon (1)
- # off-topic (42)
- # pathom (1)
- # re-frame (5)
- # shadow-cljs (17)
- # spacemacs (25)
- # testing (6)
- # tools-deps (3)
- # xtdb (12)
Hi, I think I need a clarification on when code is executed. I have defined a spec
in namespace A, I defined some data in namespace B and am using s/conform
to see if it adheres to the spec. Then I use some of the values of namespace B in core
. But when I change the spec, I get no errors from the conform
statement. Could you shed some light on when code is executed (this is cljs running on shadow-cljs)?
thinking about it, maybe the code is executed, and just returns invalid
, and I go on from there. I have to see how to throw errors
I don't recall anything in spec throwing. There are some functions for returning error information however. s/explain
will print to *out*
while s/explain-data
will give you a map with information about the failure, which you could then use to throw an exception, if that is the behaviour you need
Hello, newbie here 🙂. Is anyone here using intellij (with cursive) for clojure dev? I have a question about it. I have ran a repl for my project by right-clicking on project.clj and I can interact with it just fine. Now when I edit files under src/myproj/core/clj (add a function for example), how do I get that function into the repl? I’m unable to find a proper shortcut combination.
also check out #cursive
Nice, thank you.
Hi guys! I’m looking for good references on big projects using a dynamic language like Clojure. Things like refactoring, tests, bugs, etc… I’m starting with Clojure coming from Go and the dynamic thing is kinda of a worry for me.
Discipline, good design, good test coverage, good variable names, documentation on functions and vars, always be using the REPL, that's mostly how
There's some refactoring support in editors, but I consider those "easy" refactors, harder ones where you change things in backward incompatible ways the editor won't do those for you 😛
Getting comfortable with the repl driven development approach should remove most of the concerns you have. It is a relatively small but very significant change to the development workflow. https://practicalli.github.io/clojure/repl-driven-devlopment.html As mentioned, static analysis tools like clj-kondo also give valuable support to the development workflow
you will rely first and foremost on your brain, not on tools, so optimize for that (what didibus said)
I also suggest using some schema lib (clojure spec, plumatic schema or malli) to check and document the format of data at module boundaries
A disadvantage of clojure is that the 'shape' of the data is not always clear. In go/java/haskell etc it's easy to find out which fields the data has (just check the class of datatype definiton)
With clojure you can create a mess where everything is 'just maps' but it's hard to figure out what the fields are. Annotating these with schema, spec of malli at critical points helps a lot to prevent this.
It's not as good as static typing, but it mitigates some of the downsides of the dynamic nature of clojure
@diego.bernardes you may want to have a look at the book "Clojure, Applied", I found it very useful when going from having learned Clojure to needing to build something real world https://pragprog.com/titles/vmclojeco/clojure-applied/
I have the Getting Clojure on the way, I’ll take a look on your recommendation too 🙂
It's from 2015, do you feel it is still relevant?
@UHY8MH6KC apologies for not replying earlier. I dug out my copy and thumbed through, and did not see anything that appears dated. The usefulness will differ from person to person so I'd take a look at the table of contents and see if they are topics that are of use.
I have the Getting Clojure on the way, I’ll take a look on your recommendation too 🙂
@diego.bernardes Although it doesn't catch everything, many people, including me, find it useful to enable a linter in the editor and/or in CI: https://github.com/clj-kondo/clj-kondo (disclosure: I'm the author of this tool) This can find many "silly" bugs without even running the code. That in combination with a good test suite (which you should have anyway) and good QA practices, should help a lot. Clojure also has clojure.spec and several other data validation/conformation libraries that can help at runtime, but will require you to do extra work (write the specs) if you want more robustness.
There is also editor integration like clojure #lsp (for Calva/VSCode, emacs, ...) and CIDER which can help you find references, rename, etc.
Getting comfortable with the repl driven development approach should remove most of the concerns you have. It is a relatively small but very significant change to the development workflow. https://practicalli.github.io/clojure/repl-driven-devlopment.html As mentioned, static analysis tools like clj-kondo also give valuable support to the development workflow