This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-27
Channels
- # announcements (5)
- # beginners (267)
- # boot (1)
- # calva (37)
- # cider (11)
- # clara (10)
- # clj-kondo (24)
- # cljsrn (13)
- # clojars (1)
- # clojure (119)
- # clojure-europe (5)
- # clojure-italy (19)
- # clojure-nl (11)
- # clojure-spec (18)
- # clojure-uk (99)
- # clojurescript (44)
- # clojurex (57)
- # community-development (6)
- # cursive (13)
- # datomic (92)
- # duct (12)
- # fulcro (1)
- # graalvm (4)
- # jobs (1)
- # kaocha (6)
- # luminus (3)
- # lumo (9)
- # off-topic (20)
- # pathom (6)
- # re-frame (21)
- # reagent (2)
- # reitit (9)
- # remote-jobs (4)
- # shadow-cljs (32)
- # spacemacs (3)
The getting started pages for Clojure are kind of a balancing act between different ways of doing it. Can you build your own JAR and run that? Sure, and there might be a few projects that do so. I expect it is rare to go that path, though.
Is copying and pasting from the editor to the term the standard way of using Clojure ?
No. That's why you want REPL integration with your editor.
Then you can just press some key combination and the expression at the cursor is evaluated into the REPL that you have connected to your editor.
Or use code runner extension in VSC ?
Calva is the preferred extension for Clojure in VS Code.
So, Atom outputs to the terminal and VSC to its own console ?
Atom with Chlorine displays evaluation results inline inside the editor (and in the "Console" panel that is opened when you connect to a Socket REPL).
(Atom with ProtoREPL also displays results inline and in the REPL panel)
Looking at Calva's GitHub repo, it also shows evaluation results inline in the editor.
And the only way to run clj code in terminal is either interactively or copy / paste ?
clj
can run Clojure programs -- not sure if that's what you're asking?
I am used to navigating to the file location and running the source file
If you start a REPL in a terminal, one that is outside of any editor/IDE environment, then you can either type into it, or copy/paste, are the main options I know of.
Which can be done, but is often not preferred, because of the inconvenience for interactive development.
I see : Calva Clojure Formatter , better than tomorrow. I think this is the new one
You can also start programs that were written in Clojure, programs that you do not interact with using a REPL at all, just like a "normal" running program in C or Java.
Example of creating a clj
project and running the -main
program:
(! 584)-> clj -Sdeps '{:deps {seancorfield/clj-new {:mvn/version "RELEASE"}}}' -m clj-new.create app paul.gureghian
Generating a project called paul.gureghian based on the 'app' template.
Wed Jun 26 17:15:26
(sean)-(jobs:0)-(~/clojure)
(! 585)-> cd paul.gureghian/
Wed Jun 26 17:15:37
(sean)-(jobs:0)-(~/clojure/paul.gureghian)
(! 586)-> clj -m paul.gureghian
Hello, World!
Wed Jun 26 17:15:59
(sean)-(jobs:0)-(~/clojure/paul.gureghian)
(! 587)-> cat deps.edn
{:paths ["resources" "src"]
:deps {org.clojure/clojure {:mvn/version "RELEASE"}}
:aliases
{:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "RELEASE"}}}
:runner
{:extra-deps {com.cognitect/test-runner
{:git/url ""
:sha "76568540e7f40268ad2b646110f237a60295fa3c"}}
:main-opts ["-m" "cognitect.test-runner"
"-d" "test"]}}}
Wed Jun 26 17:16:03
(sean)-(jobs:0)-(~/clojure/paul.gureghian)
(! 588)->
(! 588)-> cat src/paul/gureghian.clj
(ns paul.gureghian
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
If you run a Clojure program that way, then you are limited in how you can interact with it and debug it to traditional methods, like printing or logging intermediate results to see what the program is doing.
Here is my Github repo. going to add some Clojure code soon. https://github.com/paulgureghian
At the risk of burying you with too many possibilities, sometimes people take advantage of starting a Clojure program on a computer somewhere, and give it command line options so that the program is "listening" on one or more TCP ports for incoming connections. Some other client program that connects via those TCP ports can then get a REPL session to send Clojure expressions and evaluate them inside of that program.
I have a good idea on my next steps
I have picked up some good tips in this Slack group
Any thoughts on the Nightcode editor ? thumbs up or thumbs down ?
I think it's good for learning/getting started. I think people "grow out of it" fairly quickly tho'
Careful with the REPL 😉 , I'm suffering from this: https://clojure.org/guides/repl/guidelines_for_repl_aided_development#_dont_get_carried_away_by_the_repl
BTW, read that guide, its really good - https://clojure.org/guides/repl/introduction
See https://clojure.org/reference/transducers#_defining_transformations_with_transducers
How to run this clj file ?
You’ll get a null pointer when you do. You’re invoking the return of a println which is nil
Working from this tutorial. https://www.tutorialspoint.com/clojure/clojure_basic_syntax.htm
Please do not follow this or the video on YT titled "Clojure Tutorial" from Derek Banas. Nothing against any of the above, they're not idiomatic at all. Recommend reading the stuff on http://clojure.org instead and watching Rich's talks, solving problems on http://4clojure.com and reading books. Can wholeheartedly recommend Clojure for the brave and true, Programming Clojure, Joy of Clojure and Clojure Applied. Last but not the least, you can always come here for help and/or banter 😀
the parentheses in that file don't completely match up. Having an editor that immediately shows you, e.g. via highlighting, which parenthesis in the file matches the one your cursor is next to, or colors them with different colors for matching pairs, are very useful when editing Clojure programs.
See https://clojure.org/reference/transducers#_defining_transformations_with_transducers
I was completely astonished a while ago when I saw that. Event posted in off-topic. Seems like someone just tried to mimic a similar tutorial in an imperative lang without knowing anything about Clojure.
Sorry for the unsolicited noise. A realise a simple "+1" would have sufficed.
@paulgureghian I would stop trying to follow that tutorial. Lots of problems with.
Do you have terminal in your Atom on Mac ?
The code is full of errors and very bad practices and the text is just plain wrong in many places.
@paulgureghian I'm not sure what you're asking.
In Atom on Windows there is a terminal menu option. do you have a terminal in your Atom on Mac ?
My Atom on Windows does not have a terminal menu option.
Perhaps it's because of a package you installed?
Atom on Windows
Does your Atom on Mac have a term ?
proto-repl is a more powerful tool purpose built for working with Clojure code, but if you wanted an integrated general purpose terminal for Atom, this is what I use: https://atom.io/packages/platformio-ide-terminal
yup. thats what I have now. do you have a console for your atom on mac ?
Like, an Emacs console? Because I do now, lol. https://atom.io/packages/atom-console
yup. thats the one I just installed. I dont know if its what I want. atom is not an ide so i dont know if atom will output data from the running of the source code. i guess we use an external console for that
If you're talking about Clojure specifically, you can do that from either proto-REPL or by starting a Clojure/Lein/Boot REPL in the terminal itself. If you use a build tool to run a project using the terminal, it will output data from the program and function as a REPL in its own right. proto-REPL can be opened in a particular project namespace, and imports all the definitions from it.
If you wanted an out of the box IDE though, there's this: https://cursive-ide.com/
Funnily enough I had more trouble getting that working than I did throwing together a bunch of Atom packages and using it as an interface for all the command-line Clojure tooling.
Found this as well, if you want something to help you get comfortable with using proto-REPL. https://github.com/jasongilman/proto-repl-demo
Thanks
I'm not at my Mac to check. I don't remember seeing a terminal menu option tho'.
How to use the repl integration in Atom now ?
Did you look at the Chlorine package I suggested?
I installed it
OK, so you start up a Clojure REPL -- or any other Clojure-based process -- with the option that starts a Socket REPL and then you ask Chlorine to connect to that Socket REPL. Then you can evaluate the code in the editor into the connected REPL.
The page I linked you to for Chlorine shows you how to start Clojure processes with a Socket REPL.
The keymap listed on that Chlorine page is a useful starting point -- but you can customize Atom any way you want for binding keys to commands.
@paulgureghian If you want to see some of what my workflow looks like with Atom and Chlorine: https://www.youtube.com/channel/UC8GD-smsEvNyRd3EZ8oeSrA
You just got a new subscriber
I use REBL as well, but the basic mechanics are the same. I use clj
to start processes with a Socket REPL running, I connect Atom/Chlorine to that Socket REPL, I evaluate code in the editor and it is evaluated in the REPL -- you see the results inline in the editor (as well as the Console panel in Atom), and also in REBL 🙂
Ill take a look tomorrow
You're on the same TZ as me, BTW, so I'll be here all night as they say 🙂
(but I'm about to go feed cats and probably pop to the liquor store for some beer)
Im in LA
clojure
; Kinda dumb question
; I noticed there are quite a few interfaces w/ single function
; that look like the one below
;
; method :: 'a -> 'b
(defn reify-consumer
[func]
(reify Consumer ; macro out this
(accept ; macro out this
[this thing]
(func thing))))
; So im trying to write a Macro that does this
(defmacro reify-basic
[interface method]
`(fn
[impl]
(reify ~interface
(~method
[this arg]
(impl arg)))))
(macroexpand (reify-basic Consumer accept))
im runnin into some errors with trying to implement this macro, the error messages are kind of incomperhensible to me
First off, macros will expand simple symbols to qualified names by default -- which is fine for references to core functions etc, but isn't what you want you want for "local" symbols within the generated code, such as function arguments.
For local symbols, you need what's called "gensym" -- in this case impl
and arg
both need to be impl#
and arg#
Since you're not using this
in the reified function you can use _#
for that -- if you actually needed it to expand to the literal this
symbol, you'd need ~'this
I think (I'd have to try that out)
Happy to help. I'm just hanging out, watching AGT, with my wife, my cats... and my laptop 🙂

Care to give an opinion on this, if you have a minute? 🙂 https://github.com/typeetfunc/datascript-mori/issues/8
Not sure why you think I'd have an opinion on it...? I don't do cljs, I don't use JS or NPM...
There's a really obvious response to the question: it has no tests, how can anyone tell whether it works?
But the "answer" to that is: send in a PR with tests...
@U0VQ4N5EE So... do I win a prize? 🙂
well, i thought cljs and clj are much the same, plus the issue is about building it which is even closer
and also, the question is what to test, if I could have some pointers on where to start, I could pick it up, but you just gave a name to it, that only made it referrable not solvable so far. next time I ask someone I will also ask what they think what tests one could write for it... So I guess for an opinion that counts as one, even more than one 🙂 thanks!
The cljs tooling is completely different and the interface with npm is another whole thing. It bothers me a lot that there are no tests here. When I've worked with projects that are cross-platform, getting the cljs stuff tested properly is always a big deal. It's very hard to maintain a project without automated tests.
I have no idea where to start -- I have no idea about datascript or mori, whatever that is.
I maintain Expectations which is cross-platform but the cljs side doesn't have automated tests yet (only manual tests). HoneySQL is better -- it has automated cljs tests. So take a look at that from an infrastructure point of view.
It can be really hard to add tests after the fact...
even in this case it seems you are saying easier to start from scratch than build on something that already exists...
It depends. I know nothing about mori
and very little about datascript
so I can't just how potentially useful the library is.
datascript compiled together with mori means that it's really fast, even though immutable, even if I use it through javascript
Wait, WAT? This is just 68 lines of exports? What on earth even is that?
How is it a library? I don't get it...
while if I build mori and datascript separately, then from javascript the two will not work together because google closure will use different minimized names
It makes no sense to me at all.
Isn't this already a solved problem in cljs? With stuff like cljsjs or whatever the library system is called?
I have no idea what to even think about this...
This is so alien to me as a Clojure developer on the JVM.
But yet, you did 🙂
I am sorry about it. I had the wrong assumptions about how easy it should be someone who can read the code and know the ecosystem to switch between contexts. In javascript it doesn't matter what the runtime is, the language is the same, everything is the same.
But there is no code in that library.
It's literally a bunch of weird defs. It makes no sense.
all the code should do is to connect mori to datascript so google closure doesn't create two different builds.
I've no idea whether this is an artifact of Google Closure or cljs or what...
This is why, after trying cljs in 2014-2015, I haven't touched it since...
I just started trying to look at it again this past weekend.
Meh, what's so exciting about that?
i used it in 2015-2016, I just gave a simple scheme to it and random JSON and it parsed it into a database with entities and queries and whatnot. But can't use it without the connector 😞
most of js development that's boring but error prone is data mangling to take backend data and make it shaped for presentation
datascript makes it so that it's basically 2 steps, writing the schema, and writing the query.
mori and datascript will link together as long as they are both passed in as inputs to the compilation process, producing a set of output artifacts (normally one) in the same compilation process
for example, I have cljsjs deps, other cljs deps, and they all get compiled, linked together, and minified as one
@UKH2HDSQH thanks for chiming in, may I ask you to elaborate on this a bit more? Or if you just point out what docs are to be read, because on my own I usually get lost 😞
do you have an existing project.clj for the project? is both datascript and mori in the dependencies?
@UKH2HDSQH https://github.com/typeetfunc/datascript-mori/blob/master/project.clj this is the project.clj for datascript-mori
seems like both datascript and mori are in it, just that mori is in the git-dependencies
Yeah I would think that should work, as you've included the mori src path in your source-files.
one thing I would try in your situation is changing :optimizations to :whitespace and rebuilding the artifact release-js/datascript-mori.bare.js
then open that in an editor. check everything is there. is the mori namespace in there? just text search for it. what about datascript, is it in there? Then check that this artifact works
if that artifact works as intended then you are going to need to look into why advanced optimizations wrecks it
thats an artform in itself. maybe start with trying to see if :whitespace optimization gets you cleany exported namespaces to the js that works
@UKH2HDSQH none of the code written there is done by me, I just want to use it
I would use datascript from js, exported through the datascript-mori package that I want to update
I will try to change the optimizations. What I think is missing is to write the new exports for the new datascript api
@UKH2HDSQH that's almost a 10 year old post 🙂. Even if it's relevant information, nothing is the same anymore, not sure it's translateable
The 2011 post from Luke.
the first one is a description of the google closure compilers advanced compilation mode, and what it effects.
Eight years old.
Clojure is very stable. Old code still runs, mostly.
but old code != old blogposts. anyway. as I said, I got it eventually, just had to read more from it
We went to production in 2011 on Clojure 1.3 (alpha 7 or 8?) and very few things have caused our code to change over those eight years.
@UKH2HDSQH but that's different, i don't want to run old code
i am sure people like @U04V70XH6 who have old code in production appreciate it though 🙂
@UKH2HDSQH Well, the compiler is a bit more strict now (with Spec) and there are more built-in fns which might clash with old code but, yeah, basically old Clojure still runs 🙂
but if your whitespace optimized code works, and :advanced doesn't, then you need to dig into what munging advanced is doing
@U0VQ4N5EE Our code is bleeding edge. We update the very latest alpha/beta Clojure versions as soon as they appear and we use all the new functionality.
That's a far cry from running "old code".
@UKH2HDSQH the problem is not that the code doesn't run, is that the code runs with older version of datascript, not with the new one, and I will have to export stuff from datascript into datascript-mori
@U0VQ4N5EE You need to take this to #clojurescript to be honest.
I don't even know where to start. You gave me helpful pointers of stuff that's necessary for this, but not quite what I have most problems with this
@U0VQ4N5EE oh ok. I didnt realise the issue was an older datascript
@U04V70XH6 you assume I have not asked dozens of people already, several from there too. I only dared to ask here because you were watching TV 😄
@UKH2HDSQH I don't remember, it was a long time (months) when I last had enough time to try it
@U0VQ4N5EE dropping this giant thread on a completely unrelated comment I made is just rude.
Seriously, take it to #clojurescript
@U04V70XH6 I didn't dropped it, we developed it together 😞
@UKH2HDSQH only got here after it got big 😄
well I have no problem with a long thread. I lurk and just pick out things I can help with. Better a thread than the mainline. It is beyond beginner stuff. I think you have to be clearer about your problem. I've been trying to help with a name exporting problem in advanced compilation combining mori and datascript, only to find out the problem is actually an old datascript version being a problem somehow, and you haven't touched in in months.
America's Got Talent. Don't judge me 🙂
Dark is amazing! We started S2 the other night and got 3 eps in.
hey is there ways to improve jdbc inserts i'm using insert-multi! while using async/thread to create parallelization of inserting data into postgres which each batch is about 1000 running in a 16 cpu core
i feels is too slow
since its taking 10-15 min to insert about 1.3 million records
records are not big
@javiergonzalez7 Have you added the Postgres-specific flag that makes that JDBC driver behave properly with insert-multi!
?
Unfortunately the auto-generated docs are not running at the moment so the 0.7.9 release is not reflected on http://clojure.github.io
oh ok gotcha
thank you
Fortunately cljdoc has the latest https://cljdoc.org/d/org.clojure/java.jdbc/0.7.9/api/clojure.java.jdbc#insert-multi!
(and it's in the very long docstring for insert-multi!
)
bumped on clojure site - lmk if that looks better
Thanks @alexmiller! Yup the 0.7.9 release, with the improved docstring, is showing up now!
Including the specs -- nice! -- first time I've seen it show those, which is interesting because they're in a separate, optional namespace.
if only there were spec docs :)
how does async/threads behave with hikari connection pool
do all threads share the same connection pool or each one creates each
since i'm using mount for the connection pool database
@javiergonzalez7 My understanding is that Mount uses global Vars for state so they are singletons shared across all threads.
oh awesome
Guys, how can I add a String to a java.util.ArrayList in clojure? Like this?
Lists.newArrayList("Aaaa")
@d.ian.b Is that using Guava?
user=> (def l1 (java.util.ArrayList.))
#'user/l1
user=> l1
[]
user=> (.add l1 5)
true
user=> l1
[5]
yes
Sorry, you asked about a string, not an integer. But take that example and replace the 5
with "Aaaa"
@d.ian.b You can create an ArrayList
from a Clojure collection, if that helps:
user=> (java.util.ArrayList. ["Aaaa" "Bbbb"])
["Aaaa" "Bbbb"]
user=>
yeah! It helped me. Thanks!
also, often you don't need an ArrayList specifically, and the API can use any List - and clojure's [] already is a java.util.List
Hey guys I have a slight problem, when I try run lein repl
in my project it keeps saying this: Error loading cider.piggieback: Could not locate cider/piggieback__init.class, cider/piggieback.clj or cider/piggieback.cljc on classpath.
Any idea how to get around this? I've tried running lein deps
but that doesn't seem to do anything
basically you set things up to always try and run cider.piggieback middleware for all projects without setting it up as a dependency
if you actually want piggieback (it provides a cljs repl over nrepl) it should probably be coming in via a plugin
if you don't, I agree with @hiredman above
I've had to switch computers recently... it used to be working before. I did a clean install of Leiningen and Emacs
In Emacs when I launch cider-jack-in-cljs
I get strange behaviour - hot reloading and everything works but if I try switch to REPL it says no cljs
REPLs found
OK, so it sounds like you do want piggieback middleware and that's a missing dep
Look in your buffers list for the clojurescript repl. The connection is kinda dumb and only sees the last one.
I have :repl-options
to include the piggieback middleware like so {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}
But when I check my buffers I only see a clj
buffer and not a cljs
one
well the error you started with is explicitly telling you why you aren't getting a cljs repl - it can't find piggieback and afaik you can't have a cljs nrepl without it
Cider should inject piggieback for you if you’re on a recent version. Can you come to #cider. I can help in 10 minutes if you don’t figure it out beforehand