Fork me on GitHub
#clojurescript
<
2015-07-16
>
meow00:07:49

@dnolen: I don't know how to try aget in Clojure because I'm using it on js objects. And I just reread and am still confused by what the api says and examples it gives: https://github.com/cljsinfo/cljs-api-docs/blob/catalog/refs/cljs.core_aget.md

meow00:07:48

Here is one of the functions I changed but I'm not sure why I needed to change it:

(defn get-root []
  (goog.object/get (dom/getElementsByTagNameAndClass "html") 0))

meow00:07:34

Seems to me that aget should have been fine there. No?

dnolen00:07:51

If you can't use aget on objects in Clojure you shouldn't using them on objects in ClojureScript.

dnolen00:07:51

@meow: looks right to me

meow00:07:56

@dnolen: cool, thanks

wilkerlucio00:07:19

I'm trying to do a POST using cljs-http with a custom Transit handler, but it's not working, someone can please check this signature call looks correct please?

wilkerlucio00:07:22

(http/post url {:transit-params params :transit-opts {:encoding-opts {:handlers {MyType MyTypeHandler}}}})

dnolen00:07:57

@wilkerlucio: gist MyTypeHandler, also a good way to sanity check is to test w/o cljs-http first

wilkerlucio00:07:01

the handler is really simple, I think the issue is with my options to cljs-http, I'm not sure if I'm sending the correct keys (I tried to look on their tests, but I found no example of using custom transit handlers), this is the handler:

wilkerlucio00:07:03

(deftype TempidHandler [] Object (tag [this v] "tempid") (rep [this v] v) (stringRep [this v] nil))

dnolen00:07:40

(MyTypeHandler.)

dnolen00:07:52

you need to construct a handler, not pass the constructor

wilkerlucio00:07:35

@dnolen: you are right, I missed that, but it still doesn't work...

dnolen00:07:57

can you be more specific than “doesn’t work”?

dnolen00:07:06

errors? stacktraces?

wilkerlucio00:07:11

@dnolen: sorry, I was checking the wrong place, I might find other issue here, I guess the transit part seems to be working now, thanks

dnolen01:07:03

@mfikes: small typo in 2nd to last paragraph “thing” -> “think"

mfikes01:07:14

@dnolen: I was surprised at the speed difference at the very bottom of the post.

mfikes01:07:25

Thanks… will fix typo

dnolen01:07:38

yeah that’s bigger than I would have suspected

dnolen01:07:10

curious how that translates to actual devices

dnolen01:07:21

from what I hear Android simulators are pretty sluggish?

mfikes01:07:40

Yes, I want to see a comparison between DeepBlueLambda’s and Replicator

mfikes01:07:45

And yes, my god yes Android simulators / emulators (whatever they are) are slow

dnolen01:07:54

the EuroClojure Clojure Android demos on the device took more like 1-2 seconds

dnolen01:07:48

wouldn't be suprised if this means ClojureScript is instantaneous though simple_smile

mfikes01:07:50

Ahh. That’s nice and fast. @lazy-lambda can hopefully compile and embed JavaScriptCore

mfikes01:07:48

That’s right. I still maintain that Replete on an iOS simulator is the fastest REPL in the West (to launch)

dnolen01:07:13

yeah excited to hear more about JSC integration

mfikes01:07:38

I bet you have to compile it for ARM and then interface it with C. Yikes.

dnolen02:07:16

@mfikes: super excited about this stuff. It’s incredible how fast everything is moving considering I could barely compile expressions at EuroClojure simple_smile

mfikes02:07:30

@dnolen: I know… Hah. I was in London at the time and something happened somewhere during that time frame (Joel’s stuff) and I saw that the light at the end of the tunnel was IN MY FACE

mfikes02:07:59

@dnolen: Somehow you "called it” with respect to mobile 1½ years ago with this prescient advice http://stackoverflow.com/a/21330653/4284484

meow02:07:52

@mfikes: very cool stuff - way to go to you and @lazy-lambda simple_smile

mfikes02:07:20

@lazy-lambda: Is a machine that does not sleep.

dnolen02:07:13

@mfikes: haha, well I definitely have had my sights on the possibility for a long time. But it’s great to see you and other people in the community push it into reality.

colin.yates10:07:50

has any one tried used ClojureScript with ExtJS? Thinking of converting a large ExtJS project over to ClojureScript. It is currently written in CoffeeScript. I suppose nobody has written a CoffeeScript->ClojureScript transpiler simple_smile

