This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-22
Channels
- # announcements (2)
- # beginners (42)
- # calva (2)
- # cider (13)
- # clara (2)
- # cljdoc (1)
- # cljs-dev (8)
- # clojure (118)
- # clojure-australia (1)
- # clojure-europe (3)
- # clojure-finland (2)
- # clojure-italy (42)
- # clojure-japan (1)
- # clojure-nl (2)
- # clojure-spec (26)
- # clojure-uk (58)
- # clojurescript (83)
- # cursive (6)
- # data-science (2)
- # datomic (13)
- # devcards (2)
- # duct (9)
- # figwheel-main (4)
- # fulcro (11)
- # graphql (51)
- # jobs (1)
- # juxt (14)
- # kaocha (1)
- # off-topic (24)
- # re-frame (65)
- # reagent (4)
- # reitit (19)
- # remote-jobs (8)
- # shadow-cljs (50)
- # specter (3)
- # speculative (1)
- # vim (5)
- # yada (50)
Hey y'all, gotta fresh toy here for ya: Kanaka's latest Mal over WASM, ported to ClojureScript and using tau.alpha for blocking reads, running in a browser REPL, producing a Mal REPL: Malhala https://github.com/johnmn3/malhala
i'm looking for a presentation of figwheel and reagent where you could follow along as tetris was implemented. does anybody have the link? i can't find it anymore š
Has anyone worked with Klipse as a library? I want to have some live-rendered snippets of reagent (as part of an interactive tutorial), but I want to call Klipse as a library from ClojureScript. Is this even possible?
Itās tricky, because Klipse needs self-hosted CLJS, but I want the tutorial to be able to seamlessly reuse whatever lies around in my project which is compiled by shadow. I might have to look into actually using filesā¦
Just watched the talk āfunctional programming in angerā, where David said that now you could require any npm lib, and there is no need to write externs manually. Thatās cool. But I canāt figure out how to actually do this. Can someone please provide an example? Should you use foreign-libs, npm-deps, infer-externs etc? Also it would be awesome to include this into get started tutorial.
@romantsopin I think he was referring to https://clojurescript.org/guides/webpack and https://clojurescript.org/guides/externs
Thanks, I actually read those, but couldnāt figure out how to apply them in my case (empty cljs project and leftpad installed from npm)
lol, can someone help, I've been up for a thousand years. what's the best way to just get a pretty print formatted string in cljs
so I have some json, I want to edit it in a textarea in my browser, and I want it to be pretty printed
if you want to edit it as json, I donāt know. you could look for some existing react lib for it, or use codemirror, I donāt know
@idiomancy if you just want pretty printed JSON and not EDN you can just use (js/JSON.stringify (clj->js {:some "data"}) nil 2)
but its like, I want it to look like this (I pasted it into an IDE and used the auto-reformat and pasted it back)
I never knew you could pass additional args to stringify
to control the formatting
How do you require namespaces in cljs REPL? I tried (require '[my.namespace :as x])
, but x/....
doesn't work.
have you changed anything after the first load? then you could try: (require '[my.namespace :as x] :reload)
so hereās a good one: how do you convince someone who doesnāt know what they donāt know (and is convinced theyāre right) to look into clojurescript when ānah man i dont like abstractions over raw jsā is their line of thinking? react/redux āis the best thingā and re-frame is just silliness.
for example, I came from the react/redux world into Clojure(Script) because I was exploring things that were already being talked about by the people I respected in those communities: - immutability - hot reloading - new syntax
when I started trying out Clojure, it was because I had tried and struggled with those 3 things and had heard that Clojure(Script) had them all by default š
but those values didnāt come from Clojureā¦ I already had them from listening to Dan Abramov, Jordan Walke, etc.
well, presumably immutability because they keep the mental overhead of using {... spread, a: 1}
syntax everywhere. or they use immer/immutablejs. they have a lot to setup to get hot reloading, but admittedly you usually only have to do that once. itās like im missing a piece to make it āclickā.
for them things like javascripts object equality by reference instead of value isnāt a problem š
I mean, for most people it isnāt. you might think it is, but to them youāre just inventing problems š
maybe if you related that to componentDidUpdate and having to use immer/immutablejs. I canāt imagine someone using immutablejs in anger and not wanting to burn their project to the ground.
it sounds like this person is happy. are you trying to convince them for some reason?
yes, i want to use cljs + reframe when we have to build SPAs (not often, but often enough). the react/redux stack very often seems like pouring concrete and i know thereās better ways š
its a consultancy, so occasionally but not all the time. unfortunately we try to standardize on a stack for new projects. if thereās not agreement i think weāre going to default to some js framework simply because itās least far from the familiar
Iāve been through this recently @lwhorton. I think itās impossible, because the things ClojureScript brings to the table manifest over a longer period of time, and they also require a considerable up-front investment. So people who feel productive in their local maximum are reluctant to change.
One argument I had is that Clojure incorporates into the language many concepts that in JS you need to have a framework for. E.g. the succession model with atoms that can replace redux entirely. Also a standard library.
In the end, it feels like youāre in a Monty Python sketch arguing about what the romans ever did for us.
one tactic I've used with a bit of success in that argument is to rebuild something - and not just a prototype, but a full reimplementation of some part of the app, real data and all - and then show (1) how much smaller and simpler the code is, and (2) how much more quickly I wrote it. the conclusions are either that these proposed tools are more powerful and allow us to do more with less code in less time, or that I'm way smarter and more productive than whoever wrote the original code, which seems unlikely.
both arguments fall apart if there's even one footnote on the reimplementation; it needs to be real.
because if there's even one tiny crack, it will become the explanation for everything, rather than the language.
(even if it's completely impossible for the tiny crack to cause the four-fold code size reduction, etc. etc. you can probably hear how many frustrating and circular arguments we had about this.)
(caveat, for honesty: I failed to ultimately persuade my team. there was an irredeemable "crack": Javascript is an officially supported language inside Google, and ClojureScript is not. never mind that both go through the Closure compiler and ultimately result in Javascript code for the user's browser to run.)
i actually did a complete rewrite of an existing clientās SPA. it was verbatim a copy-paste at 4.8x less code and it took me a week vs. 2 months. š
I know that feeling. there's a bottomless well of frustrating counterarguments people use. "oh, we can use this library and reduce our code size by 20%." "yes, but I'm talking about a five-fold reduction in code size."
I'm pitching a drop-in replacement thing at work right now unrelated to Clojure, it shrinks a block of generated JS by 20x, from 1.1MB to 70KB.
my detractors propose changing the generation options to reduce the size by ~30%, and having to change all the call sites.
but I had converts, which is something.
@lwhorton I typically express shock along with a disingenuous attempt at empathy for those using raw js. OMG you actually live without core.async?
i feel similarly. itās hard not to be disingenuous, and sadly that makes us lispers often look pretty arrogant (i think). if youāre on the outside looking in, you donāt know what you donāt know.
> makes us lispers often look pretty arrogantā¦ true, but Iām suggesting a response to arrogance + I tend to smile š itās hard to be arrogant (at least for me) when you smile
Hi, I'm trying to compute a d3 pack layout from some cljs data. It works quite well, but when I convert the result back with js->clj
, I just get #object[Node [object Object]]
... Any idea how to turn that into useful data again, or do I have to recurse through it myself?
json.stringify works on it, after I removed the parent
field from it, which otherwise makes it circular -.-
define multimethods in runtime is a bad thing to cljs? example
(defmulti foo ...)
(defn main []
(defmethod foo ... ))
we certainly don't check for problems you might encounter doing that and don't have plans to
defmethod
is just sugar over (-add-method foo :val (fn [...] ...))
so you could use that directly instead too. defmethod
doesn't actually def
anything so I'd say its fine.
but imho its probably a code smell if you do that because you need access to extra state in the function definition. something that should probably be passed as an arg
well I would argue the problem here is unmanaged manipulation of global state - def
and defmethod
both do that - so I'd still argue probably not fine š
unless you're doing something special that really calls for it anyway - I would avoid the pattern
Is there any guides on using ClojureScriptās browser events API? I found wrappers https://github.com/clojure/clojurescript/blob/master/src/main/cljs/clojure/browser/event.cljs but havenāt been able to locate any API docs
@jayzawrotny that ns exist primarily for historical reasons