This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-07
Channels
- # asami (1)
- # aws (2)
- # babashka (5)
- # babashka-sci-dev (162)
- # beginners (68)
- # biff (1)
- # calva (26)
- # circleci (4)
- # clj-kondo (5)
- # cljs-dev (7)
- # clojure (84)
- # clojure-europe (15)
- # clojure-uk (1)
- # clojured (2)
- # clojurescript (19)
- # conjure (1)
- # datomic (5)
- # emacs (2)
- # graalvm (20)
- # honeysql (6)
- # improve-getting-started (2)
- # kaocha (3)
- # lsp (31)
- # off-topic (7)
- # pathom (7)
- # releases (1)
- # shadow-cljs (1)
- # spacemacs (1)
- # vim (30)
What are leiningen vs figwheel vs shadow cljs good at in a nutshell? Figwheel is replaced by shadow I guess in community now? Pretty basic question, did some research but wanted to ask nutshells here.
Leiningen and Clojure CLI (with community add-ons) are general Repl / project / build tools for Clojure and ClojureScript Figwheel-main (replacing figwheel) and Shadow-cljs are specific tooling to work with ClojureScript (and use Leiningen or Clojure CLI) Figwheel-main and shadow-cljs take different approaches to managing JavaScript libraries, with Shadow-cljs deeply integrated into npm ecosystem. They serve different needs and have different learning curves, therefore it's unlikely one will replace the other.
@U05254DQM thanks! a) you are from practicalli group I guess. can't see 'about' page in http://practical.li. Whats about it? Its a free community movement? b) can figwheel and shadow cljs be used with clojure (not clojurescript)? would it make sense to just use one tool for all jobs? c) I heard theres clojure CLI and CLR or something (don't recall correct name). Whats the difference? one is closed source and one is open? d) well I wonder why people moved from figwheel to shadow. e) I also heard about light table but I am a vim user. Will see what can be done here.
Clojure cli is command line tool for clojure, clojure clr is a port of clojure to .net as the compile target.
At this point, I would suggest not to bother with Leiningen. It's a great dependency manager and build tool, but Clojure itself now comes with its own dependency manager and build tool, and you're best learning that.
It's a bit confusing, but people will say Clojure CLI and they refer to what you might just think of as Clojure itself, that is when you type clj
or clojure
at the command line.
Specifically the official Clojure dependency manager is called Tools.deps
and the official build tool is called Tools.build
, but since both are included with Clojure you'll interact with them through the standard Clojure command-line, aka Clojure CLI, aka clj
and clojure
commands at the terminal.
With this you can download and use all Java and Clojure libraries in your own projects, as well as setup build tasks like compilation, run tests, clean, generate doc, package, bundle, publish, etc.
Now if you want to use ClojureScript, you can also do so using this, but Tools.deps
cannot download and use NPM JavaScript libraries. But it can download and use ClojureScript libraries and any JavaScript libraries published to Clojars for use by Clojurescript as well, which people call cljsjs libraries as seen here: http://cljsjs.github.io/
The problem is that if you're doing anything with ClojureScript, it's highly likely you'd want to use a JS library from NPM.
Now it turns out Clojurescript can use NPM JS libraries, but sometimes it's a little complicated and requiring certain things depending on what type of JS lib the library is can get a bit tricky. This is where shadow-cljs comes in. It makes the process of using NPM libs a lot simpler. That means though you'll be specifying which NPM lib you want using Shadow-cljs and not Tools.deps
, and you'll then have to use Shadow-cljs to perform all Clojurescript related build tasks like compilation and bundling.
Now in Clojurescript you'll also probably want in-browser hot-reload, because it's really awesome. That's where Figwheel-main comes in. As a convenience, Figwheel-main also offers a layer on top of Clojurescript itself to make building and compiling and starting a REPL with hot-reload easier. So you'll use it to declare Clojurescript specific build tasks, but you won't use it for dependencies, you'd still use Tools.deps
and NPM directly.
Shadow-cljs also offers a hot-reload feature, so if you're already using Shadow-cljs for your dependencies and build you don't need Figwheel-main.
So basically I would say, if you want to do Clojure, don't bother with lein, just use what comes with Clojure already, that is, Tools.deps
and Tools.build
which you operate through the Clojure CLI clj
and clojure
commands.
If you want to do Clojurescript and use NPM libs, you have two options:
1. Use Tools.deps
and Fighwheel-main
together.
2. Or use Shadow-cljs
@U0K064KQV I see. that was very informative and clear. I guess no need for lein then. For clojure you also mean or it will involve deps.edn
I guess along with tools.deps
. I will have to read this. For clojurescript I will go with shadow-cljs
@U0K064KQV thanks
@U04V4KLKC @U11EL3P9U This is wonderful. I guess these do not do "inline evaluation" like the light table does? https://youtu.be/7YIaHyTdjTY?t=34
I guess its on the right side separated. Not like light table but I wonder until I use it https://asciinema.org/a/325517
If you are interested in Conjure (I would encourage evaluating fireplace too, and make your own decision), then there is #conjure and also on discord (https://conjure.fun/discord)
@U11EL3P9U thank you! I guess the plugs you use for clojure specifically are ⢠Plug 'Olical/conjure', {'branch': 'develop', 'for': ['clojure', 'fennel']} ⢠Plug 'clojure-vim/clojure.vim', {'for': ['clojure', 'fennel']} ⢠Plug 'guns/vim-sexp', {'for': ['clojure', 'fennel']} ⢠Plug 'tpope/vim-sexp-mappings-for-regular-people', {'for': ['clojure', 'fennel']} ⢠Plug 'guns/vim-clojure-highlight', {'for': ['clojure', 'fennel']} Ignoring coc as I do not use it
@U11EL3P9U Did you found discord more beneficial than slack? (I am just new at both)
How can I generate dynamic columns for insert / update sql , Which lib can I use.? like this means:
insert into t1 if need col1 then col1, if need col2 then col2 values (if need col1 then col1_val, if need col2 then col2_val).
Hi, everyone Why am I getting this exception :
class clojure.lang.Keyword cannot be cast to class java.util.Map$Entry
on this piece of code :
(def a [["Active" :Transit-RLC "Active"]])
(->> a
(transduce
(comp (map drop-last)
(map reverse))
conj []
)
(into {}))
Thanks@UK0810AQ2 âïž
the most pertinent answer is that conj'ing onto a map takes 2-element vectors as map entries (and not seqs) - the slightly deeper detail is (I believe) that conj'ing onto a map takes a Map.Entry or a 2-element vector or a seq of Map.Entry objects - since (:Transit-RLC "Active")
is a seq, clojure tried to treat the keyword as a Map.Entry, and there's the class cast exception originally mentioned
Thanks, @U013JFLRFS8
Yeah you're right. Changing the (map drop-last)
to (map #(-> [(second %) (first %)]))
and removing the (map reverse)
fixed the issue ... Isn't it a little weird ? Should I file it somewhere?
hello, how can i format the string âWed Aug 19 23:06:10 +0000 2020â to â2020-08-19 23-06-10" in clojure
(.format
(LocalDateTime/parse
"Wed Aug 19 23:06:10 +0000 2020"
(DateTimeFormatter/ofPattern "EEE MMM dd HH:mm:ss xxxx yyyy" (Locale. "US")))
(DateTimeFormatter/ofPattern "yyyy-MM-dd HH-mm-ss" (Locale. "US")))
@U01RL1YV4P7 thank u
@U01RL1YV4P7 hello, how to convert this string to timestamp?
@UCD54AV63 Do you mean java.sql.Timestamp? Note that this class is obsolete and you should use Instant from java.time.
(->> "2020-08-19 23-06-10"
(.parse (SimpleDateFormat. "yyyy-MM-dd hh-mm-ss"))
(.getTime)
(java.sql.Timestamp.))
i use clojure java-time, i know
(.toEpochMilli (java-time/instant))
(.getEpochSecond (java-time/instant))
this could, but i donât how to convert localdatetime -> insant(-> "2022-05-10 12:21:41"
(LocalDate/parse (DateTimeFormatter/ofPattern "yyyy-MM-dd hh:mm:ss"))
(.toEpochSecond LocalTime/MIN ZoneOffset/MIN))
@UCD54AV63 But results are different- maybe post this question into new thread, so more people can look at it.
Hey everyone! Total noob question here, but if I have a list of arbitrary nested lists and/or vectors, like:
((1 2 3) ((("a" "b") ([1] ("foo" "bar"))) [10 20])
And from this would want to create a sequence of lists/vectors (original type not important here) of the lists containing something which is not another list/vector:
((1 2 3) ("a" "b") (1) ("foo" "bar") (10 20))
What would be the most straightforward way to accomplish that?Thanks @U0NCTKEV8! I did encounter that in my search, but probably failed to use it properly. Given the input provided above, what would a call to produce my desired result look like?
Tree-seq to pull everything apart, filter to remove single elements and collections of collections
Something to keep in mind, if you are generating the sequence, usually as you generate it you have exactly the information you need to remove the nesting you want to remove, while keeping what you want
If you restructure after generating it is more of a pain because you have to try and recover that information
the nesting is created by calling a function recursively â thereâs probably a more elegant solution where that is avoided to begin with, but Iâd be fine with simply dealing with the mess of the result after the fact at this point
still not sure what two functions Iâd provide to tree-seq
to have it flatten that structure like I want it to
Thanks! Bedtime here but Iâll take a closer look tomorrow. Appreciate your support :thumbsup:
(->> '((1 2 3) ((("a" "b") ([1] ("foo" "bar"))) [10 20]))
(tree-seq coll? identity)
(filter #(and (coll? %)
(every? (complement coll?) %))))
=> ((1 2 3) ("a" "b") [1] ("foo" "bar") [10 20])
Can you also post the source code of function that produces this result? What were you trying to achieve?