Fork me on GitHub

which cljc file are you referring to?


There don't seem to be any cljc files in src


One you write yourswlf


Can I build Java source code with tools.deps? That is, I have some .java files in my deps.edn project, and I'd like to build them so the clj code can access them.


No you can't do that


A shame... Thanks for the link though! I am in fact migrating a lein project to tools.deps, but since it's a clj/java mixed project I think I'm out of luck 😔


Ya, in theory someone could build a tools.deps based alias that can compile Java source. Tools.deps itself is not a build tool, it only handles dependency management. But with aliases, people have built build tasks as small Clojure programs that you can call with an alias and which automatically get access to your project's classpath


So all "build" tasks available to tools deps today are unofficial and community provided.


I'm fact, you can even use lein with tools.deps, where tools.deps provides lein with the dependencies instead of having lein manage them, and lein is thusnused for build tasks


To be fair, I'd be more than happy with a community solution to this problem... 😅


I tried the lein plugin for tools.deps, but it didn't work for me with local deps, so I gave up. I'll give it another go though!


You can compile .java with javac and add compiled .class files as :paths [… "java_sources"] into deps.edn


But is there a way I can provide javac with the right classpath? Or do I need a separate infrastructure to resolve the dependencies and invoke javac with the right arguments?


clj -Spath is printing out class-path


I see.. thanks!


I have never used it, but this tool claims to support compiling Java sources in a project using deps.edn:


i like badigeon -- but there are also other options among the following list iiuc:

Alex Miller (Clojure team)11:04:52

We are working on a new that will do this as well


sounds exciting 🙂


Thanks all for the answers! 😄


@dpsutton I created my own cljc file called myapp.env in my cljc directory, in which I imported (:require [myapp.config :refer [env]], but I get the error: The required namespace "myapp.config" is not available, it was required by "myapp/env.cljc". "myapp/config.clj" was found on the classpath. Should this be a .cljs file?


I always feel circleci be a show-muscle of clojure in real world. however, yesterday I stumbled upon this post from the founder of circleci, who claims it will never use clojure, . thoughts?


The co-founder and ex cto of circleci just started a new project with clojure (griffin bank), I guess "your mileage may vary" applies here.


"my previous startup" doesn't imply they're the founder of circleci?


who said that's how they figured out who authored that


Paul Biggar is a founder of CircleCI now at darklang, and this person's account name is pbiggar

👍 4

then using OCaml for backend services is being brave. Be ready to reinvent a lof wheels, the ecosystem is not big


I love the language, but that's it


yeh that's what I was thinking, although not from experience as much as that's the impression I get everytime I look into trying anything with OCaml


it's #off-topic stuff, but lack of decent multicore support, most db drivers are not up to date or seriously lacking, conflicting async or even Core libs/lingo, poor tooling etc etc


the list goes on


(my experience is from a couple of years ago, but I doubt a revolution happened)

Mitch Dzugan13:04:03

Very confused about this

(defprotocol TestProto (test-method [a]))

(extend-protocol TestProto
  (test-method [_] 42))

(deftest core-api
  (testing "..."
    (let [obj1 (allpa.test_rec.Test.)
          obj2 (allpa.test-rec/->Test)]
      (is (= (test-method obj1) 42))
      (is (= (test-method obj2) 42)))))
The test using obj1 passes fine but the one with obj2 fails with
actual: java.lang.IllegalArgumentException: No implementation of method: :test-method of protocol: #'allpa.test-core/TestProto found for class: allpa.test_rec.Test
am I missing something?

Mitch Dzugan13:04:12

the record definition is in a different namespace

Mitch Dzugan13:04:53

works fine if the record is defined in the same namespace as the test. is this a limitation of records/protocols?


is record namespace required properly ?


One is test-rec, another is test_rec. Typo?

Alex Miller (Clojure team)13:04:00

no, that's correct - first is a Java class name, second is a Clojure namespace

Mitch Dzugan13:04:18

you need underscores for the java class name. My namespace looks like this which I think should be fine

(ns allpa.test-core
   #?(:clj [clojure.test :refer :all]
      :cljs [cljs.test :refer-macros [is are deftest testing use-fixtures]])
   [allpa.test-rec :as tr])
  (:import allpa.test_rec.Test))

