Fork me on GitHub
#clojurescript
<
2016-10-21
>
yenda08:10:50

Hi, is there a way to override ctrl-t and ctrl-w shortcuts in clojurescript in the browser or is it an hopeless quest? (thoses specifically I got the rest working already). I have tried google and trial /error for quite some time without any concluding result (including translating a few javascript snippets that didn't work out).

yenda08:10:44

(only workaround I found so far, for chrome, is starting in application mode google-chrome --app=

dominicm09:10:25

@yenda Given the importance of those mappings at the browser level, I doubt you will have much luck. I'm glad applications can't hijack my mappings.

yenda09:10:30

I am implementing keychords so you wouldn't be glad either if C-x C-w closes your application instead of saving the file (or whatever function is assigned but you see the problem here)

rauh10:10:24

10k LOC app, datascript, rum and bidi: :size 702346, :gzip-size 162783, :brotli-size 132157. I love Clojurescript.

rauh10:10:22

Yes sir 馃檪

anmonteiro10:10:12

@rauh could probably be further reduced through JS Module consumption

anmonteiro10:10:41

depending if your JS libs would support it

rauh10:10:54

Yeah, I wanna do that eventually. But right now I don't even mind loading code that the client may never use...

anmonteiro10:10:12

160KB is already pretty good

rauh10:10:10

Yeah I'm pretty happy, plus Brotli is supported on Android so that's even better

val_waeselynck10:10:38

@rauh so I assume this includes HTML templates as well ?

rauh10:10:46

@val_waeselynck I precompile all of the hiccup I use (hacked sablono a bit) so there is only calls to React.createElement, but yes, they're all included.

afhammad13:10:54

How do you access the javascript arguments list in a function.

anmonteiro13:10:45

@afhammad there鈥檚 cljs.core/js-arguments

anmonteiro13:10:20

but you shouldn鈥檛 need to use it unless for low-level stuff

afhammad13:10:41

currently using (fn [& args]

anmonteiro13:10:03

right so that should work

afhammad13:10:37

yeh it does, was just wondering if there was an alternative or if that was the suggested usage

richiardiandrea14:10:15

A confirmation, is it expected behavior that if asset-path is set to , then the out folder is searched at ? I mean, is it expected to be a relative only location to the current server?

borkdude15:10:38

@bhauman mind if I ask you a devcards question?

borkdude15:10:34

I鈥檒l post a gist, brb

borkdude15:10:07

@bhauman I鈥檓 trying to make an example card show up, but can鈥檛 get it working. Gist: https://gist.github.com/borkdude/a74806902bf75aab6060dd7ba87d0382

borkdude15:10:13

@bhauman sorry to bother you. I got :figwheel true instead of :devcards true, that was it 馃檪

bhauman15:10:18

sorry the config is soo darn intense

borkdude15:10:37

especially with boot I guess

akiroz15:10:37

Wow, devcards is so cool! Thanks for bringing this up guys 馃槃

kenny17:10:06

@rauh I am interested in your sablono hacking. Is there a fork somewhere I could peek at?

rauh17:10:06

@kenny I'm not proud of those hacks. 馃檪 But i can gist them...

rauh17:10:55

It's nothing magic, just pruning the interpret call and then fixing the errors that react gives me by always applying a (html ...)

lockdown17:10:03

So rum uses cursors, I think I remember dnolen mentioning some problems with cursors and om, anyone recall what it was?

dnolen17:10:55

@lockdown tradeoffs is probably a more appropriate way to think about it

kenny17:10:39

@rauh If cleaned up, it sounds like it could be a valuable addition to sablono. Many of my components could easily be pre-compiled for speed

misha17:10:05

@lockdown rum can use cursors, but it's not the only option

jrheard17:10:23

so, possibly stupid question: the other day, i mentioned that i was having trouble speeding up a function that converts a 2d js array of booleans into a 2d clj vector of keywords, and we came up with this:

(defn array->grid [an-array]
  (into []
        (map (fn [row]
               (into []
                     (map (fn [cell]
                            (if (true? cell) :full :empty)))
                     row)))
        an-array))
and it works great, and profiling indicates that calling it twice accounts for a total of 5% of the time in the main function i鈥檓 working on speeding up, which is fine. but i noticed that profiling also indicates that 30-35% of my function's time is now spent in GC, and my heap size graph looks like this (blue part): https://www.evernote.com/shard/s11/sh/f10c0c33-5bea-42e6-81cb-0d1912b0a8c6/a17df90c6da1cc8b/res/fa1e5447-de13-4eee-9570-39b523c472cb/skitch.png . when i remove the function鈥檚 two calls to array->grid, that 30-35% GC time goes away entirely, and my heap graph stays flat. is this to be expected / is there no way around this? the graph above represents 250 calls to the function i鈥檓 optimizing, and i likely won鈥檛 be calling it more than 5-10 times in real life, so if this unfixable, i suppose i could just ignore / live with the issue

jrheard17:10:03

like, i鈥檓 not surprised that making a 2d clojurescript vector causes some memory to be allocated, that sounds like just how programming languages work - i am surprised that all of a sudden i鈥檓 spending 30-35% of my time in GC though

dnolen17:10:57

@jrheard but why do you find this surprising?

dnolen17:10:15

if you think about it the heavy work in that code is very likely just allocating new structure

kenny17:10:56

@rauh (or others).. A bit off topic but how did you access Github? Still getting the DNS issues.

jrheard17:10:28

@dnolen i definitely buy that - i guess i was just surprised by the magnitude of the effect i鈥檓 seeing

dnolen17:10:43

if the rest of the work is trivial

jrheard17:10:48

i haven鈥檛 spent much time thinking about specific memory numbers before, so i don鈥檛 have a good gut feeling for what is and isn鈥檛 normal

jrheard17:10:50

mainly wanted a sanity check 馃檪

jrheard17:10:18

if that looks normal+expected to you, that鈥檚 great info for me to have and will help me calibrate my understanding for the future

lockdown17:10:23

dnolen can you mention some of those tradeoffs?

dnolen17:10:36

@lockdown sorry, there鈥檚 lots of posts about cursors these days

jrheard17:10:49

i see your point now re: relative amount of work

dnolen17:10:01

@jrheard yes the rest of your code isn鈥檛 doing anything

lockdown17:10:12

micha the other is derived atoms which they mention not to use

dnolen17:10:21

so of course GC is going to come up in your benchmark

lockdown17:10:29

kenneth use opendns 208.67.220.220 servers

jrheard17:10:32

heh, makes sense. thanks david!

lockdown17:10:39

err kennyjwilli ^

dnolen17:10:08

@jrheard that said this is a good way to know when you might want to choose a mutable data structure for whatever reason

dnolen17:10:16

you don鈥檛 want to be subject to GC throughput

jrheard17:10:58

yeah, absolutely - right now i鈥檓 using this mutable plain js array to do all of my work, and only converting to the cljs vectors when i鈥檓 all done

jrheard17:10:11

and so i鈥檓 inclined to think that maybe i鈥檓 just making an error in my profiling methdology here

jrheard17:10:40

this probably won鈥檛 be an issue in real life, since i鈥檒l be calling this conversion function much less than i am when i call the whole shebang in a loop a bunch of times

dnolen17:10:59

@jrheard I think what you鈥檙e seeing is to be expected

dnolen17:10:16

case in point in a typical React CLJS library you鈥檙e never going to see GC as the bottleneck

dnolen17:10:32

it鈥檚 a fraction of all the rest of the stuff that鈥檚 going on

jrheard17:10:40

makes sense

dnolen17:10:52

which why we don鈥檛 care

dnolen17:10:02

everyone said this stuff will be slow in a real app

dnolen17:10:14

but then you have 60fps in ClojureScript apps

dnolen17:10:48

the only time you need to care is really heavy compute stuff, and usually that means data vis / games

jrheard17:10:58

you caught me, working on a little game 馃檪

dnolen17:10:12

yes then you need to be more careful

jrheard17:10:35

achieving 60fps pretty easily atm though, right now i鈥檓 working on generating random levels (i.e. that鈥檚 the function i鈥檝e been discussing), and that hardly happens every tick of the game loop so i don鈥檛 even really need to be worrying about it as much as i am

jrheard17:10:06

for anyone else in the room who鈥檚 interested, the 鈥渢ips鈥 section of https://github.com/alexkehayias/chocolatier is very helpful in this context

jrheard17:10:19

anyway thanks again for the sanity check, it鈥檚 exactly what i was looking for!

dnolen17:10:58

@jrheard Alex gave a nice talk about that work at ClojureNYC, he said in all the work he had done he didn鈥檛 run into any cases where using the game models as immutable data structures themselves were the bottleneck

dnolen17:10:42

he has some nice optimization tips that are worth considering first

jrheard17:10:53

glad to hear it 馃槃 yeah, i need to actually work through that 鈥渢ips鈥 section i linked and actually apply it to my game鈥檚 code

jrheard18:10:39

ok, i鈥檝e got to head out - thanks again for your time, i really appreciate the sanity check + advice!

lockdown18:10:09

does core.async fulfills the purpose of ES7's async/await?

dnolen18:10:02

@lockdown it offers higher level functionality than ES7 async/await - but yes you can use them to clean up async code in the same way

herbm19:10:06

@rauh please explain "Brotli is supported on Android"...

amirrajan19:10:51

@jrheard I think Zach Oakes is working on a Pixi.js wrapper too.

jrheard23:10:21

@amirrajan nice, i鈥檝e just been using the cljsjs version

amirrajan23:10:55

@jrheard here is his: https://github.com/oakes/play-cljs I only mention it because he had some traction with play-clj