Fork me on GitHub
#clojurescript
<
2016-12-12
>
jrheard03:12:24

@flyboarder my 2c - i think that the article suffers by being a series of inline responses to the body of the original how-it-feels-to-learn-js-in-2016 post. makes it feel a bit disjointed and a bit difficult to read IMO. i think you might be able to make your argument much better if it were written in the form of a regular post/article/essay/etc rather than as a series of quotes/responses - also this way you wouldn鈥檛 have to repeat yourself quite as often, since you鈥檇 be controlling the bits of the essay and the order that they appear in. hope this is helpful 馃檪

flyboarder03:12:01

@jrheard thanks for the suggestion, I will probably go back and remove some of the inline stuff.

wildermuthn03:12:24

@puppybits I like this part: ClojureScript core.async is like the green wrap tubes in Super Mario Bros 馃檪

wildermuthn03:12:47

Minor typo with wrap vs warp

meeli04:12:58

@puppybits i鈥檓 leaving you some edits/comments

puppybits04:12:12

@wildermuthn @meeli Thanks a ton for reviewing it. I'm rereading through it now to clear up spelling/grammatical errors.

puppybits04:12:09

Any edit or suggestions you have are great.

meeli04:12:37

peer review for blog posts 馃憤

meeli04:12:01

it鈥檚 a great post

meeli04:12:48

hope i helped!!

puppybits07:12:31

@meeli Thanks for the feedback. It feels so much more polished with your recommendations. I really appreciate it.

meeli07:12:26

awesome 馃檪

octahedrion08:12:27

in Clojurescript, why can't i use fns defined in a .clj macro namespace from a .cljs namespace ?

octahedrion08:12:56

(i can only use macros defined in the .clj macro namespace, not functions)

henriklundahl09:12:25

@octo221 I believe you can if you rename the file to .cljc. You'll need to use reader conditionals for stuff not available in ClojureScript.

rauh09:12:46

Ever wanted to use goog enums in a case? Here you can generate a NS so that you can: https://gist.github.com/rauhs/098a720669c75e53eb00dc3e6ed58e49

hlolli10:12:33

does anybody have an css trick up their sleeve for avoiding to style js libs within cljs. Then I mean when a library gives you endpoints like nestedListStyle titleTextStyle etc, any css function available that I could simply say :nestedListStyle #js { extend everything from class x}?

Aron10:12:27

what to use if i want to include something from npm?

martinklepsch10:12:17

@rauh seems like this might be a nice optimization language-wide, think there's a way to do that?

rauh10:12:03

@martinklepsch Doubt it, you first need to eval javascript to get the objects in question, walk and filter them. Then output something to the compiler, which can only be done during macroexpansion.

martinklepsch10:12:18

@rauh would it work if goog.events.KeyCodes had a ^:const annotation?

martinklepsch10:12:52

@rauh not thinking in terms of writing some macro but rather enhancing the Closure<>CLJS integration for all of CLJS in this way

rauh10:12:04

No the clojurescript compiler wants a var with a :const metadata to allow case constants

rauh10:12:00

I think the problems will be that clojurescript can't really analyze google closure (js) code.

rauh10:12:48

There is a potential for a new clojurescript construct that allows much more flexiblity in the case: constructs, but I doubt that'd be considered since Java is less flexible and then we'd brake clojure<->cljs compatibility

rauh10:12:40

For instance javascript allows switch (true) {case: (bar < x && bar > y) doit();}

rauh10:12:05

But the JVM is much more restrictive so that's why it's also a no-go in cljs

rauh10:12:06

IMO, the closure compiler could optimize nested if/else's into such a construct.

martinklepsch10:12:56

If the conditions are expensive that wouldn't end up being more optimal would it?

rauh10:12:54

Yeah doubt it, it's also such a microoptimization that it's probably not worth it.

rauh10:12:30

I mainly wanted it for readability and multiple case constants: (case x (ENTER ESC ALT) (doit))

martinklepsch10:12:50

Yeah, totally agree that that's nice

Aron11:12:04

how to require and use an npm module inside clojurescript? i found https://github.com/RyanMcG/lein-npm this but it talks about things i don't want to do, and it doesn't talk about the thing i want to do

xificurC11:12:43

