This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (3)
- # beginners (128)
- # boot (2)
- # braveandtrue (97)
- # calva (13)
- # cider (4)
- # cljdoc (12)
- # cljs-dev (16)
- # clojure (78)
- # clojure-germany (8)
- # clojure-italy (5)
- # clojure-nl (1)
- # clojure-spec (59)
- # clojure-uk (29)
- # clojurescript (46)
- # core-async (9)
- # cursive (63)
- # data-science (3)
- # datomic (22)
- # devcards (1)
- # duct (7)
- # emacs (4)
- # flambo (2)
- # fulcro (37)
- # instaparse (6)
- # jobs-discuss (38)
- # juxt (1)
- # off-topic (35)
- # om-next (1)
- # parinfer (7)
- # re-frame (14)
- # reagent (6)
- # reitit (21)
- # rum (1)
- # shadow-cljs (74)
- # spacemacs (8)
- # specter (1)
- # sql (3)
- # testing (2)
- # unrepl (2)
- # yada (6)
Hi, what is the recommend way of setting things like print-length automatically at repl startup? I'm using deps.edn.
Hi. I just discovered Clojure (again). This time I really want to give it a try! I am comming from the front end and mostly work with TypeScript and Vue.js at the moment.
Which editor or IDE is good for beginners? At the moment I am am doing everything I can with VSCode.
Does it make sense to learn Clojure without having any knowledge of Java to speak of? Last time I got quite some tracebacks talking Javarish when someting did not work correctly.
As an also beginner, I’ve found lein and vs code good for me. My coworkers recommend spacemacs as an editor, but that seems like overkill for me rn.
A frequently-recommended tutorial would be Clojure for the Brave and True, available online (https://www.braveclojure.com/) and in book form. There’s also a #braveandtrue channel on this slack specifically for people working through that tutorial
There are several good editors: I use IntelliJ with the Cursive plugin, others are using Atom with the appropriate plugins, and I think there’s a Clojure plugin for VSCode? Maybe, not sure on that one.
For front end work I recommend re-frame, which is built on top of Reagent. https://github.com/Day8/re-frame. Re-frame has a fairly thorough README, but don’t let that fool you, the real docs are in the
/docs folder. Also be sure to read the todomvc example in the
/examples folder--there’s a bunch of extra documentation in the comments that’s worth having.
I use Leiningen for pretty much everything, never made the jump to Boot. I have heard some say that Boot is better for CLJS stuff, but I’ve never been motivated enough to try it out. One thing in Lein’s favor is that there’s a bunch of people who know it and can help out if you have issues.
If you’re mostly developing front end stuff, the Java side shouldn’t be too much of an issue (I have a site in production now that is CLJS exclusively, no Java anywhere). But if you do run into problems feel free to ask and to post stack dumps in snippets and someone will likely have a look and see if they can help out.
For VSCode, try @pez excellent Calva: https://marketplace.visualstudio.com/items?itemName=cospaia.clojure4vscode
I highly recommend trying out #parinfer if you haven’t already. It juggles brackets and indent levels for you using clever mathematics. The #parinfer devs are bumping into problems of inflexibility with VSCode that’s slowing down progress on the latest version of parinfer for VSCode (though an older version is available). Were it not for that, I would give VSCode a serious go.
If you’re willing to give Atom a go, proto repl is a very nice environment for exploring the output of functions. You can see a demo here: https://atom.io/packages/proto-repl
VS Code is where the issues reside. We have been working on it through out the month
@UB9RVULMA Kudos on the hard work! It’s a shame that VSCode isn’t more flexible than it is.
Thanks for the Calva shout-out! Anyone who does everything in VSCode should try it out. 😍 In waiting for Parinfer, the combo of Calva Formatter and Calva Paredit works pretty well (in my, biased, opinion).
with regard to the
^:private metadata tag: it looks like this hides functions from unit tests. how do folks conventionally balance the need to unit test and the need to hide implementation details?
#'var-name will let you grab the var. you can test it even though it is private. I think there are some languages that let the runtime know that the test code is privileged in some manner and you don't need to do this.
@michael740 Conventional wisdom for other languages is that you shouldn't be testing private implementation details in the first place, and I don't see why it would be different in Clojure.
that doesn't seem very wise to me. you should absolutely test private things that aren't shown to outsiders
if a public interface relies on an implementation of shortest path through a graph you can and should write some tests around your graph traversal
if there's lots of private functionality to get the public api to work, why leave it untested. and then if there is a bug in your graph traversal your unit test for the public api would just say some nonsense error and not help you. why wouldn't you want confidence in the edge cases of private implementations
further, the input to the api to hit edge cases in private functions might be quite annoying to put in the test but the input to the private functions could be trivial to probe the edge case
If those edge cases are never hit with the public code, why do you care? Test behavior, not implementation.
> if there is a bug in your graph traversal your unit test for the public api would just say some nonsense error This is the situation I find myself in now. I couldn't debug my main function, so that seemed like a sign I should decompose it
do you think having everything exposed publically could confuse clients of your package?
because there may be some helper functions there that don't make sense / aren't useful outside of the context of your implementation
@pez Anything I should know to get ANSI colors in VSCode's terminal when running the REPL (or lein, for that matter)?
You mean syntax highlighting of clojure code? If so, no, that is not anything that Calva can help with atm. Do you have it working in done other terminal?
Lots of clojure tools output ANSI escape codes to colorize the output. For instance "lein cljsbuild once min" compiles your code and the last line it prints out is a "Successfully compiled" message in green. Or, it would be if the console supported ANSI escape codes.
I know Calva doesn't do anything with the console, but I figured if you work in VSCode you might know the answer here.
VSCode is supposed to handle ANSI escape codes according to some google searches, but they show up as funky characters in my output by default.
In Win10 the console also supports them, but I get the same result. But, to use them there a special mode needs to be entered by the application, and I guess lein doesn't bother with this.
The lein README suggests using ansicon, which is a bummer since the console should support it anyway, but I installed it.
Works fine in my PowerShell console, but it's messed up in VSCode. Does produce colors, but afterwards the colors are all out of whack (I get a pink background until I start to type... really ugly).
That "boolean?" warning is a different matter, but this shows how ansicon and VSCode aren't playing nice for me.
I am getting an error
No reader function for tag object when I call this function
(read-string my-str). Does anyone know why I am getting this error?
that might be a record literal vs a tag literal, I forget exactly how the reader discriminates between the two
but the reader might first attempt the record literal, then tag literal, so the error you get for a missing record literal is that tag literal error
A philosophical question: to pass atoms and channels down my functions? or to lift values out into monads? or have a stream topology, where information flows and triggers callbacks?
Hi guys, any idea why this doesn’t work:
lazy data is realized by accessing it - this could be as simple as printing or counting it
reduce doesn't call f if you supply no initial item and there's only one item in the coll
but I don’t get why if that mapping partial reduce works, then why doesn’t take 1 then reduce work
because reduce doesn't call your function if you supply no starting value and there's only one item in the coll
(reduce * (take 2 (partition 4 number-list))) ClassCastException clojure.lang.LazySeq cannot be cast to java.base/java.lang.Number clojure.lang.Numbers.multiply (Numbers.java:148)
* is one of those cases where partial and reduce do the same thing in the two argument case
simply mapping over a collection of collections does not work because does not work with collections
(map * [1 2 3]) gives the same result as
(list (* 1) (* 2) (* 3)) - although I may be fudging a bit with the
list part there
I was specifically talking about (map * [1 2 3]) - that returns the lazy-seq (1 2 3)
okay so is
(map #(apply * %) (take 2 (partition 4 number-list))) is the same as
(map (partial apply *) (take 2 (partition 4 number-list)))
what’s the right idiom if I wanted to simulate a “moving-window” of 4 digits?
For example, thinking in non functional (’cause that’s where my brain is at), I would:
(partition 4 number-list)
(partition 4 (drop 1 number-list)) and so on until
then if I appended all that together my map apply * would give me the largest product of any 4 consecutive digits
or I could use tail recursion and an accumulator that eats another digit to make a 4 digit window
partition takes a step argument so you can do
(partition 4 1 number-list)
boot.user=> (partition 4 1 (range 15)) ((0 1 2 3) (1 2 3 4) (2 3 4 5) (3 4 5 6) (4 5 6 7) (5 6 7 8) (6 7 8 9) (7 8 9 10) (8 9 10 11) (9 10 11 12) (10 11 12 13) (11 12 13 14))
what would be the cons to using something like HugSQL vs just writing regular Clojure queries or having some other type of SQL query file?