borkdude11:07:25

I was wondering why read-string in clojurescript returns null instead of an exception when reading a non-string

dnolen11:07:32

@borkdude: probably because no one complained or submitted a patch?

ordnungswidrig12:07:09

Could clojurescript be used to configure phoenix? It supports coffescript compiled to javascript. In other words, is there a way to compile clojurescript to „generic“ javascript? https://github.com/kasper/phoenix

dnolen12:07:05

ClojureScript has always supported “generic” JavaScript

dnolen12:07:29

the easiest way to get ClojureScript into weirder JS environments - :simple optimizations

ordnungswidrig12:07:27

@dnolen: oh great. I never used clojurescript outside the browser. I follow the whole clojurescript on node/rhino/some random spaceprobe discussion very remotely

dnolen12:07:59

ClojureScript’s core has never had anything browser specific

martinklepsch12:07:11

@ordnungswidrig: haha, that was my first thought when I saw it in #C03RZGPG3 😄

dnolen12:07:21

@ordnungswidrig: the main downside is degraded tooling. But it’s usually not that much work.

dnolen12:07:42

if you can give CLOSURE_IMPORT_SCRIPT an implementation then REPL driven development is not far off

ordnungswidrig12:07:49

@dnolen: well, when used to configure a window manager then I can live with it.

martinklepsch12:07:57

Looking at the configuration files for phoenix I don’t think it’s worth it really. More of an exercise @ordnungswidrig

ordnungswidrig12:07:03

Aside, I will only trust clojurescript when it runs on a ESP8266 simple_smile

ordnungswidrig12:07:15

@martinklepsch: you don’t know my config file.

dnolen12:07:35

@ordnungswidrig: ha, then you should write a Lua backend for ClojureScript simple_smile

ordnungswidrig12:07:52

dnolen: there used to be one simple_smile

dnolen12:07:53

but in all seriousness anything without good amounts of memory is not a good target

dnolen12:07:07

@ordnungswidrig: yes but it never got very far

ordnungswidrig12:07:26

is the memory footprint because of javascript or because of clojure?

dnolen12:07:38

persistent data structures ain’t free

dnolen12:07:32

but Node.js I think needs at least 5mb to even get going

martinklepsch12:07:39

@dnolen: maybe a good idea to define a threshold for “good amounts of memory” for other people following along simple_smile

fnumatic12:07:22

is there any refactoring support for clojurescript in emacs?

dnolen12:07:28

@martinklepsch: this is very challenging to compute

dnolen12:07:44

VM needs to parse, hold onto sources, object layout is different depending on optimization level

dnolen12:07:21

VM optimization level

borkdude12:07:22

@dnolen: do you care for a jira issue btw? I just asked because I was curious, not because it was a huge problem

dnolen12:07:34

@borkdude: ticket + patch please

martinklepsch12:07:36

@dnolen: thinking of ballpark figures. “good amounts of memory” could easily me interpreted as 4gig or so.

dnolen12:07:21

@martinklepsch: at least 5mb for Node.js, whatever it takes to store information about ClojureScript sources

dnolen12:07:40

then whatever data structures your program actually allocates

dnolen12:07:06

then 32bit/64bit target affects pointer size

borkdude12:07:09

is it me or is the clojure jira a bit slow today?

dnolen12:07:25

then look at an object and assume every field is a 32bit or 64bit value

dnolen12:07:46

that would give you a lower bound

dnolen12:07:58

@borkdude: it was acting up a bit yesterday

borkdude12:07:12

I got "This site is currently undergoing maintenance. We apologize for the inconvenience."

borkdude12:07:24

aaaaand it's back

borkdude13:07:44

@dnolen: read-string throws a NullPointerException in JVM with nil input and a ClassCastException in other cases, when not provided a string. What would be the javascript alternatives for this, just an 'Error'? I believe there is no unified exception for null pointers in js?

teslanick13:07:47

Pretty sure it would be either ReferenceError or TypeError depending on context. (in standard JS)

dnolen13:07:05

@borkdude: trying to match the error type between ClojureScript and Clojure is not a good use of time simple_smile

dnolen13:07:24

@borkdude: just check string? and throw Error. done.

borkdude13:07:05

@dnolen: you could assign this issue to me CLJS-1342

dnolen13:07:19

