Fork me on GitHub

I do have to say... the people helping out in here for us Clojure newbs are refreshing. Not a judgmental comment anywhere that I've seen, and everyone has been so patient and willing to walk beginners through questions. It is a stark contrast from what I've been used to where asking a question could get your head ripped off... (for example.. the Arch community is notorious for this... at least from what I've seen..).... anyway... kudos to the more experienced Clojure devs in here!! 🙂


I got banned from arch irc channel before even saying anything :rolling_on_the_floor_laughing:


haha.. doesn't surprise me. I've been running arch for about 4 years now... and have never even tried to interact with their community. Great distro (imo)... but yeah... not even worth trying to be a part of the community.


@ryan.russell011 The Clojure community has always had the guidance to be polite, respectful, and welcoming — that comes down from Rich Hickey himself, as well as reinforced by all the Cognitect (formerly Relevance) and Clojure/core folks. The conferences have had a Code of Conduct for several years — and this Slack also has a Code of Conduct — so there’s a culture of treating people decently. And we also deliberately set up a separate #beginners channel here for folks new to Clojure and those folks who opt-in to help them (it’s why there’s nearly 13K people in #clojure and only 4.5K here). There’s also a #programming-beginners channel for folks who are new to programming as a whole.


that is super amazing! Well done!


Besides, how can we take over the world if we don’t encourage more people to use Clojure? 🗺️

😂 12

How many of you started with Clojure (or other functional-first lang) after feeling burnt-out on imperative? :thinking_face:


I actually got some Haskell experience first. After that, when I went back to Java, I noticed Java felt clunky and I actually noticed how verbose it was. I still feel like it is a good language, but it has its purpose and I felt like most the time it just wasn't needed for most the things I was doing. I then started looking into Scala, but it also felt too Java-like... Clojure has a simple elegant-ness that I am very much enjoying and I am hoping to one day be proficient with it lol.. and hopefully be able to contribute to this channel as a person that can answer questions!

👍 4

My arc is a bit unusual I think… I did some Lisp and other FP stuff at university but my professional career was assembler, COBOL, C, C++, Java, ColdFusion(!), Groovy, Scala, and finally Clojure (starting in 2010). So it was more returning to my roots. But, yeah, I was pretty tired of OOP and dealing with the boilerplate associated with that sort of approach.

👍 4

Question: how do you require relative namespaces? “Programming Clojure” goes through first imports and mentions > If you see the first 10 Fibonacci numbers as listed here, you have successfully installed the book samples. But doesn’t mention anything about how to install them..


"install" is a weird term for namespaces - clojure looks up code that's required via the classpath


either it's in a jar which is on CP, or there's a directory on the CP with your code in a nested folder relative to the namespace definition


And what is classpath, please?


it's the places a jvm looks for things, a start-time parameter


if you use leiningen, it's leiningen's job to set classpath for you


How do I even retrieve the current classpath?


I found java -cp ... sets it, but that doesn’t help


in the repl, (System/getProperty "java.class.path")


(System/getenv "CLASSPATH") I guess


it can be set from command line and not just env though, use getProperty


but if you are using a tool, it manages that for you


its config decides where source files should be


Aah, I see now


to get more specific I need to know more about your toolchain - leiningen project, boot? raw command line calling java?


OK, the default with lein is for source to be under a src directory

noisesmith02:06:28 ns would be in src/foo/bar.clj


But does that apply to REPL as well?


if lein starts clojure, that's where it wants your source


Aah, I see now


regardless of repl, run, or build


but there's a config in project.clj that can be modified


Okay, okay, now I get it


Hi guys, As you can imagine, I am a beginner. I am trying to take up Clojure. Managed to convince my boss to let me work on a web service + frontend in Clj/Cljs (Compojure, re-frame). It is a small project and I haven't messed up much so far. I am not a hugely talented programmer like many people here so some of the stuff I mess up because I don't have good understanding. I am just an average programmer (So, you will never find me at Google or Facebook.) I would like to get engaged with any open source project that can use some man hours. Testing, documenting, it doesn't matter. Can you suggest a project been done by decent human beings (Not 200 IQ assholes) which can use some help from a beginner like me? I can probably put in five or six hours a week, and I would like to contribute in any way I can. I think I would learn better and faster that way too.


one that immediately comes to mind is the app that displays the logs for this Slack:

👍 4

I will have a look. Thanks


no worries 🙂


I am used to relative imports from JS, but this is based on (CLASS)PATH


Okay, thanks a lot! I’ve been literally playing with cding for 30 minutes trying to figure out how to import those files 😂


@kyselyradek yes, it works just like a path in your shell - it controls which places you get code from


Yup, thanks, really! 😄 This channel is a blessing 🙏


one advantage to that method of doing things is it means you can use code that is inside a zip file (a jar is a zip with a special set of contents), or even directly from a URL


and it won't want to load things just because they are in the current directory (which I guess is a kind of security feature)


Actually, weird thing, it works on clj repl but not using lein repl


quick question... is the caret before Currency doing actual type checking? or is just metadata to describe what currency should be (without actually type checking)?

(defrecord Currency [divisor sym desc])
(defrecord Money [amount ^Currency currency]


type hints are not type checks


they are an assistance to the compiler


with records they are not needed


this example is from Clojure Applied


so the book is wrong?


or there might be another reason?


I think he is just saying ordinarily they aren't needed... which doesn't mean you can't have them


Not that there is a "wrong" or "right"


seems noise then?


the compiler doesn't throw errors for nonsense type hints in most cases, and I guess there might be a case where the compiler could make better numeric code if it knows something about what's in Currency...


and this: (don't let the title mislead you... the first response clarifies a poorly written question here)


so.. here is the whole record from the book

(defrecord Money [amount ^Currency currency]
    (compareTo [m1 m2]
      (validate-same-currency m1 m2)
      (compare (:amount m1) (:amount m2))))
I am assuming the type hint is used here because of the interop with java.lang.Comparable


@noisesmith but is that type hint telling the compiler what's in Currency?


well that code isn't even using currency so there's not enough there to really say - the definition of Currency is what would tell it what's expected to be in there


he pasted the definition of Currency before


(defrecord Currency [divisor sym desc])


well he posted Money before too and that was empty


I'm assuming clojure applied is building up to something interesting where there's a point to the type hint, I'd have to double check it's been ages and there's parts I only skimmed


lol... to alleviate some of the confusion about my amazing copy/paste skillzzzz


obviously there is more... I was just curious as the the functionality of the ^ lol... the actual code is pg 8 in the Clojure Applied book


just so you know, this falls under the metadata syntaxes, see here:


@noisesmith so in general you don't need type hints for defrecords because the clojure compiler already knows about its methods?


right, and the way defrecords and protocol methods dispatch it doesn't need the same kind of expensive reflection it needs to use on classes and interface methods from native java

👍 4

hmm, slack was down for me


Is it necessary to clear ~/.m2/ old (deprecated) dependencies? And How ?


you can safely delete anything in m2 as long as you only install by normal methods


it's a cache, you'll just need to wait for the stuff to download again


if you use mvn or lein etc. to install something local by hand, it will be missing until you do that again, for obvious reasons


Any way to say (require [korma.core :refer :all :except update])?


I don't know of a way to figure out which versions your projects use or not, but deleting the whole thing is a thing people do


@duminda you can use :rename to give update a name that doesn't clash with clojure


or use a db library that has been updated since the clojure.core/update function came out :P


@noisesmith: "or use a db library that has been updated since the clojure.core/update function came out :P" Any suggestion?

Mario C.04:06:29

I am learning about providing support for inserting Clojure maps into JSON columns in a postgres db. An article explain that, its as easy as extending a protocol. It provides an example

(extend-protocol jdbc/ISQLValue
  (sql-value [value]
    (doto (PGobject.)
      (.setType "json")
      (.setValue (json/write-str value)))))
I have a few question that I am going to try and articulate.


@duminda honeysql and hugsql were both kept up to date last I checked - at least more active than korma

👍 4
Mario C.04:06:38

The protocol is implemented by someone and in that example listed, it is being called by the JDBC driver?

noisesmith04:06:48 is invoking that protocol method on its argument


by extending that method to map, that tells what to do when it sees a map

Mario C.04:06:11

I see thanks


1. Unhandled org.sqlite.SQLiteException
   [SQLITE_ERROR] SQL error or missing database (incomplete input)


Why it report missing database?


incomplete input = SQL error methinks


is there a reason your query vector is 2 strings instead of one?


I think you need to mention a database in the configuration [db] and that database must be already created ... here is sample configuration (def mysql-db {:dbtype "mysql" :dbname "clojure_test" :user "clojure_test" :password "clojure_test"})


maybe (sql/query ["" ""']) is happy with 2 strings or however-many, after i have read the docs it seems like that would work. check out:


Is there a way to undo evaluation of all the forms in a file? Sort of like un-intern defs and stuff


@ackerleytng You can (remove-ns (.getName *ns*))


Oh nice, thanks! And then restart for anything in that namespace?


What do you mean by restart?


Just re-eval.


nice. thanks!


Without restarting the repl?


@ackerleytng You can do this, maybe this is what you’re looking for? (require :reload '[my.thing :as thing])


It’s not quite what you asked for, and it sometimes leaves things hanging around that you want to get rid of, but it’s useful in a lot of cases.


There’s also but I haven’t used it personally.


I'm not sure why but c.t.n.r/refresh tends to break things in our project but I've never been able to figure out why

:error-while-loading c.b.c-m-a-test
#error {
 :cause "namespace 'c.b.c-m-a' not found"
 [{:type clojure.lang.Compiler$CompilerException
   :message "java.lang.Exception: namespace 'c.b.c-m-a' not found, compiling:(c/b/c_m_a_test.clj:1:1)"
   :at [clojure.core$throw_if invokeStatic "core.clj" 5807]}
  {:type java.lang.Exception
   :message "namespace 'c.b.c-m-a' not found"
   :at [clojure.core$apply invokeStatic "core.clj" 659]}]
 [[clojure.core$apply invokeStatic "core.clj" 659]
  [clojure.core$load_libs invokeStatic "core.clj" 5925]


After that I have to restart the repl.


seems like it might have something you could use, though.


hmm i was looking for a workflow tip sort of, to avoid having to restart the repl


In that case (require :reload '[some.ns :as s]) might be your best bet. It reloads the namespace and redefines any functions you have changed in the underlying source (but not anything defined with defonce, and I think also not any protocol handlers). That's not quite what you originally asked for, so maybe that's not what you wanted, but that was as close as I could come, and I hope it's useful.


Is there a test coverage tool that supports boot? I can only find Cloverage, which apparently only supports lein

👍 4
Philip Hale19:06:57

I couldn't find one when I looked, would like to help out with that project sometime. Thinking of and boot support would be nice too


Many Leiningen plugins can be run directly from Boot, and creating a boot-* version of most lein-* plugins isn't too hard... take a look at for my path through that with lein-localrepo...


And since the blog post doesn't link to the repo


Cool, thanks both!