Alex Miller (Clojure team)13:04:01

this looks right to me, and should be fine. just to check - are you sure you have a clean repl state?

Alex Miller (Clojure team)13:04:38

there are some situations you can get into where the protocol was extended to an old version of the record class, but you've recompiled the record class and have an instance of a new record class (even though their names are the same)

Mitch Dzugan13:04:10

Don't have a repl open. just running lein test I tried rerunning after a lein clean to be sure but no luck

Mitch Dzugan13:04:50

Not that I know of. I haven't changed anything in project.clj from the template.

Mitch Dzugan13:04:33

Not a huge deal because I believe this is working correctly in the application I'm writing that uses the library I'm writing. Just preventing me from writing unit tests for one of my macros but would be nice to understand what is happening

Alex Miller (Clojure team)13:04:47

I tried what you listed and it worked for me

Mitch Dzugan13:04:23

strange... ty for trying. maybe something fishy w/ my clojure/lein version

Alex Miller (Clojure team)13:04:33

nothing has changed in this regard in either for a long time, so not sure what that would be. I'm not using leiningen though to test

Alex Miller (Clojure team)13:04:39

I can repro it with leiningen though

Alex Miller (Clojure team)13:04:13

it's something to do with the order lein test is loading code - I see the allpa.test-rec namespace get loaded twice, which makes it likely this is the scenario I described above

Alex Miller (Clojure team)13:04:34

and if I move allpa.test-rec from test/ to src/, it works

Mitch Dzugan13:04:37

cool ty! I'll get a bit cleaner repro and file a bug with leinengen. I'd guess it has to do with how leinengen sets the main namespace because I didn't have this issue when the same type of code is deep in the application instead of in the entry point of the test

Mitch Dzugan13:04:02

thats plenty enough for me to get my unit test working ty!

Alex Miller (Clojure team)13:04:23

I think lein test will gather all the files in test and load them - it's probably loading the test-core, which loads test-rec transitively, then it loads test-rec, then it runs test-core

Alex Miller (Clojure team)13:04:04

$ lein test
loading allpa.test-rec
loading allpa.test-core
loading allpa.test-rec

lein test allpa.test-core

lein test :only allpa.test-core/core-api

ERROR in (core-api) (core_deftype.clj:583)
expected: (= (test-method obj2) 42)
  actual: java.lang.IllegalArgumentException: No implementation of method: :test-method of protocol: #'allpa.test-core/TestPro

Alex Miller (Clojure team)13:04:27

adding printlns to the namespaces makes that clearer

Mitch Dzugan13:04:53

ah nice! Ill keep that in mind for future debugging

Breno Duque Estrada17:04:47

What do you recommend to study when a intermediate level in Clojure is reached ?

Joe Lane18:04:17

Have you read "The Joy of Clojure" ?

thanks 4
metal 12
Breno Duque Estrada18:04:30

Not yet. But I know this book and it is on my read plans.


That's what I like about Clojure Reading a book that's 9 yrs old and still makes sense 🙂 Which is rather rare these days. Technology become obsolete so fast.

truestory 4

1. Study (day by day) the Clojure Standard library book with many good examples: 2. Learn Clojure code from well known open source projects. 3. Make something practical using Clojure: your own pet project or full-time job


I read the 12th chapter "" from The Joy of Clojure yesterday. Mind blown. It shows some pretty advanced techniques and goes on to explain the "why", not just the "how". If the whole book is like this, then it is a must read.

Breno Duque Estrada23:04:59

Thank you guys! These advices were very good to me!

Breno Duque Estrada23:04:51

@U0113AVHL2W Which book did you mention, e.g ?


@U010H5U6SEM I was referring to the same book that @U0CJ19XAM mentioned. "The joy of clojure". It was released in 2011.

truestory 4

The 2nd Edition came out in 2014.