@borkdude: you’ve signed a CA, you now have elevated JIRA permissions - you can assign it to yourself now 😉

borkdude13:07:56

I never committed anything, first time I logged into JIRA simple_smile

eggsyntax14:07:11

@dnolen: re: your comments a couple of days ago (7/14, 3:08 pm) about :simple + :static-fns buying you all the perf benefits of :advanced -- that seems like such useful info it should be on the wiki. The decision path around how to best handle bringing in a vanilla JS library can be kind of a slog, especially for a relative cljs newbie (like myself). Knowing that there's a good way to punt on that without losing perf would be super-helpful.

dnolen14:07:57

@eggsyntax: I do not want to document this kind of information on the wiki.

dnolen14:07:02

people will just get confused

dnolen14:07:10

it’s really only for people who are already experts

eggsyntax14:07:18

Fair enough.

dnolen14:07:52

You should always be writing your code in terms of :advanced

eggsyntax14:07:49

Sure, that makes sense.

dnolen14:07:34

@eggsyntax: including random JS libraries will become simpler by the end the year so we’re working on the actual problem

dnolen14:07:47

encouraging people to generate non-optimal builds is simply not going to happen

eggsyntax14:07:05

Oh, awesome simple_smile. I'll say I've definitely found that issue to be one of the trickier parts of learning cljs. Not that any part of it is conceptually difficult; it's just a lot of options to absorb. Making that a bit easier seems like a big win.

dnolen14:07:51

@eggsyntax: we’re definitely aware of the problem, but as usual we prioritize just doing it right

dnolen14:07:01

sometimes that means you gotta wait

eggsyntax14:07:33

Can't argue with that. It's a big part of why I made the move to clj/s in the first place.

borkdude14:07:28

@dnolen: I submitted a patch. Should I mark it resolved now?

dnolen14:07:50

@borkdude: you only mark resolved if it’s been applied to master simple_smile

dnolen14:07:56

@borkdude: assign the ticket to me

bostonou14:07:02

@dnolen is there an entry point to the cljs compiler? specifically, i’m looking for a way to add a default tagged reader to *cljs-data-readers*

dnolen14:07:59

@bostonou: I’m assuming you want to compile-time/run-time support for some data literals

dnolen14:07:14

there’s no good way to do this and several tickets that need to be completed first for this to work

bostonou14:07:39

that’s what i suspected. and yet another reason cljs compiled in cljs is useful correct?

dnolen14:07:53

bostonou: no, it’s unrelated to that actually

dnolen14:07:11

when I mean “no good way” I just mean, we haven’t fixed the outstanding tickets

dnolen14:07:21

1.7 makes it possible

bostonou14:07:04

you have any quick pointers to those outstanding tickets or what i should search jira for?

bostonou14:07:32

ok thanks. i thought about cljs-in-cljs in that we could access the compiler from our code. not necessarily following clojure with data_readers.clj(c), which is perhaps obvious

dnolen14:07:24

It would be easier with cljs-in-cljs but that doesn’t really fix the problem, most people are never going to use cljs-in-cljs

dnolen14:07:08

the CLJS-1277 is the only slightly tricky bit, requires some thought but I don’t think particularly hard

dnolen14:07:35

(require ‘data-literals) is the easy part, just generate a goog.require as usual

dnolen14:07:52

the main challenge is making this work for builds, would need to collect all cljs.user fragments

dnolen14:07:14

would need to move the (require …) expressions too I guess

dnolen14:07:41

anyways a bit of work for someone else to do simple_smile

bostonou14:07:53

i thought you might say that simple_smile

dnolen14:07:40

definitely willing to help out laying out / guiding the approach if someone is willing to take it on of course.

bostonou14:07:31

i’m up for that

shaunlebron14:07:39

@bostonou: curious, what’s your use-case for adding custom data literals?

bostonou14:07:15

@shaunlebron: answering stack overflow questions simple_smile

shaunlebron14:07:00

just imagining cljs code with some custom data literals for some domain specific things

bostonou14:07:09

generally trying to remove any stumbling blocks people have with cljs

shaunlebron14:07:11

not sure what the best practices are

shaunlebron14:07:29

as opposed to just regular constructors I mean

shaunlebron14:07:44

#js and #inst are helpful and standard of course

bostonou14:07:55

yeah. i’m not sure it’s a good/necessary idea, but didn’t want to go that path in the discussion

