Fork me on GitHub

Is Lumo probably what I’m looking for if I want to work primarily with Clojure in the Node.js ecosystem?


Maybe Planck


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


So when I think of interop I think of JS on NPM rather than Java with Maven


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

❤️ 4

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...

🙏 4

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 ...

Matti Uusitalo13:01:00

Look into associative destructuring


(defn weatherdata
  [{{deg :temp feel :feels_like} :main
    city :name
    sys :sys}]
  (str [deg feel city sys]))

Matti Uusitalo13:01:17

Your code is fine though

👍 4

that looks cleaner, thanks!


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 -- 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, 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...


(BTW, I'm more likely to see questions about next.jdbc or 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 😞


yeah that's gotta be an incredible pain for you


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 [ :as json])
  (:require [clj-time.core :as t]
            [clj-time.format :as f])
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.


can you eval (ns-aliases *ns*)?


returns {}


then there's no t namespace


ELI5, Clojure is my first language. Does not this set a namespace as t? Screenshot 2020-01-25 20.58.23


put them all in the same require


(ns blah
  (:require [thing :as t]
            [thing2 :as t2]
            [thing3 :as t3]))


Still getting error when I try to compile: Screenshot 2020-01-25 21.09.44


You removed the vector around the sub clause for 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

Matti Uusitalo20:01:57

Can you try to require the namespace straight in the repl? This should isolate the source of the problem a bit.

Matti Uusitalo20:01:15

(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.

Matti Uusitalo20:01:01

Did you launch the cider repl before adding clj-time to the deps.edn? Maybe you need to close and restart the repl


I bet you are starting your cider repl using a tool that doesn't support deps.edn


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.clj


Deps.edn and project.clj are used by entirely separate tools


I am using emacs

Matti Uusitalo20:01:18

Cider should support both


Emacs is an editor


Project.clj is used by lein and deps.edn is used by clj


Typically you only really need one or the other depending on if you are using lein or clj

Matti Uusitalo20:01:28

Ah. If you have both files in the project folder, cider probably defaulted to using leiningen


Then I will continue using the leining and project.clj


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.

👍 4

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.

cljs 20