(and, yes, it's a great book once you have the basics down)


I'd also recommend Clojure Applied as a "next level" book (although it relies more heavily on records than its authors would now if they did a new edition).

Breno Duque Estrada15:04:47

Very cool guys! Thank you!

Breno Duque Estrada15:04:48

@U04V70XH6 Do you recommend this book after reading the "The Joy of Clojure" ?


@U010H5U6SEM Yes, I think Clojure Applied would be a good choice to read after Joy of Clojure. Other books to consider: Programming Clojure 3rd Ed (although it starts from beginner level, it's a very thorough coverage of intermediate+ stuff too), The Clojure Cookbook (some of the examples might be a bit dated but it has a lot of practical, real world Clojure usage, showcasing a number of popular libraries).

Breno Duque Estrada18:04:31

Oh, I knew "The Clojure Cookbook" last week and I'm very interested

Breno Duque Estrada18:04:37

Thanks for the recommendations!


my kingdom for a “Joy of Clojure” 3rd Ed treating spec and core.async.


I was also really surprised how much still-valid intermediate stuff was in the O’Reilly “Clojure Programming” book from Chas Emerick, Brian Carper, Christophe Grand (2012).


particularly if like me you’re a Java newb; I’m coming in from JS/CLJS. The stuff around avoiding object boxing for performance was :male-cook:😘


Yeah, I like that book. It was one of the first three Clojure books I bought: Joy of Clojure (1st Ed), Clojure in Action (outdated, even at the time it was published!), Clojure Programming.


I tend not to recommend it now, just because I sort of assume it might have become outdated... but I guess not. We have so many newer books tho'.


True. I think it’s the most Java-exposing, which was very good for me when I read it, since I have somehow missed using Java my entire career


(Fun story: I read Fogus’s “Functional Javascript” and thought huh, wonder if he’s written anything else, and bought Joy Of as my first clj book 😬).

clj 12

How do I get each line to count as a seperate match here? Am I misunderstanding "multiline mode:?

(def s
  "A 1
A 2
A 3")

(re-seq #"(?m)^A.+$" s)
;;=> ("A 1 A 2 A 3")


o_O user=> (re-seq #"(?m)^A.+$" s) ("A 1" "A 2" "A 3")


Yep, can confirm - works for me both in CLJ and in CLJS.


I'm on windows, could this be related to that?


Was just about to ask. :D


I know there are some newline differences


Yep, exactly.


I don't have Windows, but in cljs it works for me even with windows line endings


Ok it looks like this might be an inf-clojure bug actually


and this is clojure: user=> (def s "A 1\r\nA 2\n\rA 3") #'user/s user=> (re-seq #"(?m)^A.+$" s) ("A 1" "A 2" "A 3")


yeah it's working for me from the command line just not in emacs


I have a customization to inf-clojure Emacs Lisp code that does not eliminate newlines in the strings sent to REPL.


Default inf-clojure behavior for some of the key bindings to send expressions to REPL is to eliminate newlines.


Any chance you'd be willing to share the relevant code when you have a chance?


You can search for occurrences of 'inf-clojure' in this Emacs Lisp file I wrote and have in a public Github repo -- those are Emacs Lisp functions I wrote that are small modifications of the built-in ones, that work the way I prefer:


perfect, thanks!


When using definterface, do I have to use import function instead of the (ns (:import ...)) form?


in the consuming ns?


In the ns where I define the interface.


I have this,

(ns com.github.hindol.clj-fn.core
   [clj-java-decompiler.core :as cjd])
   ( HttpRequestMessage

(definterface Functional
  (run [^ request]))
Note that in the interface I had to fully quality the HttpRequestMessage.


If I don't fully qualify, that resolves to java.lang.HttpRequestMessage. Don't know why.


that is surprising


And the function form (import ...) did not help either. 😕


try using (with-meta 'request {:tag HttpRequestMessage}) maybe...


the docs seem to indicate what you're trying should work


Where do I put this? In place of the type hinted arg?


Like this?

(definterface Functional
   (run [(with-meta 'request {:tag HttpRequestMessage})]))


^ This removed the hint entirely, now it's Object.


Okay, I hunted down the actual thing. HttpRequestMessage is an interface. Does that change anything?