I'm trying to use core.async in nodejs but a (go (>! c 5)) throws a Could not resolve var >! error, more info here - http://sprunge.us/LiJI . What could be the reason? I have cljs 1.9.293 and async 0.2.395 as dependencies

xificurC11:12:36

if I do (put! c 5) and then (go (println (<! 5))) I even get Could not resolve println, which is kind of funny

Aron11:12:40

ok, whatever, i give up

Aron11:12:47

impossible

Aron11:12:20

when i decided to try clojurescript, i believed that interop with javascript is beyond the most obvious let's just put properties on the global variables and let's hope nothing overwrites them...

Aron11:12:20

not even an answer? so questions that are not interesting to the community are ignored everywhere, this really shows the experience i am living right now, where i feel that i was told a lie so many times i believed it

xificurC11:12:42

@ashnur not many people use cljs on top of nodejs. As you can see from my question above I'm having similar issues. It's not that questions are ignored, there just aren't many people that could give an answer

Aron11:12:15

why do you think i am using it on nodejs? i am not and i never talked about using it on top of nodejs

Aron11:12:31

"never" as in not today 馃槃

xificurC11:12:01

@ashnur I figured the web modules are mostly covered with https://cljsjs.github.io/

Aron11:12:18

and when i say ignored, i mean that for weeks i've been asking questions regularly on several channels on this slack and the weather is more reliable than trying to get help

Aron11:12:07

and i see many people asking the same questions and being left unanswered by the "community"

xificurC12:12:32

if slack doesn't work then some mailing list might have more luck?

Aron12:12:53

i just linked the same question from the mailing list from a year ago

Aron12:12:08

and there was not a single person writing a single response

Aron12:12:34

telling the OP that their solution is a hack and not a good idea in general perhaps unless they don't plan maintaining the code

xificurC12:12:50

noone's gonna answer a 1yo question today. And that question is from Dec 25th and he kind of answered his own question

Aron12:12:59

found this now

thheller12:12:41

@ashnur what are you trying to do?

thheller12:12:15

when you want to use a npm module, you are going to need npm

Aron12:12:16

specify an npm dependency and use it

Aron12:12:33

i already installed the lein-npm plugin

thheller12:12:33

CLJS does not interact with it in any way

Aron12:12:54

ok, so you are telling me to go elsewhere with my questions then?

thheller12:12:32

just saying that the answer to your question is to use npm

thheller12:12:50

wether that is wrapped by lein-npm or not

Aron12:12:37

that's not an answer, maybe a piece of an answer 馃檪

thheller12:12:03

well you only gave part of the question

thheller12:12:14

where do you want to use it?

thheller12:12:17

node / browser?

Aron12:12:59

it shouldn't matter, but browser

Aron12:12:04

the code is not API dependent

thheller12:12:07

it does matter a lot actually

Aron12:12:12

it doesn't, actually

thheller12:12:31

the browser does not have js/require

thheller12:12:45

so things need to be bundled for it

thheller12:12:00

node will just load things happily via require

thheller12:12:20

whether the code is for node or the browser does not matter yes

thheller12:12:24

how you load it does though

Aron12:12:27

i know, and it also doesn't have a lot of other stuff that node has, again, as i mentioned before, i don't care about the API dependent stuff because I don't use it, I don't need the node.js require, i need whatever require to load the dependency.

thheller12:12:44

so what is that dependency?

Aron12:12:03

jsnetworkx

Aron12:12:17

and i don't need it really, but there is nothing similar in clojure to use

Aron12:12:23

so this is already a backup plan

thheller12:12:46

and this jsnetworkx provides a bundled release somewhere? or only npm?

Aron12:12:23

i am not interested in a case-by-case solution

thheller12:12:45

well you didn't like the general solution?

thheller12:12:52

use npm and all that comes with it

Aron12:12:01

how is that a general solution?

thheller12:12:39

well CLJS is not going to replace the whole JS ecosystem

thheller12:12:51

if you want to use something from there you have to use their world

thheller12:12:12

cljsjs goes a long way of hiding that

thheller12:12:52

the whole JS world can't even decide how to do things ... given npm, yarn, webpack, browserify, ...

Aron12:12:37

i am not sure why you talk about the whole js ecosystem

