This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-09
Channels
- # adventofcode (187)
- # aws (1)
- # aws-lambda (1)
- # beginners (162)
- # boot (64)
- # cljs-dev (6)
- # cljsjs (2)
- # cljsrn (32)
- # clojure (357)
- # clojure-greece (1)
- # clojure-korea (4)
- # clojure-russia (63)
- # clojure-sanfrancisco (3)
- # clojure-spec (91)
- # clojure-uk (63)
- # clojurescript (74)
- # clojurex (10)
- # code-reviews (55)
- # core-async (4)
- # core-typed (1)
- # cursive (17)
- # datascript (36)
- # datomic (43)
- # devcards (4)
- # dirac (3)
- # emacs (59)
- # hoplon (286)
- # jobs-discuss (399)
- # luminus (4)
- # mount (9)
- # off-topic (30)
- # onyx (53)
- # protorepl (3)
- # re-frame (88)
- # reagent (4)
- # spacemacs (1)
- # specter (14)
- # untangled (1)
- # vim (42)
hey guys what’s the easiest way to debug cljs code on node with cursive?, does it just work?
@dnolen , @anmonteiro, It’s work ok now, Thanks for your help 👍 👍 👍
going through https://github.com/clojure/clojurescript/wiki/Quick-Start I downloaded the cljs.jar, created the directory structure and files. I'm trying out the node example. My fs looks like this:
.
├── cljs.jar
└── src
└── hello_world
├── core.cljs
└── node.clj
The compilation command in the wiki fails for me though:
$ java -cp cljs.jar:src clojure.main node.clj
Exception in thread "main" java.io.FileNotFoundException: node.clj (No such file or directory)
@xifi node.clj
is a script technically and should be at the top level (next to cljs.jar)
it's mentioned in the beginning when creating the first build file, build.clj
- "Create a file called build.clj in the current directory not in src"
Dang, doseq
does create a surprising amount of code:
(count
(str
(macroexpand-1
'(doseq [a b c d e f g h i j]
[a c e g i]))))
=> 22367
(count
(str
(macroexpand-1
'(for [a b c d e f g h i j]
[a c e g i]))))
=> 2577
but :advanced
compilation cuts the js size down quite a bit, so I wouldn't worry about it too much
@thheller Yeah I was just surprised that it is so much more than for
, I would've imagined it being less. But I guess it's for pure speed
@rauh in what context? Can you give an example?
REPL the last fn
and check out the code produced. It doesn't include the truthy test for the first example.
Since javascripts' trythy is really messed up, most of the if/when etc
you write will be wrapped in the truthy checks. I knew of the ^boolean
tag but the ^seq
tag is also nice to know
now that I think of it, there is few more functions in core that could probably use a seq
? @dnolen : Why doesn't reverse
, list
have a ^seq
type hint?
hello everyone! I've seen some presentations about clojurescript and react native and decided to give it a try. I got sample app with re-natal and android but now I wanted to add some material design so I installed reat native material design components according to this https://github.com/react-native-material-design/react-native-material-design and when I'm importing namespace in clojure with (set! js/MaterialDesign (js/require “react-native-material-design”))
I got an 'unknown named module’
error. Are there some tips how to set it up somewhere ?
@charafau try use re-natal use-component react-native-material-design
and then re-natal use-figwheel
. And there is #cljsrn for this questions)
@rauh I haven’t really been able to quantify the value of ^seq
for non-toy stuff. ^boolean
is obvious - we need need it at the bottom. Not interested in documenting it at this time.
"Clojurescript for skeptics" inspired me to fix the typed-cljs checker. awesome talk 🙂
@rauh I see, thanks for the example.
so cool that I can use Lumo to try this stuff out in one second
@rauh since you seem to be knowledgable about this, could you tell me why all the CLJS function calls compile to f.call(null, ...)
(instead of just the f(...)
syntax) ?
@val_waeselynck more things in ClojureScript are functions than just functions
guess you already explained this here: http://swannodette.github.io/2015/03/16/optimizing-clojurescript-function-invocation, right ?
That talk rocks thanks @ambrosebs
@dnolen I'm looking for a cljs analyzer function that acts like clojure.core/resolve
. It seems resolve-var/resolve-symbol both return the input symbol, even if it's unresolvable. Does it exist?
@ambrosebs cljs.analyzer.api
has something more like resolve
@dnolen I was giving an intro talk to cljs to a room of js devs a few nights ago. I of course mentioned immutability as a big cljs win. A few of the participants mentioned the use of Object.assign
as a viable alternative to library (immutable.js) or language (cljs) based immutability / persistent datastructures when using. I have limited knowledge of Javascript but I am under the impression that using Object.assign()
in practice you incur a significant memory / performance overhead. What is your take on this?
@mac Object.assign
is different from CLJS's immutable data structures because the resulting objects don't share memory with each other
my understanding is that it creates a copy of the objects you pass as arguments
Clojure(Script)'s data structures use structural sharing to provide memory efficient and performant data structures
@anmonteiro That was also my understanding, but several participants claimed that only the reference to the changed part is replaced.
I'm not sure what they mean by that, but there's no structural sharing in Object.assign
Immutable.js
would be a strong contender though
@anmonteiro My words exactly 🙂
I think they’re referring to the use of Object.assign to simulate structural sharing. Since
Object.assign({}, foo)
is just a shallow copy of foo
, if you had something like a = SomeLargeObject(); b = {foo: a, bar: 1}; c = Object.assign({}, b); c.bar = 2;
, you’re “structurally sharing” the value of a
Of course.. its extremely limited compared to immutable.js or cljs datastructures 🙂
right, that explains it
and that's even worse than deep copying the whole stuff
since it's not immutable at all 🙂
@matthavener @anmonteiro I which ways is this not as good as real immutability?
it only works one level deep, imagine if you had b.foo.baz.buz and you wanted a ‘updated’ b that ‘changed’ buz
plus, its only the limited semantics of javascript Objects-as-a-map.. string keys, no arrays, sets, etc.
@matthavener Ok, i see.
@mac plus you can't do equality checks
sorry, that came out wrong
you can't do efficient (deep) equality checks