This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-25
Channels
- # announcements (3)
- # beginners (64)
- # calva (1)
- # cider (78)
- # clj-kondo (4)
- # clojure-losangeles (1)
- # clojure-uk (5)
- # clojuredesign-podcast (1)
- # clojurescript (15)
- # cursive (2)
- # datomic (19)
- # docker (7)
- # fulcro (17)
- # graalvm (1)
- # hugsql (1)
- # instaparse (2)
- # jobs-discuss (25)
- # joker (2)
- # luminus (1)
- # off-topic (20)
- # pathom (1)
- # pedestal (2)
- # reagent (5)
- # shadow-cljs (83)
- # spacemacs (11)
- # vim (1)
- # vscode (13)
Is Lumo probably what I’m looking for if I want to work primarily with Clojure in the Node.js ecosystem?
planck doesn't use node
it uses javaScriptCore, which is an os-specific js api, so it's useful for doing system /scripting but you can't use node specific features or libraries
with planck you can use the clj deps tool to manage libs, with lumo you'd use node
If you want to target nodejs just use shadow-cljs. It will wrap the normal clojurescript compiler and make your life easier
that's fair, then you use java but just on the build / compile side
Yeah. It’s quite nice and makes using npm deps extremely easy. I prototyped a simple tui with blessed.js which is a port of ncurses and it was effortless
It’s not really that I’m trying to escape java at all costs. I don’t mind it for tooling. It’s just that most of my experience is in the JS ecosystem, so it’s what I understand
Clojurescript is a clojure program so that’s most likely in your build chain. I think unfortunately the maintainer of lumo has stepped back. Planck is amazing but I haven’t gotten a good dev setup with it
Go with shadow as the default until you need something different. I would guess that’s not gonna be an issue though
I’ve tried to play with shadow a bit, but I find it difficult to follow the docs. Lumo has at least been easy (until probably running into a bug or two)
Need some help with shadow? I honestly wouldn’t even consider a different cljs build chain these days
Yes I probably do. Let me sleep on it though and take a crack at it tomorrow—I’ll ping you after I know concretely where things get hazy for me, if that’s ok
@kamuela There's a #shadow-cljs channel here if you're not already in that...
Hi, when I'm working with APIs I'm mostly extracting the stuff I need via a usually rather huge let
which doesn't feel quite right to me, does anybody have a better suggestion of doing that? Example:
(defn weatherdata [d]
(let [main (:main d)
deg (:temp main)
feel (:feels_like main)
city (:name d)
sys (:sys d)]
(str ...
Look into associative destructuring
(defn weatherdata
[{{deg :temp feel :feels_like} :main
city :name
sys :sys}]
(str [deg feel city sys]))
Hi, I'm working with next.jdbc and I'm having a hard time coming to terms with, what looks like, the need to restructure a hash map into two vectors (for columns and row values). My data looks like this:
#{{:key "value"} {:key "value2"}}
But I haven't been able to find a way to next.jdbc.sql/insert-multi!
without restructuring to multiple vectors. Am I missing something? Including possibly a reason for this limitation...@parkerjohnsonwebdev Because for insert multi you want a single batch insert operation to happen (as opposed to insert!
which does a single row operation).
So the SQL is insert ( column names ) values ( first row ), ( second row ), etc
If you read the justification for the next.jdbc.sql
stuff, it exists primarily as a migration aid from clojure.java.jdbc
-- the recommended approach is to use the next.jdbc
functions and a DSL like HoneySQL if you don't want to write SQL strings.
In clojure.java.jdbc
, insert-multi!
took a series of hash maps but under the hood it did repeated single row inserts.
The array form of arguments -- a row of column names follow by rows of data -- was the only way with c.j.j
to get a single batch operation.
But also note the caveats about database-specific behavior around that...
https://cljdoc.org/d/seancorfield/next.jdbc/1.0.13/doc/getting-started/friendly-sql-functions#insert-multi -- and the recommendation to use next.jdbc.prepare/execute-batch!
instead.
(BTW, I'm more likely to see questions about next.jdbc
or clojure.java.jdbc
in the #sql channel since it's much lower traffic than #beginners or #clojure -- and there's a #honeysql channel too, if you have questions about that @parkerjohnsonwebdev)
gotcha! That makes a lot of sense now that I'm reading this. Thank you very much for the explanation
The database-specific behaviors drive me crazy, especially since the workarounds and JDBC connection options differ between databases 😞
Hi everyone. I am trying to add the time library. I have added this to the namespace in my core.clj file: (ns clojure-noob.core
(:require [clojure.data.json :as json])
(:require [clj-time.core :as t]
[clj-time.format :as f])
(:gen-class))
and this into my deps.edn which is located in my project folder:
{:paths ["resources" "src"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
org.clojure/data.json {:mvn/version "0.2.7"}
http-kit {:mvn/version "2.4.0-alpha4"}
cheshire {:mvn/version "5.9.0"}
clj-time {:mvn/version "0.14.2"}}
I can get it to work the clojure repl in the terminal, but not in the ciderREPL in emacs.ELI5, Clojure is my first language. Does not this set a namespace as t? Screenshot 2020-01-25 20.58.23
You removed the vector around the sub clause for clojure.data.json between your two screenshots
Wow now I felt stupid, it’s the par-edit which I still mess up with. I got it to compile now, but its still the same error:
Syntax error compiling at (clojure_noob:localhost:51835(clj)*:43:25).
No such namespace: t
Can you try to require the namespace straight in the repl? This should isolate the source of the problem a bit.
(require '[clj-time.core])
Execution error (FileNotFoundException) at clojure-noob.core/eval6269 (form-init5163200568704381030.clj:52).
Could not locate clj_time/core__init.class, clj_time/core.clj or clj_time/core.cljc on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
Did you launch the cider repl before adding clj-time to the deps.edn? Maybe you need to close and restart the repl
Fixed it now, by adding
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/data.json "0.2.6"]
[cheshire "5.9.0"]
[clj-time "0.14.2"]]
in the project.cljCider should support both
Typically you only really need one or the other depending on if you are using lein or clj
Ah. If you have both files in the project folder, cider probably defaulted to using leiningen
Just as a slight additional detail on there, which you do not necessarily need to understand at this moment, but long term is useful: a single library described in a project.clj file (or deps.edn file) can contain multiple Clojure namespaces. Often the namespaces inside of a library have similar names to the library, but often they are different. In Clojure you use require
and give it the name of one or more namespaces to require.
Wow this actually made me understand libraries. :as gives you shorter and more intuitive names to call all the functions contained within a library. Libraries are added in the project.clj file, and automatically downloaded. Seems so simple now that I got it working. Thank you for the help! Now onto getting data from an open API.