Aron12:12:05

because i never asked about the whole js ecosystem

thheller12:12:33

well you didn't want a case-by-case solution?

Aron12:12:53

first a strawman, now a false dilemma

Aron12:12:02

guess only these two exist, right? :))

Aron12:12:15

funny how people see the richness of the js ecosystem as a problem

Aron12:12:50

when their own ecosystem can't even deal with anything that's not dumb as js menu from 1997

thheller12:12:51

well if you have an actual question I'm happy to help

thheller12:12:58

not gonna go down that road though

rauh12:12:17

@ashnur You'd do well listening to thheller, there is less than a handful of people who know the cljs build system better than him. That being said: Just include your library in a <script> tag and use it in cljs. That's as easy as it gets. Once you want to do advanced builds you'll have to supply an externs file so the minifcations leaves those fields alone.

Aron12:12:38

using html to manage project dependencies is a no go, i am not going back in time 10 years just to accommodate clojurescript quirks

rauh12:12:39

That'll get you started to use the library, nothing wrong with that. If you want to compile it all in once you just do an npm install of you library and use :provides compile option

Aron12:12:27

our views differ more than you realize

rauh12:12:49

This is a solution to your problem. If there is something specific why that's not good enough, then you'll have to ask a specific question.

Aron12:12:55

i just want to use this jsnetworkx from clojurescript without having to manually wrap it, expose it, include it in a script or anything. i want a solution that is not unique so if someone who understands the tooling knows what's happening and they don't have to read my configuration code to figure out what i did. i definitely do not want to touch html, beyond including the basic template with a single div#app that i will populate from reagent.

Aron12:12:13

simple, straightforward stuff.

Aron12:12:49

someone should've given me this link when i first asked about this topic https://github.com/clojure/clojurescript/wiki/Packaging-Foreign-Dependencies

Aron12:12:14

i just found it by chance, not even through google

rauh12:12:46

It is very much expected that somebody who used clojurescript clicks on "Get started" on the official http://clojurescript.org homepage. Where there is a section about "dependencies" and links to more details.

Aron12:12:19

well, i am sorry that i did not live up to your expectations

Aron12:12:30

must be my fault, i am stupid like that

anmonteiro12:12:24

@ashnur: your tone definitely doesn't help anyone willing to answer your question(s). Apart from that, I think you need to adjust your expectations. Every technology has tradeoffs. ClojureScript has used the Google Closure Compiler since its inception which means it has chosen to accept the tradeoffs it imposes (specifically that it hasn't historically been easy to consume random JS libraries, either from NPM, bower or whatever package manager or module system of your choice)

anmonteiro12:12:13

That said, there's work underway to make that integration easier

anmonteiro12:12:46

The JS module consumption is already in the ClojureScript compiler, but should be regarded as an alpha feature

anmonteiro12:12:22

Unfortunately I don't think there exists a lot of docs on that apart from Maria Geller's blog posts and a Lambda Island screencast

Aron12:12:09

sorry about my tone, i am not raised in California and if people act as they are helping while they are actually working on making me angry, they will succeed easily.

Aron12:12:24

i am now trying to figure out how hard it would be to put jsnetworkx into cljsjs

Aron12:12:49

cool, thank you

anmonteiro12:12:50

