This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-26
Channels
- # aleph (1)
- # beginners (96)
- # boot (5)
- # cider (44)
- # cljdoc (11)
- # clojure (73)
- # clojure-conj (4)
- # clojure-dev (1)
- # clojure-finland (2)
- # clojure-italy (7)
- # clojure-new-zealand (1)
- # clojure-nl (3)
- # clojure-spec (4)
- # clojure-uk (66)
- # clojurescript (114)
- # code-reviews (16)
- # cursive (15)
- # datomic (37)
- # emacs (6)
- # events (2)
- # figwheel-main (12)
- # fulcro (36)
- # graphql (19)
- # hoplon (2)
- # hyperfiddle (3)
- # jobs (2)
- # leiningen (4)
- # off-topic (36)
- # om (1)
- # om-next (2)
- # other-languages (1)
- # re-frame (12)
- # reagent (12)
- # reitit (5)
- # remote-jobs (4)
- # ring (2)
- # shadow-cljs (218)
- # spacemacs (8)
- # specter (7)
- # sql (34)
- # tools-deps (9)
- # uncomplicate (6)
I need to pack a javascript lib that will be used in django/PHP/template-like sites by <script src...>
and myLib(....)
besides exporting, there is any other concerns ??
can my bundle become incompatible with other's bundle?
@souenzzo you mean you want to compile cljs to js and then include it via script tag in another js program?
if so, then I’m pretty sure that you cannot include more than one cljs-compiled bundle in a single environment
@souenzzo i’m just reporting what i’ve seen in this channel. you might hop into #shadow-cljs and describe what you are doing. there a lots of people who have been doing similar things
Hi all, I am using lein to build my re-frame project, and have hit a lot of trouble when trying to get cider working in Emacs. Long story, now my project won't build from the command lein or through Emacs. Here is the error:
error in process sentinel: Could not start nREPL server: java.lang.Exception: Error loading /home/aaron/Source/grownome-admin/project.clj
And more detailed: Caused by: clojure.lang.Compiler$CompilerException: java.lang.IllegalArgumentException: No value supplied for key: {:builds {:dev {:source-paths ["src/cljs"], :figwheel {:on-jsload "grownome-admin.core/mount-root"}, :compiler {:main grownome-admin.core, :output-to "resources/public/js/compiled/app.js", :output-dir "resources/public/js/compiled/out", :asset-path "js/compiled/out", :source-map-timestamp true, :preloads [devtools.preload day8.re-frame-10x.preload re-frisk.preload], :closure-defines {"re_frame.trace.trace_enabled_QMARK_" true, "day8.re_frame.tracing.trace_enabled_QMARK_" true}, :external-config {:devtools/config {:features-to-install :all}}}}, :min {:source-paths ["src/cljs"], :compiler {:main grownome-admin.core, :output-to "resources/public/js/compiled/app.js", :optimizations :advanced, :closure-defines {goog.DEBUG false}, :pretty-print false}}, :test {:source-paths ["src/cljs" "test/cljs"], :compiler {:main grownome-admin.runner, :output-to "resources/public/js/compiled/test.js", :output-dir "resources/public/js/compiled/test/out", :optimizations :none}}}}, compiling:(/home/aaron/Source/grownome-admin/project.clj:1:1)
I've tried formatting and modifying many things, and just can't figure out what is going on.
@thheller thank you! Man I've been losing my mind over this, especially on top of trying to get figwheel to work
Hey folks, got a new example of tau.alpha up on a github page, showing an automaton stress test both on the main thread and off the main thread: https://twitter.com/Doxosophoi/status/1022357248201379840
yeah, probably should have been a bit more explicit. It won't work unless you enable SharedArrayBuffers in <chrom://flags>
the only thing beautiful about this language is that you don’t have to worry about this crap haha. why is everybody mad.
so are you sharing the raster that backs the canvas directly? (assuming that’s a canvas)
I've got a version that doesn't use SharedArrayBuffers, instead passing Transferables. But there's still transfer overhead and the benefits wash out for a lot of scenarios.
so it gets a notification that there’s new stuff in the array and then copies that into the canvas? and there must be some kind of synchronization around the copy?
Yeah, the tau
implementation uses twice the memory you specify, on the inside. swap!
ing on it alternates the write point, so reads never block, like clojure atoms
notifications are still in progress. I haven't fixed up the add-watch solution for this SAB version
So in that example I'm using a separate, local atom to trigger a watcher, to restart the next render
that is Most Excellent. I would not have thought you could swap the full raster that fast.
but once I have watchers back up on this SAB implementation, we can just put the watch on the tau
itself and the implementation code for this example will be even more succinct.
The main thread automatons still run a little faster, but once you get all six of either scenario going, you can see the main thread scenario slows down too much, and the interface becomes unresponsive.
I saw Craig Andera give a demo that essentially involved drawing a map with some simulated weather effects, written in ClojureScript, and he had it calculating the weather for different regions in the canvas in background tasks in the browser. Perhaps something like this Tau stuff would have made it simpler for him to code up.
the memory management is naive right now. You have to know before hand how large your memory workload is.
A better memory management scheme might make it more general, but I see no avenue for expanding the size of SABs synchronously, on or off main thread, atm
I imagine the WASM folks will need to do that eventually though, in order to port over all these langs
where is the mathy stuff happening? in a webworker? i’m just trying to figure where that code is because i thought that you don’t have access to the canvas element in a webworker and so i was wondering how you are doing the drawing
It just runs across a 1d array, reading cells from the left and writing new ones to the right, as if it's a 2d array
It's probably not a fully faithful implementation. I just threw it together to show some brute force computations
FWIW, it is really good at making use of cores https://twitter.com/mfikes/status/1022550658522771456
damn well i’ll have to wait for offscreencanvas and shared memory to become mainstream 🙂
Personally I think if this path is efficacious, folks should be keeping their head-space on the webworker side and only push logic to the main thread as if it's just a screen
the demo is not written that way, but I may eventually have other examples that show doing things that way
the problem is if you need to draw a bunch of, say, text to the screen, you have to do that in the main thread afaict
If it ever happens (things like https://webkit.org/blog/7846/concurrent-javascript-it-can-work/) then ClojureScript is really primed to work well in this space (small experiment https://github.com/mfikes/mt-cljs)
and with a non-SAB implementation, you could have an isomorphic "pool" of tauons that are on both the server and client, but appear to be local to one aonther
We're def primed to "fix" JS's concurrency problems, once they're ready to take them on 😉
Or you could merge multiple tauon pools between multiple node instances. The webworker and the websocket postMessage interface are very similar
Hi. Just wondering - does figwheel play nicely with CIDER at all, or is it always inf-clojure that people use?
@mfikes what I like about the tau method over the mt method you showed, is that in this tau scheme, threads are still uninterruptible, so a given js context is still semantically consistent. You can only "wake" a thread up via the single response a particular thread is waiting on.
So you have to structure things circularly, but some of the apparent benefits of singlethreadedness from the js world is still maintained
@clojuriansslack722 I always used it with cider. Working with shadow-cljs lately, but especially with cider 0.18.0 it should work.
I just think agents will be a convenient minimal interface to operate over tauons in some scenarios
Maybe a SAB-backed agent would largely “just work” without having to revise the code ClojureScript emits. :thinking_face:
(If you abide by some mild constraints in your code, like not messing with the state the agent operates upon, behind its back.)
Ahh, so maybe if you do something like (agent x)
, no matter what the value of x
is, a copy would be made for the SAB impl, and it can party on that copy.
@clojuriansslack722 tried https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl?
admittedly it's a bit verbose and not all steps might be needed anymore, cider 0.18.0 addresses this by making it more easy (i.e. a wizard that asks some steps)
latest figwheel: https://cider.readthedocs.io/en/latest/clojurescript/#using-figwheel-main older figwheel (the lein figwheel docs I sent previously do this approach kinda): https://cider.readthedocs.io/en/latest/clojurescript/#using-figwheel-leiningen-only
@bbss "Even though this has recently become easier, you should still consider setting up a workflow that includes nREPL as an advanced undertaking as it requires a lot of contextual knowledge of the Clojure environment if something goes wrong.", eep.
Yeah then go with that using-figwheel-main link, it's meant to have made it a tad easier.
I haven't thought about the SAB backed implementation of agents in a little while. But the non-SAB backed version, each send basically fanned tasks out to a pool of tauons that didn't share state between them.
For a SAB backed version, anyone waiting to write on a particular shared tau will block their thread while waiting for access.
Any recommendations for Clojurescript podcasts?
Anyone have any strong opinions either way for https://material-ui.com/ or https://ant.design/docs/react/introduce with CLJS?
@dijonkitchen I have, I have! I love material-ui, and have been using the latest version a bit. The older version has https://github.com/madvas/cljs-react-material-ui/ but I think the maintainer hasn't got time to figure out the new version (it's quite a drastic change).
I tried upgrading it on this fork, but was unable to get it working for my project. https://github.com/stephenway/cljs-material-ui
The way I use it does depend on #shadow-cljs ability to import npm packages easily, but I guess it could be done with recent improvements to cljs compiler/figwheel as well. I basically wrote a macro in clojure to take all the dirs in the node_modules
dir of @material-ui/core
. That, matches up with the components in the docs. Then I generated a big file with all those Symbols, and called a factory react creating function on them. It's ugly as I'm not sure how it advanced-compile/tree-shakes (probably not well). But I'm able to use it like I would any ported cljs react library. Input fields work (they can be tricky to port), and every other thing I've tried so far works too.
http://cljsjs.github.io/ doesn’t help instead of npm-deps
or shadow-cljs
?
anyone know if there’s a way of stopping execution as a result of a (when)? kind of like an empty return in javascript
I tried some basic stuff with the cljsjs/material-ui
one and it was OK.
@stephenway what do you mean by stopping execution?
I hadn't seen the cljsjs version. I probably would have gone with that if I hadn't hacked my own version. But yeah it does mention the inclusion of its own react versions: https://github.com/cljsjs/packages/tree/master/material-ui
In js if i do something like if (disableMyFeature) { return; }
it will stop executing beyond that line inside the function and return undefined. In cljs I could do something like (when disableMyFeature js/undefined)
but I’m unsure if it will stop at that point?
@stephen you'd need to slurp the body that you don't want executed into a (when (not disabledMyFeature) body)
@stephenway not really. check out this thread for a deeper discussion https://stackoverflow.com/questions/7491360/how-do-you-return-from-a-function-early-in-clojure
@lee.justin.m thanks, I’ll check that out