shaunlebron14:07:22

yeah, could you link the SO question?

bostonou14:07:18

it came across my twitter feed and was one of those questions my brain wouldn’t let go of 😕

dnolen14:07:03

@bostonou: you’ve definitely identified a massive wart simple_smile

dnolen14:07:22

it just doesn’t work right now and it’s very confusing

dnolen14:07:05

making data-readers.clj -> cljc means it can be loaded into the compiler and into the runtime and work more or less as expected

dnolen14:07:42

got numerous requests about record data literals not working for example

dnolen14:07:03

I think a lot of people that want it have stopped asking since it’s not obvious how to accomplish the desired result

dnolen14:07:09

but now I have a good picture about that

bostonou14:07:20

@dnolen i’m afraid to ask more questions. my cljs todo list is already too long simple_smile

dnolen14:07:31

haha, tell me about it

bostonou14:07:24

i’ve got some free time over the next couple of days so i’ll look into CLJS-1277

bostonou14:07:41

and work towards CLJS-1194

dnolen14:07:15

@bostonou: CLJS-1277 is the tricky one, CLJS-1194 pretty easy

dnolen14:07:53

CLJS-1277 has the cool aspect of fixing a fairly big limitation

bostonou14:07:57

@dnolen i’m going to do some exploring to make sure i understand the issue. open to pointers if you have them

dnolen14:07:02

i.e. ClojureScript files w/o namespaces

dnolen14:07:57

basically the issue would be making sure cljs.user is the namespace if the file doesn’t have an ns form

dnolen14:07:14

so compiling a file w/o an ns form should work

dnolen14:07:18

that’s step 1

dnolen14:07:43

step 2 is making it possible to merge together all cljs.user namespaces into a single thing and moving the requires

dnolen14:07:26

step 2 is what would allow libraries to supply data-readers.cljc individually and builds always get the aggregation of reader extensions

bostonou14:07:50

what did you mean in your comment on CLJS-1277: "something like require etc. outside the ns needs to be supported in order to be useful"

dnolen14:07:36

@bostonou: files w/o ns forms still need to be able to require files

a.espolov15:07:11

cljs supported unqoted?

borkdude15:07:15

I worked on an Om and Reagent application this week. Lucky me simple_smile

colin.yates15:07:32

Om and reagent? How was that split?

borkdude15:07:38

two different applications

shaunlebron15:07:29

I thought unquote had to be in a syntax quote

shaunlebron15:07:38

I don’t know much about this

dnolen15:07:10

@a.espolov: what you pasted wouldn’t work in Clojure either

shaunlebron15:07:29

if you wrap it in a syntax quoted list, seems to work

dnolen15:07:00

inching closer to eval, all you need to do to build a bootstrapped thing is include cljs.js, no other compiler configuration 😄

shaunlebron15:07:23

wow, that’s neat, I wanna see what that ns looks like then

shaunlebron15:07:11

oops, that’s a filename

dnolen15:07:11

yesterday I split out all I/O side effects from ns node AST logic

dnolen15:07:46