If it helps answer your question consider buying a subscription (I'm not affiliated with it in any way). At the least, give a warm "thank you" to @plexus for taking the time to make it available for free

deas12:12:23

BTW: Should :infer-externs play with 1.9.293 already?

anmonteiro12:12:39

@deas: no you'll need to use master

xificurC13:12:12

since there's a few more people talking now than when I asked. Any tips on my question from 2 hours ago? I can't get core.async to work with nodejs. I tried several versions of cljs and core.async by this point and nothing worked

anmonteiro13:12:14

@xifi did you (:require-macros [cljs.core.async.macros :refer [>!]]) ?

anmonteiro13:12:44

Or is >! a function? I can't remember at this time

mitchelkuijpers13:12:57

I think >! is a function

anmonteiro13:12:13

Anyway you need to require the macros namespace as well as the cljs.core.async namespace

xificurC13:12:19

@anmonteiro function. The same code worked on top of the JVM

thheller13:12:36

@xifi looks like you are missing the refer for go

anmonteiro13:12:57

go is definitely a macro

mitchelkuijpers13:12:03

Don鈥檛 you need to require cljs.core.async ?

mitchelkuijpers13:12:31

Oh lol I am duplicating @anmonteiro

thheller13:12:22

you should be getting a warning, something about go missing? or maybe you are using the go macro from clojure?

xificurC13:12:38

so the namespace is different in clj and cljs? This is what I tried to do http://sprunge.us/IYSB

thheller13:12:45

as @anmonteiro said it must be cljs.core.async.macros not clojure.core.async

thheller13:12:03

yeah macros for cljs are in an extra namespace

mitchelkuijpers13:12:13

`(require-macros [cljs.core.async.macros :refer [go]])`

xificurC13:12:27

great, that works. That was a simple mistake that was impossible for me to debug 馃檪

thheller13:12:41

for cljs you should always use cljs.core.async and not rely on clojure -> cljs aliasing

dnolen13:12:30

@deas :infer-externs is experimental - people need to kick the tires with master first

dnolen13:12:13

@ashnur assume everyone in this channel is trying to help you please. Thanks.

Aron13:12:00

@dnolen really hard to assume that with strawmans and false dilemmas thrown at me 馃槥 i hope you understand that

dnolen13:12:30

@ashnur I read the whole backlog

dnolen13:12:34

I read no such things

Aron13:12:49

if i want to help someone i try to understand them and not act if they are somehow stupid because they don't already know the limitations of my system

dnolen13:12:59

nobody is doing that

Aron13:12:40

fine, not going to argue, because it would be evil 馃檪

dnolen13:12:24

thank you for not arguing

dnolen13:12:50

@ashnur back on topic. Integrating seamlessly with npm modules is just not a goal and it鈥檚 never going to be. So you should expect some friction there since it鈥檚 just not something we鈥檒l ever prioritize. All this goes back to how Google Closure works - fundamental tradeoff.

dnolen13:12:18

so your frustration are just a reflection of choices that were made long ago and they are not going to change. If you don鈥檛 like it, don鈥檛 expect us to do anything about it.

dnolen13:12:44

that said, there鈥檚 some work in to consume node_modules directly coming to the Closure compiler.

dnolen13:12:05

it looks promising - but it still won鈥檛 ever address the fundamental problem - most libraries can鈥檛 go through advanced compilation.

Aron13:12:53

i will figure out some way to use the lib, or just reimplement it in clojure

xificurC13:12:00

the cljsjs ones don't go through advanced compilation either, right?

dnolen14:12:43

they usually provide a minified thing in the JAR, these all get concated in dep order and preprended to the final build

Aron14:12:42

i don't care about that compilation thing

borkdude14:12:43

Would it matter in lookup speed if I used vectors (of numbers) as keys or (str [鈥) them first in ClojureScript hash-maps?

dnolen14:12:30

@borkdude I don鈥檛 recommend doing that, but if you have some inner loop then you could try to measure

dnolen14:12:43

this is the kind of thing that you should probably expect to see some large variance across JS engines

borkdude14:12:44

@dnolen which you don鈥檛 recommend?

dnolen14:12:55

str鈥檌ng vectors into keys

dnolen14:12:27

it鈥檚 also important to remember str鈥檌ng vectors has a non-trivial cost

dnolen14:12:35

so that might hose any benefits

rauh14:12:30

Is there a way to tell that a parameter (a function) can be called static (ie without .call(null, ...)? I'm currently resorting to (js* ...) macro to do that in performance critical code.

anmonteiro14:12:06

@rauh I assume :static-fns true isn't helping you?

rauh14:12:46

Nope, that's deep into datascript btset and it's generated as .call(null,...)

Alex Miller (Clojure team)14:12:16

Hey all, the 2016 State of Clojure Community survey is now open! We do this every year as a way to take the pulse of the community and if you can spare 5 minutes to take it, it would be awesome to get input from everyone here. https://www.surveymonkey.com/r/clojure2016

dnolen14:12:48

@rauh as you probably know don鈥檛 use js*, since no promises it will work in the future. .call is avoided when possible even in higher order cases.

dnolen14:12:39

@rauh we never just do call if we can avoid it, we鈥檒l check if there鈥檚 is an arity we can invoke directly first.

dnolen14:12:06

I also do not understand your explanation

dnolen14:12:20

鈥渄eep into datascript btset鈥 and using js* makes no sense to me

rauh14:12:06

@dnolen But in case of an argument, how could this .call ever be avoided? (Like (defn f [cmp a b] (cmp a b))

dnolen14:12:21

@rauh I explained that

dnolen14:12:33

first check if we can invoke the arity directly

rauh14:12:07

Well I'm changing a bunch of the datascript code to optimize some things. The comparators are heavily invoked.

dnolen14:12:32

you are misinterpreting my explanation 馃檪

rauh14:12:44

Yes I'm afraid so 馃檪

dnolen14:12:49

the ClojureScript compiler generates code that first checks if we can invoke directly

rauh14:12:19

Can you give an example when the above would omit the .call syntax?

dnolen14:12:31

I didn鈥檛 say we omit

dnolen14:12:45

1. can we invoke directly 2. yes, invoke directly 3. no, invoke call

dnolen14:12:22

this is the code we generate for all higher order invokes

rauh15:12:55

Oh I see. That's where the zyx$invoke$arity2 ? ... : ....call( ... ) come from?

rauh15:12:17

Got it! That makes sense now 馃檪

dnolen15:12:33

it also helps VM inlining

dnolen15:12:52

this is why higher order stuff can be ridiculously fast, like @mfikes C comparison post

rauh15:12:22

Very interesting, you guys are a step ahead of me.

dnolen15:12:45

yes I do not recommend hacking around perf stuff, there鈥檚 5 years of work in this stuff already

lxsameer15:12:55

hi, how does atom watchers implemented in js ?

dnolen15:12:13

@rauh note our approach is faster than just erasing call

dnolen15:12:36

even if you erased it you would (potentially) have to go through the fn鈥檚 arity dispatcher and performance would go down the toilet

rauh15:12:47

Yeah in that particular case, the comparators only have one arity, but I agree, my optimizations all in a sudden make no sense. So I'm reverting

dnolen15:12:35

@rauh right so there鈥檚 the one place where we potentially lose, one arity higher order invoke

rauh15:12:51

Still keeping my datoma.a.fqn < datomb.a.fqn ? ... comparator though, which was a nice speedup.

dnolen15:12:41

@lxsameer can you clarify?

lxsameer15:12:44

@dnolen I want to know, how atom and watchers work. How they implemented in js. Did you use observers to implement the atom watchers functions ?

dnolen15:12:43

@lxsameer but hardly anything in ClojureScript is implemented in JS 馃檪 no we don鈥檛 use observers, it鈥檚 just some custom ClojureScript.

lxsameer15:12:26

cool thanks

borkdude15:12:35

is there a shorthand in clojurescript for repeatedly setting properties on an object?

mitchelkuijpers15:12:50

@borkdude for a javascript object?

borkdude15:12:08

something like doto

borkdude15:12:59

I have:

(set! (.-strokeStyle ctx) "#1f77b4")
(set! (.-fillStyle ctx) "#2C82C9")
(set! (.-lineWidth ctx) 1)

mitchelkuijpers15:12:00

you could use extend?

borkdude15:12:30

not really a problem, but just wondering

mitchelkuijpers15:12:55

using goog.object/extend would be way nicer already

mitchelkuijpers15:12:51

(gobject/extend ctx #js {:strokeStyle "#1f77b4" :fillStyle "#2C82C9鈥潁)

surreal.analysis16:12:34

I have a project which requires a decent amount of custom html / js for testing, and I was hoping to use Hiccup and Reagent. In general, when I鈥檝e used Reagent or any ClojureScript setup, I鈥檝e used something like Figwheel to constantly recompile the ClojureScript, but is there anything more along the lines of an include-cljs function in Hiccup, or a different way to get them to play together nicely? i.e. I don鈥檛 really want to precompile the ClojureScript, because it will only be used in testing, and only with very small files, but I鈥檇 like to be able to say something along the lines of:

(html5 {:lang "en"}
         [:head
          [:title title]
          (include-css "//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css")
          (include-cljs 鈥渕y-ns.example1鈥)

          [:body
           [:div {:class "container"} content ]]]))

dnolen16:12:40

@surreal.analysis in the past people would sometimes compile on demand via a webserver that runs ClojureScript

surreal.analysis16:12:49

So that鈥檇 be just having a webserver that called cljs.build.api/build on demand?

jalvz16:12:15

Hello everyone! I stumbled upon this great article on core.async in clojurescript: http://rigsomelight.com/2013/08/12/clojurescript-core-async-dots-game.html I believe it is previous to om, reagent, etc., and the author himself warns "take my Clojure idioms with a grain of salt" I find the approach very interesting thou, in that state is not managed via a global atom, but with channels, so it "flows" to where it is needed without needing anything global (from what I understand) I wonder what experienced people think of this pattern 3 years later... Is it a good way to develop more complex apps? Does it make it easier or harder to test, troubleshoot, debug, etc (compared to om.next or reagent, for instance)?

dnolen16:12:35

@jalvz I would argue no - nearly everyone has moved towards the idea of a global atom

dnolen16:12:54

I think Hoplon is the only real exception here that has users

dnolen16:12:44

core.async is great for managing asynchrony - not for managing state

jalvz16:12:41

I see. What drawbacks do you see in using channels for managing state?

jalvz16:12:09

(compared to global atoms, that is)

dnolen16:12:40

it鈥檚 not global

Al Baker16:12:20

@jalvz in the small, those functions that just operate on a channel appear nice and concise, you can view them with predictable ins/outs from a channel perspective. But in the large, the state of that game is some timeline of channel puts and gets and side affecting function execution, so 'where is the bug' is harder than a global state management where you know where the truth is at all times... i.e. why the frameworks use async stuff, but they return data and manage state uniformly rather than sprinkling it all over

jalvz16:12:15

Makes sense. Thanks!

tbaldridge19:12:46

@jalvz I actually worked on a large scale project that used messages, core.async and separate atoms for every control. So when you click a button it sends an "event" to it's parent, and the parent's parent until something does something with the message. Sounds fantastic...and it was utter hell.

tbaldridge19:12:07

My opinion is now...the less mutable "things" in your gui the better.

borkdude19:12:41

The benefit of using #js is primarily compile time so you don鈥檛 have an allocation overhead, right?

borkdude19:12:04

(over clj->js and except for the nested case)

dnolen19:12:57

the benefit is purely syntactical

dnolen19:12:06

js-obj and array compile to literals

borkdude19:12:43

js-obj is also a macro?

borkdude19:12:02

Here it says: function/macro, kind of confusing 馃檪 https://cljs.github.io/api/cljs.core/js-obj

dnolen19:12:12

yes function/macro

dnolen19:12:44

it鈥檚 like +, it inlines if not higher order

borkdude19:12:46

thanks! I wondered about this because if I would write a function like:

(defn set-properties [obj props-map]
  (gobject/extend obj props-map)
  obj)
and I would pass a map to it with #js, like (set-properties ctx #js {:foo 1 :bar 2}), the ClojureScript map will never see the light of day at run time right? But what if I would make it more convenient for the user and write:
(defn set-properties [obj props-map]
  (gobject/extend obj (js-obj props-map))
  obj)
and call it like:
(set-properties ctx {:foo 1 :bar 2})

borkdude19:12:33

( set-properties! would be a better name)

borkdude19:12:35

Will this create the hash-map at run time?

borkdude19:12:19

Of course this can be worked around by creating a macro instead

dnolen19:12:11

@borkdude I just don鈥檛 know what you are asking

dnolen19:12:21

but my advice is to avoid all of this stuff

dnolen19:12:30

if you鈥檙e dealing with JS objects stop converting

borkdude19:12:58

@dnolen well, this function basically calls goog.object/extend, which expects a javascript object instead of a clojurescript object. But if I wrap that in a function because extend annoyingly doesn鈥檛 return the object and to allow the user to call this function with a normal clojurescript map, can I prevent the overhead of the clojurescript map at run time.

borkdude19:12:56

with a macro for sure

dnolen19:12:30

does doto + gobj/extend not solve this issue?

borkdude20:12:39

it鈥檚 good enough, but you still have to write #js. No problem, this can be solved with a macro.

anmonteiro20:12:28

@borkdude sounds like your problem is just with the #js syntax then?

borkdude20:12:43

My cljs REPL:

(doto ctx (gobject/extend #js {:x 鈥渂ar鈥潁))
;; prints {:x 鈥渂ar鈥潁, but returns the `ctx`

borkdude20:12:10

@anmonteiro well, I was wondering about how this would be optimized, but I guess I can just write a macro to be sure of this

anmonteiro20:12:25

I don't really understand what the problem is though

anmonteiro20:12:50

your approaches all seem equal to me in that you always end up calling gobj/extend

anmonteiro20:12:01

(disregarding stuff like clj->js etc)

anmonteiro20:12:23

cljs.user=> (doto #js {:a 1} (gobj/extend #js {:b 2}))
#js {:a 1, :b 2}

anmonteiro20:12:33

^ this should be what you want, as David mentioned

borkdude20:12:43

@anmonteiro yes, my question was like this: suppose you want to make a 1) function (not a macro) that calls gobj/extend for you and 2) this function accepts normal clojure hash-maps, in which cases will this hash-map be optimized away. My assumption is not at all, because the function argument is not a literal.

anmonteiro20:12:16

"not at all" seems right to me

borkdude20:12:49

sorry for my confusion messages, I have to go now 馃槈

borkdude20:12:55

We鈥檙e using Reagent. Turns out it has a macro which is pretty nice in this case:

(doto #js {:a 0} ($! :b 1) ($! :c 2) ($! :d 3))

jetzajac21:12:11

hello everyone, I just noticed that cljs doesn鈥檛 intern keywords. does anybody know why and how can it impact a memory traffic?

dnolen21:12:41

@jetzajac interning keywords would require the wide availability of weak maps in JS

dnolen21:12:07

since those don鈥檛 exist, we don鈥檛 intern - I don鈥檛 really understand the later half of your question

jetzajac21:12:36

@dnolen I mean it can produce a major memory pressure. did anybody try to intern them just by hard refs and see if allocation profile gets better?

dnolen21:12:16

@jetzajac I鈥檝e never heard anybody report memory pressure issues around this in 5 years

dnolen21:12:42

but to avoid allocations for keyword literals we do dump a constants table of keywords under advanced compilation

jetzajac21:12:34

@dnolen oh, I see. so it can鈥檛 be a problem in advanced mode? right?

dnolen21:12:46

and yes that does have a measurable beneficial effect on perf

Aron21:12:10

so, what is your suggestion to my problem? I need a random graph generator, should i try to implement one or try to use one from javascript, which is the recommended way? 馃檪

dnolen21:12:07

@ashnur what鈥檚 wrong with jsnetworkx like you mentioned before? it鈥檚 available as a standalone JS file - you can include that as a foreign dep in the usual way - people dropped links about how to do that earlier

Aron22:12:13

it's a hack

Aron22:12:42

corner cutting

Aron22:12:48

not sure how to explain

Aron22:12:44

this is not for money or anything, i don't have to make it for the pleasure of other people, it doesn't have a deadline. i don't like the idea of having to manage dependencies through html, as i also expressed before

dnolen22:12:06

@ashnur then we cannot help you, sorry

Aron22:12:08

i saw two other ways i think, one is the cljsjs thing and the other is foreign-libs i think, maybe the two are actually the same, i am not sure. My question was about these two, if I should try it.

dnolen22:12:12

I鈥檓 not spending any more time on this

dnolen22:12:05

read the the links people sent earlier please before saying anything more about this

Aron22:12:07

well, there goes the "everyone is trying to help" assumption i think. not sure why are you so upset though, you seemed a nice, calm person irl 馃槥

dnolen22:12:21

foreign dependencies is how CLJSJS works, or if you do it yourself - it鈥檚 all the same stuff

dnolen22:12:54

I鈥檓 not upset - information has been shared, now fulfill your end of the deal

dnolen22:12:34

if you have questions after reading everything I鈥檓 sure everyone including myself will happy to help you with any difficulties you may encounter

Aron22:12:52

reading everything 馃檪

dnolen22:12:41

this covers the important stuff, it鈥檚 explain foreign deps as well as CLJSJS in detail