Fork me on GitHub

[:app] Configuring build. [:app] Compiling ... To quit, type: :cljs/quit [:selected :app][:app] Build completed. (551 files, 1 compiled, 0 warnings, 6,73s) No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. Happens right after starting emacs and issuing cider-jack-in on a project that works fine and just fidling around in a .cljs file. So weird.


neither emacs restart or os boot fixes the issue


That’s a cljs repl starting up. It’s basically a jvm program that evaluates your cljs output in a JavaScript engine. It’s saying all is ready but you need to connect to a JavaScript engine. Usually by loading your app in a browser or running node on your generated cljs script

Michael Stokley05:02:43

is there a naming convention to indicate that a given var might be nil or absent?


A point of terminology, a var is something created by a def, a global definition, those are pretty much never nil


A name bound by let or a function in clojure is called a local, and those are indeed sometimes nil

👍 1
Michael Stokley05:02:37

in scala we're always so explicit about values we expect to always be present and values we might reasonably expect to be missing - does lisp/clojure have a similar approach?


So, the way its done in Clojure, is that absence is represented by the key being missing from the map


You can do that, because of how dynamic the data constructs are


So you have two concepts. First is the data is missing, that would be represented as the key isn't even there. The next one is, the data is there, but its value is nil. That would be represented with the key being there but having a value of nil


So say you had person maps, and sometimes those have a name and an address, sometimes only an address.


You would have:

{:name "Joe" :address "123 bla"}
And if its a person without an address:
{:name "Joe"}
And if its a person where an address was given, but it was garbage, or it was submitted as blank, or the user ticked the box saying "rather not say" you'd have:
{:name "Joe" :address nil}


Oh, and to specify the semantics of a particular map, Spec would be used. You can say which key are mandatory, which are optional, and which are allowed to be nil or not


Though sometimes, simply doc or comments are used, or even its just not specified if its kind of obvious from context


@michael740, I have not seen any such convention in Clojure code.


I have a failing test inside a cljc file, when I run lein test it does not catch the error. But in the console I see that the file was tested. I should do something different in the setup of clojure.test for this situation?


@iagwanderson Not sure I'm following you -- but it seemed to work when I tried it

(! 779)-> lein new app bartuka
Generating a project called bartuka based on the 'app' template.
(! 780)-> cd bartuka/
(! 781)-> mv src/bartuka/core.clj src/bartuka/core.cljc
(! 782)-> mv test/bartuka/core_test.clj test/bartuka/core_test.cljc
(! 783)-> lein test
lein test bartuka.core-test

lein test :only bartuka.core-test/a-test

FAIL in (a-test) (core_test.cljc:7)
FIXME, I fail.
expected: (= 0 1)
  actual: (not (= 0 1))

Ran 1 tests containing 1 assertions.
1 failures, 0 errors.
Tests failed.
(! 784)-> echo $?
(! 785)-> 


that's exactly the problem. But, if yours is working fine, it should be a problem with my current setup


I have added :test-paths ["test/cljc", "test/clj"] to my project.clj and nothing else 😕


how do you know it is failing? Is it possible only a cljs branch fails and you aren't running tests in that environment?


found it! Look at the next example, when I use the use-fixtures it passes with 0 failures.

(ns mamulengo.bartuka
  #[email protected](:clj
      [(:require [clojure.test :refer [deftest is use-fixtures]])]
      [(:require [cljs.test :refer-macros [deftest is use-fixtures]])]))

  {:before (fn [] "ok")
   :after (fn [] "go")})

(deftest please-work!
  (is (= 0 1)))


the api of use-fixtures is different for both environments. I would expect some error.


actually, it seems like the test was not even recognized, which makes sense because it breaks before. Only hard to catch


Ah, yes, the Clojure code -- run by lein test -- would try to invoke that hash map as a function, passing in the test to be executed.


so it would run ({:before,,,} please-work!) which will "run" but not call please-work!


because that's (get {:before,,,} please-work!) which just returns nil


I'm surprised use-fixtures differs between Clojure and cljs like that...


yes, right? This one was tricky.


thanks for the help!


If you write a function that accepts a test function as an argument (and calls it), that will work for both clj and cljs.


Supporting that :before/`:after` format would be a nice enhancement for clojure.test.

clj 1

I like how readable this approach is


I'll go ahead and implement this in expectations.clojure.test tho'...


also, just minor thing but [clojure.test :refer [deftest is use-fixtures] should work in both environments. don't need to reader conditional that one


I didn't know that. I thought I needed the reader conditional because of the macros.


cool! Thanks!


Hello there, What do you guys use to set up a rest api? I have seen people use Compojure and Ring but would like to know if it is the best option


best options are hard to tell rsrsrs. I like reitit now o/// #reitit


Okay, maybe best options is a little too much to ask, my bad hehe I'll give this one a look, thanks!


I use reitit too


For what it's worth, I've put up a little twitter bot that tweets a random clojure function of the day. You can find it here: It's new, doesn't do anything clever, but it's kinda cute 🙂 Enjoy!

👍 6

That's quite useful actually. Sometimes I forget the less used fns.


I swear I didn't see that thing before I wrote the script 🙂


It was a massive co-incidence!


I saw your posts too and I was like "wow!"


I did see the idea here before:


In the definition for comp there’s a block for composing two functions. I’m wondering why it handles 1, 2, 3, and n arguments differently. Couldn’t it just use apply for any length?


it is a performance optimization


Ah okay.


So apply is slow?


not slow, just slower


@tylertracey09 If you look at the source of several core functions, you'll see a similar "unrolling" of the first few arities -- as a performance optimization.


Good to know.


Can anyone recommend me a clojure book for learning purposes? I do best when I have some exercises to do as well


@tylertracey09 There's Clojure for the Brave and True (available for free online as well), Getting Clojure, Living Clojure -- those are the three that come to mind. Not sure which of those actually have exercises in them.


For exercises, 1) Clojure Koans and Exercism for basic staff, 2) 4clojure for slightly harder puzzles.


