Fork me on GitHub
#clojurescript
<
2016-12-09
>
stbgz00:12:07

hey guys what’s the easiest way to debug cljs code on node with cursive?, does it just work?

dnolen00:12:43

@stbgz there’s not a great way to do that yet

stevechan04:12:52

@dnolen , @anmonteiro, It’s work ok now, Thanks for your help 👍 👍 👍

xificurC08:12:06

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)

thheller08:12:54

@xifi node.clj is a script technically and should be at the top level (next to cljs.jar)

thheller08:12:07

if you follow the quick start word for word that is

thheller08:12:42

so not in src/hello_world

xificurC08:12:01

@thheller and that concludes I cannot read well. Thanks

thheller09:12:24

not sure that this is actually mentioned anywhere explicitly

xificurC09:12:24

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"

rauh09:12:05

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

thheller10:12:29

@rauh if you want to see something real scary do it in a core.async go 😉

thheller10:12:11

but :advanced compilation cuts the js size down quite a bit, so I wouldn't worry about it too much

rauh10:12:16

@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

rauh11:12:11

TIL: Adding a ^seq type hint avoids truthy tests. since 2012 🙂

rauh11:12:01

Should I add this to the hinting section on the wiki?

val_waeselynck11:12:47

@rauh in what context? Can you give an example?

rauh11:12:19

(defn ^seq xt []
  ())
(defn xnt []
  ())

(fn []
  (when (xt)
    (pr 1))
  (when (xnt)
    (pr 2)))

rauh11:12:30

REPL the last fn and check out the code produced. It doesn't include the truthy test for the first example.

rauh11:12:40

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

rauh11:12:40

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?

charafau12:12:16

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 ?

savelichalex12:12:18

@charafau try use re-natal use-component react-native-material-design and then re-natal use-figwheel. And there is #cljsrn for this questions)

dnolen12:12:27

@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.

dnolen12:12:31

@charafau might also want to check #cljsrn which is focused on React Native

charafau12:12:38

thank you I will try with that command first

ambrosebs13:12:46

"Clojurescript for skeptics" inspired me to fix the typed-cljs checker. awesome talk 🙂

dnolen13:12:35

yeah that’s a really good talk

val_waeselynck14:12:28

@rauh I see, thanks for the example.

val_waeselynck14:12:12

so cool that I can use Lumo to try this stuff out in one second

val_waeselynck14:12:23

@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) ?

dnolen14:12:48

@val_waeselynck more things in ClojureScript are functions than just functions

dnolen14:12:08

maps, sets, vectors, etc.

dnolen14:12:51

though that post talks about how we try to avoid .call if we can

mitchelkuijpers14:12:44

That talk rocks thanks @ambrosebs

ambrosebs17:12:04

@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?

dnolen17:12:36

@ambrosebs cljs.analyzer.api has something more like resolve

ambrosebs17:12:03

excellent 🙂

dnolen17:12:12

#cljs-dev is better place for questions like this though 🙂

mac20:12:08

@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?

anmonteiro20:12:27

@mac Object.assign is different from CLJS's immutable data structures because the resulting objects don't share memory with each other

anmonteiro20:12:05

my understanding is that it creates a copy of the objects you pass as arguments

anmonteiro20:12:39

Clojure(Script)'s data structures use structural sharing to provide memory efficient and performant data structures

mac20:12:02

@anmonteiro That was also my understanding, but several participants claimed that only the reference to the changed part is replaced.

anmonteiro20:12:04

I'm not sure what they mean by that, but there's no structural sharing in Object.assign

anmonteiro20:12:14

Immutable.js would be a strong contender though

mac20:12:35

@anmonteiro My words exactly 🙂

matthavener20:12:43

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

matthavener20:12:05

Of course.. its extremely limited compared to immutable.js or cljs datastructures 🙂

anmonteiro20:12:46

right, that explains it

anmonteiro20:12:08

and that's even worse than deep copying the whole stuff

anmonteiro20:12:15

since it's not immutable at all 🙂

mac20:12:52

@matthavener @anmonteiro I which ways is this not as good as real immutability?

mac20:12:25

immutability = persistent datastructures?

mac20:12:54

I mean immutability via persistent datastructures.

matthavener21:12:20

it only works one level deep, imagine if you had b.foo.baz.buz and you wanted a ‘updated’ b that ‘changed’ buz

matthavener21:12:10

plus, its only the limited semantics of javascript Objects-as-a-map.. string keys, no arrays, sets, etc.

anmonteiro21:12:10

@mac plus you can't do equality checks

anmonteiro21:12:52

sorry, that came out wrong

anmonteiro21:12:02

you can't do efficient (deep) equality checks

mac21:12:45

Well, if it only works one level deep that's not going to be an issue anyway 🙂

jr21:12:22

it's an issue for an object with more than 1 property

dnolen22:12:14

yes the only comparable thing is if you’re using Immutable.js (I’m not aware of another comprehensive data structure lib)

dnolen22:12:38

it’s not as popular as it deserves to be since there’s no syntactical support

dnolen22:12:42

we don’t have that problem 🙂