so cljs.js will need to reintroduce side-effects but asynchronously via cljs.js/*load-fn*

dnolen15:07:03

but this means getting a bootstrapped thing in browser or Node.js should be trivial

dnolen15:07:08

just set *load-fn*

dnolen15:07:05

in browser lib name -> url -> fetch, in Node.js lib name -> file on disk -> fs.readFile

gtrak15:07:54

but that leading quote seems wrong

a.espolov15:07:39

TypeError: cljs.user.a.call is not a functionalmind

a.espolov15:07:56

for clj ClassCastException clojure.lang.Cons cannot be cast to clojure.lang.IFn

gtrak15:07:08

try not quoting it

dnolen15:07:22

@a.espolov: the errors will rarely match, drop the quote

meow15:07:47

So I went through the process of making my cljs app reload-friendly by adding setup and teardown functions that deal with unlistening to events and stopping channels and so forth. But my recently created listen-fps! function is giving me a new challenge. I changed it so that the callback has to return a truthy in order to keep the thing going, but I'm not sure how to stop it between calls to its callback:

(defn listen-fps!
  "Repeated callback returning the frames-per-second measured at regular intervals."
  ([callback]
   (listen-fps! callback 500)) ; Measure every half-second
  ([callback interval]
   (let [frame-count (atom 0)
         starting-point (atom nil)
         repeating (atom true)]
     (letfn [(measure-fps
              [timestamp]
              (when repeating
                (request-animation-frame measure-fps)
                (if-not @starting-point (reset! starting-point timestamp))
                (let [elapsed (- timestamp @starting-point)
                      f-count (swap! frame-count inc)]
                  (if (> elapsed interval)
                    (let [fps (->> (/ f-count elapsed) (* 1000) (.round js/Math))]
                      (reset! frame-count 0)
                      (reset! starting-point timestamp)
                      (if-not (callback fps) (reset! repeating false)))))))]
       (request-animation-frame measure-fps)))))

meow15:07:01

Actually, what I suspect, and am avoiding, is that I'll have to create an unlisten-fps! function. In Google Closure they keep track of listeners and calls to listen will return a listener-key that can be passed into an unlisten function to turn things off.

a.espolov15:07:06

I understand that I have not be able to cljs unquoted for the resulting object at run time?

gtrak15:07:49

why are you trying to quote it?

a.espolov15:07:23

gtrak: because this code is not part of the cljs

a.espolov15:07:34

gtrak: is clj

a.espolov15:07:41

usage http request client side handle this structure

gtrak15:07:22

I don't get it, you'll have to be more clear.

gtrak15:07:36

I understand there is clj and cljs code, what is the relationship between them?

a.espolov15:07:32

gtrak: cljs send request to clj, clj send response to cljs

gtrak15:07:41

clj cannot call cljs functions

gtrak15:07:11

it sounds like you need a multimethod to handle your responses

gtrak15:07:25

and the responses should be structured accordingly

a.espolov15:07:02

for example, cljs processes an http response, and redraws the component om according to new requirements

gtrak15:07:06

responses are asynchronous, so when making an ajax request, you specify how to handle a response

gtrak15:07:12

via a callback

gtrak15:07:31

which will call said multimethod

gtrak15:07:45

assuming you need that level of indirection

a.espolov15:07:53

No I don't need multumethods)

gtrak15:07:01

in this example, a hander function is provided at request-time to respond to responses: https://github.com/JulianBirch/cljs-ajax#getpost-examples

a.espolov15:07:35

Yes it is not something)

a.espolov15:07:49

url example /api/app

gtrak15:07:28

you can't return functions across the wire

a.espolov15:07:56

and all I need to do in cljs, so it's for ' unquoted # (js/alert "from Hu Hu")

gtrak15:07:06

if you want to hack something similar, an alternative is to use clojure.walk to replace data-structures with the functions they represent.

gtrak15:07:40

and probably a multimethod

gtrak16:07:31

there's no concept of unquoting a function, what you're trying to do is 'eval', which is insecure and only recently implemented anyway. An alternative is to interpret the data in a limited way, which is what I'm suggesting.

a.espolov16:07:43

Man you know what om/om-tools/render this function macros sablono?)

gtrak16:07:11

sablono has both a compiler and an interpreter for these hiccup-style templates

gtrak16:07:56

you should be able to call sablono's html function after having tree-walked your template and added handler functions.

a.espolov16:07:38

so I needed render that while the application is running can redraw the component with the new om html structure. Everything is OK I have it made. Not me not required to come up with unquoted as an anonymous function or any other (actually, there's not a lot of options)

a.espolov16:07:49

I don't use sablono

a.espolov16:07:58

cited as an example

colin.yates17:07:52

@mfikes - wow, just wow. I look forward to the tools we will be using daily in a few months because of this work.

mfikes17:07:11

@lazy-lambda: It’s essentially the same code. Here’s to hoping JavaScriptCore can find its way into Replicator!

colin.yates17:07:19

what’s the potential for using this runtime for lein or boot? I guess access to the filesystem would be an issue

mfikes17:07:00

Yes… perhaps Node is easier to use to do things like that (at least out of the box?)

mfikes17:07:52

It is pretty easy to endow JavaScriptCore with new capabilities by plugging in a little native code here and there.

colin.yates17:07:29

interesting - it isn’t something I have thought about really, just a reaction. I know the current lein and boot start up times are a pain point. No bandwidth (or knowledge in this area either) to do anything about personally 😉

mfikes17:07:12

@colin.yates: Right. If you take that to an extreme, you end up running the entire ClojureScript compiler in the bootstrapped runtime, which has lots of consequences.

mfikes17:07:44

(Mostly negative consequences, IMHO, with the one positive being faster launch.)

shaunlebron17:07:29

love the name too simple_smile

mfikes17:07:30

But, little scripts are a much less demanding environment. simple_smile

mfikes17:07:57

@shaunlebron: Can you guess at the reference for the name?

shaunlebron17:07:20

I don’t know much about physics, but yes, a planck length!

shaunlebron17:07:41

err, I think it’s the smallest measurement of space or time

mfikes17:07:03

Excactly. Was thinking of this thing: https://en.wikipedia.org/wiki/Planck_time

mfikes17:07:47

I think it would be difficult to launch a REPL faster than 10^-44 seconds.

shaunlebron17:07:32

that is an unfathomably short length of time

shaunlebron17:07:41

yeah, great name

colin.yates17:07:01

@shaunlebron: about as long as my kids’ attention span

shaunlebron17:07:46

lol, presciently short

dnolen17:07:06

@mfikes: does Plank have a command line -e thing?

dnolen17:07:19

just tried it easily the fastest “Clojure” REPL I’ve ever seen

mfikes17:07:45

No… but I hope people are interested in contributing to it, or using it as inspiration

mfikes17:07:13

-e would execute a form?

dnolen17:07:03

./plank -e “(+ 1 2)”

dnolen17:07:08

same thing that Clojure REPL supports

shaunxcode17:07:18

@mfikes seriously great stuff!

mfikes17:07:25

Ahh…. cool. yeah I faked that by using echo piped into it

shaunlebron17:07:37

just ran it, that is very fast

mfikes17:07:08

We have all been conditioned on how long it takes a REPL to launch. It reminds me of this experiment where subjects perceived a light lighting up prior to pressing the button.

mfikes17:07:44

Cool. That post is now in the new section of HN

shaunlebron18:07:05

the -e switch would make it easier to time the bootup. timing with a quick ^C will always go over simple_smile

mfikes18:07:52

That’s true. And perhaps there are ways to make it even faster. It is currently loading :none files as fast as it can.

shaunlebron18:07:55

I really like slurp and spit functions

dnolen18:07:13

@mfikes: hey with some more work you could have something cooler than Node.js target for ClojureScript users simple_smile

dnolen18:07:31

I’m assuming JSC can easily be built on every major OS

lazy-lambda18:07:52

I need some help building JSC for android

dnolen18:07:56

@lazy-lambda: seems tough, I really wish React Native for Android would get released to see how they do it simple_smile

mfikes18:07:37

@lazy-lambda: There is a React Native app for Android available (from Facebook)

mfikes18:07:06

Yay… at #1 on HN

robert-stuttaford18:07:14

@dnolen: cljs modules. fiiiinally getting to this. couple questions: can i include a :main per ‘end’ module?

dnolen18:07:00

@robert-stuttaford: does not work that way but it doesn’t need to

dnolen18:07:12

just include the entry point in as something in the module

robert-stuttaford18:07:44

cool. spinning it up now

shaunxcode18:07:21

man that is impossibly fast - I love it

shaunxcode18:07:14

at first I instinctively sat there staring at the screen waiting and then realized it was ready before I even started waiting.

raymcdermott19:07:09

just playing with planck: super stuff again Mr @mfikes

raymcdermott19:07:13

time echo '(+ 1 2)' | ./planck 3 real 0m0.671s user 0m0.726s sys 0m0.102s

robert-stuttaford19:07:50

what is planck? *fomo *

mfikes19:07:02

What is fomo?

robert-stuttaford19:07:08

Fear Of Missing Out

mfikes19:07:21

Look at HN simple_smile

mfikes19:07:46

It is a REPL I made for the desktop based on JavaScriptCore and bootstrapped ClojureScript

robert-stuttaford19:07:50

got a direct link? nothing’s jumping at me

mfikes19:07:23

Sorry, @robert-stuttaford I’m being a dork

robert-stuttaford19:07:46

whoa, interesting!

mfikes19:07:12

They removed it from HN.

raymcdermott19:07:29

unfair comparison but the standard lien repl on my MBP gives

raymcdermott19:07:31

time echo '(+ 1 2)' | lein repl user=> (+ 1 2) 3 user=> Bye for now! real 0m3.475s user 0m4.809s sys 0m0.338s

robert-stuttaford19:07:44

man, this is going to change things quite a bit

robert-stuttaford19:07:56

good old dependable HN

brettevans19:07:21

It’s down at #16

mfikes19:07:12

Ahh… yeah. It initially had a controversial title, which probably put it at #1, and then its title was revised by the HN admins.

robert-stuttaford19:07:45

@dnolen: code motion question. aside from :entries, what decides when things go into the edge modules? i thought it would be “if only this edge module uses it, it goes in this edge module”, but i’m not seeing this. i’m using 3308.

robert-stuttaford19:07:11

i could add all the nses to entries, but that doesn’t feel like the way you would have put it together

dnolen19:07:20

@robert-stuttaford: no where has such a statement been written simple_smile

dnolen19:07:32

every documentation of :modules in the wild is clear about this

dnolen19:07:47

if you know a library belongs in a specific module be explicit about it

dnolen19:07:14

you don’t have to enumerate every last module, but anything obvious should be declared

robert-stuttaford19:07:27

i’ve got us.common.*, and us.app1.* and us.app2.*. each app has its own entrypoint ns, which starts stuff up. i’ve put each of those into their own module as :entries. i was hoping that for us.app1, it would bring in all the other us.app1.* nses automatically, and leave only the genuinely common stuff in core.

dnolen19:07:19

it just doesn’t work that way

dnolen19:07:28

not shadow-build not Google Closure itself

dnolen19:07:32

it’s very easy to make mistakes in your code that prevent code motion

dnolen19:07:42

so Closure cannot move a library

dnolen19:07:56

this is why being explicit is important

robert-stuttaford19:07:16

i’m going to keep digging at it

robert-stuttaford19:07:26

by library, you mean namespace, right?

dnolen19:07:00

Closure will really only move primitive JS values and functions

dnolen19:07:23

if you have a top level CLJS data structure and your functions refer to it

dnolen19:07:26

none of that code will move

dnolen19:07:49

if you have top level invoke anything depends on it’s result

dnolen19:07:52

that code won’t move

dnolen19:07:24

it took a ton of work to make the standard library code motion friendly

robert-stuttaford19:07:35

that’s the problem

dnolen19:07:38

I don’t really expect application developers to do this

dnolen19:07:51

so you need to be explicit about your modules dependencies

robert-stuttaford19:07:53

good old (defonce app-state (atom {}))

robert-stuttaford19:07:20

ok. thank you. i have a path to follow simple_smile

robert-stuttaford19:07:56

yeah. we use a common ns for history, which has a goog.History instance. ditto common code for the om/root + defonce’d atom. both sound like good candidates for preventing code motion

robert-stuttaford19:07:10

@dnolen: one more question, sorry. should :simple be putting everything in a single file, like :advanced does, or does :simple load stuff from the output-dir ?

dnolen19:07:45

:simple :advanced work differently with :modules

dnolen19:07:53

normally single file yes

robert-stuttaford19:07:17

sorry, single file per module, i should have said simple_smile

robert-stuttaford19:07:26

ok. cool. just trying to be clear about what i’m seeing

dnolen19:07:09

:simple and :advanced should work the same here, I didn’t try :simple that much since not expected to be a common pairing.

robert-stuttaford19:07:31

it would be awesome if :entries could take wildcards

robert-stuttaford19:07:05

is that kind of thing possible, dnolen?

robert-stuttaford19:07:23

for the future, i mean. i realise it’s not supported now

dnolen19:07:32

@robert-stuttaford: not going to do that

dnolen19:07:37

what’s there is how it works

dnolen19:07:57

if people want something do it in a downstream tool

dnolen19:07:47

basically everything ClojureScript takes needs to be in a fully decomplected data only form

dnolen19:07:59

it’s already too complicated as it is

dnolen19:07:05

anything more just makes a bigger mess

dnolen19:07:21

and prevents downstream innovation too

robert-stuttaford19:07:52

that’s true. gotta be strict about making it do more

dnolen19:07:27

and plenty of new stuff coming down the pipe

robert-stuttaford19:07:40

this is just a poor understanding on my part, but how do macro namespaces play out?

robert-stuttaford19:07:47

should i include them in :entries?

dnolen19:07:58

macro namespaces don’t exist at runtime

robert-stuttaford19:07:29

i must say, it feels like cljsbuild isn’t really doing anything any more - it’s all in the compiler now

dnolen19:07:12

yeah cljsbuild (which is great but old) got too quirky for me so I moved the essential services in

robert-stuttaford19:07:04

cljsbuild got us here simple_smile

robert-stuttaford20:07:22

ok, i’m having some success

robert-stuttaford20:07:53

by putting all our shared code into a module, that’s insulated the apps from all the common defs and now it’s all split correctly

robert-stuttaford20:07:37

well. not completely, but it’s closer than it was before

dnolen20:07:46

submit a talk!

robert-stuttaford20:07:42

so, only by explicitly putting each ns i want in :entries do i get the behaviour i want. that’s going to be painful to maintain, but i guess it’s worth it, and we can write tooling to automate the updating of it

robert-stuttaford20:07:50

i’m happy. thanks dnolen for your help!

robert-stuttaford20:07:07

new question: is there a safe way to load two separately compiled :advanced js on the same page?

robert-stuttaford20:07:28

almost certainly with differing clojurescript versions

dnolen20:07:40

no that’s a recipe for disaster

dnolen20:07:52

unless you can prevent them from interacting at all

robert-stuttaford20:07:47

that’s the problem they need to interact. right now, we have one advanced and one whitespace, and they interop via a single js interop call

robert-stuttaford20:07:03

legacy code we haven’t had the time to port 😐

dnolen20:07:16

that can never work unless you marshal between the two via JSON or Transit or something like that

dnolen20:07:38

if you do that then wrapping both things in closures should work

robert-stuttaford20:07:43

the API between the two is very small, just one fn with two string args

robert-stuttaford20:07:18

so that’s ok. its just we can’t have them both advanced and on page at the same time. all sorts of silly things happen

robert-stuttaford20:07:37

i guess because they both live in the global scope

robert-stuttaford20:07:54

anyway. just a curiosity. we’re close to not needing the old code now

smnirven20:07:29

anyone ever run into a 414 (uri too long) error with figwheel

dnolen21:07:14

@mfikes: ^ big deal, Oliver Hunt is one of the JavaScriptCore tech leads simple_smile

mfikes21:07:55

@dnolen: Awesome. I’ll thank him for his work.

pupeno21:07:51

Should I learn React before learning Reagent?

shaun-mahood22:07:00

@pupeno: I don't think you need to, I was able to get up and running with it pretty easily and have never done any react programming. Reagent has a bunch of good examples and is pretty easy to get started with.

pre22:07:32

How do you generate .cljs and .clj source files from a Clojure 1.7 project using .cljc?

jwm22:07:31

got my stickers, thank you

jwm22:07:09

they look great

dnolen22:07:58

@pri: that's not how it works. Can just be loaded by either compiler.

pre22:07:38

@dnolen: I’m looking to migrate a couple of .cljx projects (including garden), but not sure how I should go about it.

pre22:07:17

Currently, I hook up lein-cljx in the build, along with figwheel, so figwheel picks up the cljs sources.

pre22:07:22

I can’t get cljs.repl or figwheel to work with .cljc files, thoughts?

pre22:07:27

Would this load the .cljc source files? `cljs.build.api/build …”

dnolen23:07:21

@pri: no idea why you’re having problems with cljs.repl if you’re using 3308 and Clojure 1.7.0, don’t know anything about figwheel here

pre23:07:15

3308 and this `(b/build "src" {:main 'vfl-clj.core :output-to "target/app.js" :output-dir "target" :optimizations :none :source-map true :verbose true})`

pre23:07:47

src has a single .cljc file

dnolen23:07:07

@pri: I’ve been using .cljc this whole time while working on ClojureScript itself

dnolen23:07:11

haven’t encountered this problem

dnolen23:07:19

so have others

pre23:07:30

I noticed that; perhaps it would be useful to update lein meis or a bare bones repl running a cljc example.

pre23:07:55

AFAIK none of the cljx projects are migrated to cljc.

dnolen23:07:31

@pri: I would suggest putting a minimal failing example somewhere

dnolen23:07:44

no dependencies, then easy for someone to point what’s wrong

pre23:07:50

let me do it now ..

dnolen23:07:02

I have to run, but I’m sure someone else will see the issue

pre23:07:58

ok, thanks.

mfikes23:07:01

@shaunlebron: @dnolen: I added -e support and you can see that Planck is very comparable to “straight” Clojure, but lein repl evidently does a lot more: https://gist.github.com/mfikes/2c704aca591a2bf8442a

mfikes23:07:22

And I guess the difference between real and user output for the JVM-based timings reflects the use of multi-threading. Dunno.