Might be just me, but as I know another language already (Java), the 1) Guides and 2) References section on were excellent resources for me. Books were too slow.

Behrokh Farzad20:02:32

has anyone had a problem with downloading tools.deps in IntelliJ IDEA settings? I keep getting the following error Cannot execute, please download tools.deps in Settings: Cannot execute, please download tools.deps in Settings


Hi Behrokh, not sure if you already solved the issue, but it's a problem with Cursive and it's fixed in EAP only. If you don't want to download that, you can fix like this: Go to Build Tools -> Clojure Deps: Use private repo: ID: Central / URL: Then refresh and download.

👍 2

thanks @U7JCZJR0W I was suffering the same.

Behrokh Farzad19:02:27

thanks @U7JCZJR0W it’s working now.

Guillermo Ithier20:02:11

Hello Clojurians, I'm having a problems getting access to a zero-token through a POST so that I can use it in my buffer to perform an authentication request. Now the URL here's the link ; following along a video 'Microservices with CLojure'.  I'm lost on how to use this site to create a way to well, access to a zero-token through a POST so that I can use it in my buffer to perform an authentication request. Here is the relevant functions that calls the outdated api: (defn auth0-token []
  (let [ret
        (client/post ""
                     {:debug false
                      :content-type :json
                      :form-params {:client_id (System/getenv "AUTH0_CLIENT_ID")
                                    :client_secret (System/getenv "AUTH0_SECRET")
                                    :grant_type "client_credentials"}})]
                                  (json/parse-string (ret :body))))


People might be able to help more if you describe what is and isn't working. When you run your code what does it do that you didn't expect? What do you want it to do?

Guillermo Ithier20:02:43

Can someone help me with this? Thank you in advance 🙂


I imaging (:headers ret) will have some info there


Is emacs the go to for clojure?


if you already know emacs yes. if you're just learning clojure you probably don't want to start learning both emacs and clojure. in which case I personally recommend Cursive for IntelliJ. Some others like VSCode with Calva and Atom


@tylertracey09 If the editor/IDE you are already using supports Clojure, I'd stick with that while you are learning Clojure. What are you using now?


I use VSCode


Really all I want is to be able to evaluate an expression in line


I guess that’s what folks use the REPL for, but I saw a screencast where the guy was using emacs and he had a command that would evaluate the expression under the cursor or something


calva with VSCode can do that


Oh neat I will check into it, thanks


I think I’m using a different plugin atm. I will try Calva instead

Nate Sutton23:02:03

there are editor-specific channels on here too if you run into issues

Nate Sutton23:02:25

there's an emacs channel and I'm pretty sure there's a calva one

Nate Sutton23:02:09

emacs is fun but it's a big investment of time. I use it and like it but I generally don't recommend people use it unless they're interested in the editor itself


Out of curiosity if you use emacs were you using it before clojure? I remember reading something about how emacs was implemented with a LISP and so you can write extensions using LISP as well. Is that what got you folks into it or did you migrate because of clojure tooling at the time?


I used Emacs decades ago, back in the 17.x/18.x days. I moved away from it round about 19.x I think. I started using C++ IDEs then Java IDEs. Eventually, after a bunch of languages, I ended up in Clojure and went back to Emacs because it was the "best" / "most popular" -- and was shocked that it hadn't changed much in... twenty years?


I went back and forth between Emacs and other editors for a while, when learning Clojure, then settled on Emacs... until I saw Atom/ProtoREPL at Conj one year! I switched to Atom and never looked back. ProtoREPL is no longer maintained (and I think it's actually broken in recent Atom releases?) but I switched to Chlorine over a year ago and I love that combination (Atom/Chlorine, plus Cognitect's REBL data browser, with a simple Socket REPL -- no nREPL etc).


curious, why not the socket prepl?


@U4R5K5M0A I think Chlorine starts a prepl once it has a plain socket connection.


The socket REPL is nice because you can a) telnet/netcat to it from your phone b) connect to it via unrepl/unravel c) connect from Chlorine ...

Nate Sutton23:02:06

it's not like switching from vscode to sublime or atom or even intellij, it's quite alien


it is a time machine

Nate Sutton23:02:25

I was using vim and I got sick of broken plugins and a terrible extension language (vimscript). I moved to spacemacs and then to doom emacs


I'm honestly not sure how much knowing clojure would help you writing Emacs Lisp. they're dramatically different


visiting an alternate future branched off from this world in the 70s


I wrote a heartfelt cover letter to David Nolen and the other folks over at Vouch. Here’s hoping I get the chance to learn from some experienced clojure developers