This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-11
Channels
- # aleph (4)
- # beginners (68)
- # boot (21)
- # chestnut (1)
- # cljs-dev (72)
- # clojure (64)
- # clojure-austin (9)
- # clojure-dusseldorf (16)
- # clojure-gamedev (2)
- # clojure-italy (32)
- # clojure-russia (80)
- # clojure-spec (9)
- # clojure-uk (20)
- # clojurescript (105)
- # cursive (5)
- # data-science (5)
- # datomic (23)
- # defnpodcast (3)
- # emacs (22)
- # fulcro (2)
- # graphql (63)
- # hoplon (7)
- # lein-figwheel (17)
- # lumo (63)
- # mount (2)
- # nrepl (4)
- # off-topic (66)
- # om (6)
- # onyx (3)
- # portkey (54)
- # re-frame (12)
- # reagent (12)
- # specter (42)
- # uncomplicate (1)
- # unrepl (38)
- # vim (9)
- # yada (3)
In CLJS, what is the best way to make AJAX calls? I see there is this library https://github.com/r0man/cljs-http but could one just as easily use js/fetch
and if so, is there a pro to using a library?
There is some way to run closure-compiler "simple"
> prepack
> closure-compier "adv"
with cljs-build
?
is it possible clojure 1.9.0-alpha20 breaks a lot of cljs tooling? i've had a lot of trouble using it with cljs on both figwheel (lein) and boot-cljs. i think part of it has to do with handling of NaN in cljs; i'm seeing things like ##NaN
in the cljs.test build output. works fine on alpha19
"Invalid format: 1504569600000 is malformed at ("0" "0" "0" "0" "0")"
Anyone come across similar errors in advanced compilation? Everything works fine with no optimizations and I can't work out where the problem is.
I'm working with dates, the number is a js/Date .UTC
The error was coming from somewhere in cljs-time and I fixed it.
Comming to clojure(script) from a react/js/node background I'm a bit confused as to what libraries I should try first. Any suggestions?
@karlstefan What do you want to do? A good thing about Clojurescript is that you have easy access to Google Closure. This and the language itself cover a lot that you might usually need libraries for.
Is google closure still, to this date, superior to the latest solutions available with webpack and co @danielstockton
@hmaurer I'm pretty sure webpack is still behind in terms of dead code elimination and code splitting, mainly because closure is written in such an explicit/verbose style.
(->> [] (apply max))
is nil
. (->> [] (apply max) inc)
is NaN
. But (inc nil)
isn't NaN
, it's 1
. What am I missing here?
Hi. At advanced compilation, I try to leave out foreign libs like React and load them separate. I like to do it because we have many apps using the same React version (and other foreign libs). Is it even a good idea not to have one big JS file these days?
I filed https://dev.clojure.org/jira/browse/CLJS-2358 for the inc issue
@akiel you might want to look at https://clojurescript.org/guides/code-splitting
@lxsameer I know this. My understanding is that you split your code by functionality used at different sites. But foreign libs would go to cljs-base. Than I have a different cljs-base per app, because I use different stuff from cljs itself. I like to separate stuff like React because it won’t be touched by advanced compilation.
@thheller Ok leaving them out and only use the externs would mean, that I build my own version of the cljsjs react lib - right?
yeah it requires a bit of minor tweaking since things like reagent expect to find cljsjs.react (in non-beta versions)
the common approach is to a create an empty namespace for everything that would otherwise be provided by the foreign libs
@mbertheau My understanding is that js awesomely has two kinds of null and cljs treats them both as nil
, except when it doesn't and the js madness leaks through
correction to the above:
(inc js/undefined)
NaN
^ there’s your issue
And just to add to the madness: (number? NaN) ;; true
from node
~ node --version
v8.4.0
~ node
> typeof NaN
'number'
clojure is hosted. Will/should not introduce a new number logic.@mbertheau the JIRA issue you opened is not a bug, in general it’s best to ask here and wait for someone who contributes to ClojureScript to respond before opening an issue
and we do not currently check primitive arithmetic ops like (inc ...)
for perf reasons
@dnolen Ok, but I still don't understand what's going on. A call to max
isn't arity-checked, so it's value is what? And second, why does it matter how inc
got its argument value (if (apply max [])
does evaluate to nil
)?
if something throws in Clojure and it doesn’t throw in ClojureScript it’s safe to assumed it’s behavior is undefined in ClojureScript
@dnolen Is it wrong to say that (apply max [])
is JS undefined
, and nil
is JS null
, and JS undefined + 1
is NaN
, whereas JS null + 1
is 1?
it could throw if we come with a reasonable way to do that, so you cannot depend on the result
@mbertheau it doesn’t matter what it currently is
It does matter in practice to me because knowing which things have "undefined behaviour" without compiler support is quite hard
After all, in practice, ClojureScript behaviour has to be explained to the developer who uses it in terms of the various JS VMs execution environments
Hmm, I don't know how relevant the JS spec is in practice. What matters to the developer right now is what browsers actually do.
@mbertheau what?
anyways, we could probably solve the arithmetic issues but it would be fairly dramatic change with wide ranging repercussion
which aren’t obvious if you haven’t been following ClojureScript dev for the last 6 years
I don't deny that, I just need to know what's going on. You have to admit that the behaviour described in the beginning is very unexpected to the unsuspecting developer.
for some ideas about how this might be done read https://clojurescript.org/news/2017-07-14-checked-array-access
So the take-away is, when you get nil
from something, it can be JS undefined
or JS null
, which behave differently in different situations.
What exactly does "treat" mean in that context? When are JS undefined
and JS null
"coerced" to nil
?
Ok. So when you see an expression printed as nil
or test if for nil
, be aware that using the same expression in a different context may not be the same as using nil
in that context, because the JS value can actually be undefined
or null
.
@dnolen Is there a list of things the behaviour of which are undefined? Or is just the missing arity-checking?
The unsuspecting developer can't tell that the nil
they see in the repl is actually an invalid value.
@mbertheau there’s no list, there’s lot of little edge cases
@mbertheau you can’t pass nil
to inc
Saying (inc nil)
is meaningless may be the extent to that ClojureScript cares, but since that code compiles and a similar situation can easily appear in practice, its meaning in JS matters a lot to a developer in my opinion.
Allright with me, I have my take-away. Thanks for your work with CLJS! I enjoy it very much 🙂
Anyone have a recommendation for a clojurescript webgl/canvas library? Perhaps something that integrates with Pixie?
http://thi.ng/ or https://github.com/thi-ng/ has everything you're looking for, and then more, and then even more / with a gitter community to boot