This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-16
Channels
- # admin-announcements (5)
- # announcements (2)
- # beginners (2)
- # boot (3)
- # cider (54)
- # clojure (196)
- # clojure-berlin (16)
- # clojure-brasil (4)
- # clojure-dev (36)
- # clojure-italy (3)
- # clojure-japan (9)
- # clojure-korea (3)
- # clojure-russia (18)
- # clojure-uk (24)
- # clojurebridge (11)
- # clojurescript (414)
- # code-reviews (1)
- # core-typed (4)
- # datomic (59)
- # editors (30)
- # euroclojure (2)
- # events (1)
- # jobs (2)
- # ldnclj (16)
- # liberator (11)
- # off-topic (59)
- # om (16)
- # onyx (33)
- # reagent (53)
- # thejaloniki (2)
- # yada (1)
@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
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))
If you can't use aget on objects in Clojure you shouldn't using them on objects in ClojureScript.
I hope I understood you correctly. https://github.com/cljsinfo/cljs-api-docs/issues/128
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?
(http/post url {:transit-params params :transit-opts {:encoding-opts {:handlers {MyType MyTypeHandler}}}})
@wilkerlucio: gist MyTypeHandler
, also a good way to sanity check is to test w/o cljs-http first
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:
(deftype TempidHandler [] Object (tag [this v] "tempid") (rep [this v] v) (stringRep [this v] nil))
@dnolen: you are right, I missed that, but it still doesn't work...
@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
More detail behind the scenes with @lazy-lambda http://blog.fikesfarm.com/posts/2015-07-15-clojurescript-on-android.html
This is DeepBlueLambda’s https://play.google.com/store/apps/details?id=com.sattvik.clojure_repl
Ahh. That’s nice and fast. @lazy-lambda can hopefully compile and embed JavaScriptCore
That’s right. I still maintain that Replete on an iOS simulator is the fastest REPL in the West (to launch)
@mfikes: super excited about this stuff. It’s incredible how fast everything is moving considering I could barely compile expressions at EuroClojure
@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
@dnolen: Somehow you "called it” with respect to mobile 1½ years ago with this prescient advice http://stackoverflow.com/a/21330653/4284484
@mfikes: very cool stuff - way to go to you and @lazy-lambda
@lazy-lambda: Is a machine that does not sleep.
@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.
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
I was wondering why read-string in clojurescript returns null instead of an exception when reading a non-string
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
the easiest way to get ClojureScript into weirder JS environments - :simple
optimizations
@dnolen: oh great. I never used clojurescript outside the browser. I follow the whole clojurescript on node/rhino/some random spaceprobe discussion very remotely
@ordnungswidrig: haha, that was my first thought when I saw it in #C03RZGPG3 😄
@martinklepsch: let’s go!
Pretty good stuff about transducers: https://github.com/funcool/clojurescript-unraveled/blob/master/src/language-advanced.adoc (Author also asked for RfC)
@ordnungswidrig: the main downside is degraded tooling. But it’s usually not that much work.
if you can give CLOSURE_IMPORT_SCRIPT
an implementation then REPL driven development is not far off
@dnolen: well, when used to configure a window manager then I can live with it.
Looking at the configuration files for phoenix I don’t think it’s worth it really. More of an exercise @ordnungswidrig
Aside, I will only trust clojurescript when it runs on a ESP8266
@martinklepsch: you don’t know my config file.
@ordnungswidrig: ha, then you should write a Lua backend for ClojureScript
dnolen: there used to be one
@ordnungswidrig: yes but it never got very far
is the memory footprint because of javascript or because of clojure?
@dnolen: maybe a good idea to define a threshold for “good amounts of memory” for other people following along
@martinklepsch: this is very challenging to compute
VM needs to parse, hold onto sources, object layout is different depending on optimization level
@dnolen: do you care for a jira issue btw? I just asked because I was curious, not because it was a huge problem
@dnolen: thinking of ballpark figures. “good amounts of memory” could easily me interpreted as 4gig or so.
@martinklepsch: at least 5mb for Node.js, whatever it takes to store information about ClojureScript sources
I got "This site is currently undergoing maintenance. We apologize for the inconvenience."
@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?
Pretty sure it would be either ReferenceError
or TypeError
depending on context. (in standard JS)
@borkdude: trying to match the error type between ClojureScript and Clojure is not a good use of time
@borkdude: you’ve signed a CA, you now have elevated JIRA permissions - you can assign it to yourself now 😉
@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.
@eggsyntax: I do not want to document this kind of information on the wiki.
@eggsyntax: including random JS libraries will become simpler by the end the year so we’re working on the actual problem
Oh, awesome . 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.
@eggsyntax: we’re definitely aware of the problem, but as usual we prioritize just doing it right
Can't argue with that. It's a big part of why I made the move to clj/s in the first place.
@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*
@bostonou: I’m assuming you want to compile-time/run-time support for some data literals
there’s no good way to do this and several tickets that need to be completed first for this to work
that’s what i suspected. and yet another reason cljs compiled in cljs is useful correct?
you have any quick pointers to those outstanding tickets or what i should search jira for?
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
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
the CLJS-1277 is the only slightly tricky bit, requires some thought but I don’t think particularly hard
the main challenge is making this work for builds, would need to collect all cljs.user
fragments
definitely willing to help out laying out / guiding the approach if someone is willing to take it on of course.
@bostonou: curious, what’s your use-case for adding custom data literals?
@shaunlebron: answering stack overflow questions
ha okay
just imagining cljs code with some custom data literals for some domain specific things
not sure what the best practices are
as opposed to just regular constructors I mean
#js
and #inst
are helpful and standard of course
yeah. i’m not sure it’s a good/necessary idea, but didn’t want to go that path in the discussion
yeah, could you link the SO question?
http://stackoverflow.com/questions/31430489/can-reader-tags-be-used-with-clojurescript/31457252
it came across my twitter feed and was one of those questions my brain wouldn’t let go of 😕
making data-readers.clj -> cljc means it can be loaded into the compiler and into the runtime and work more or less as expected
I think a lot of people that want it have stopped asking since it’s not obvious how to accomplish the desired result
@dnolen i’m going to do some exploring to make sure i understand the issue. open to pointers if you have them
basically the issue would be making sure cljs.user
is the namespace if the file doesn’t have an ns form
step 2 is making it possible to merge together all cljs.user
namespaces into a single thing and moving the requires
step 2 is what would allow libraries to supply data-readers.cljc
individually and builds always get the aggregation of reader extensions
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"
Om and reagent? How was that split?
ah ok
@a.espolov: unquote? kind of https://github.com/cljsinfo/cljs-api-docs/blob/catalog/refs/syntax_unquote.md
I thought unquote had to be in a syntax quote
I don’t know much about this
@a.espolov: what you pasted wouldn’t work in Clojure either
if you wrap it in a syntax quoted list, seems to work
inching closer to eval
, all you need to do to build a bootstrapped thing is include cljs.js
, no other compiler configuration 😄
wow, that’s neat, I wanna see what that ns looks like then
oops, that’s a filename
nothing much to see there yet https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/js.cljs
so cljs.js
will need to reintroduce side-effects but asynchronously via cljs.js/*load-fn*
in browser lib name -> url -> fetch, in Node.js lib name -> file on disk -> fs.readFile
@a.espolov: the errors will rarely match, drop the quote
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)))))
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.
I understand that I have not be able to cljs unquoted for the resulting object at run time?
for example, cljs processes an http response, and redraws the component om according to new requirements
responses are asynchronous, so when making an ajax request, you specify how to handle a response
in this example, a hander function is provided at request-time to respond to responses: https://github.com/JulianBirch/cljs-ajax#getpost-examples
if you want to hack something similar, an alternative is to use clojure.walk to replace data-structures with the functions they represent.
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.
you should be able to call sablono's html function after having tree-walked your template and added handler functions.
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)
Fast JavaScriptCore Desktop ClojureScript REPL: http://blog.fikesfarm.com/posts/2015-07-16-fast-javascriptcore-desktop-clojurescript-repl.html
@mfikes - wow, just wow. I look forward to the tools we will be using daily in a few months because of this work.
:thumbsup: @mfikes
@lazy-lambda: It’s essentially the same code. Here’s to hoping JavaScriptCore can find its way into Replicator!
what’s the potential for using this runtime for lein or boot? I guess access to the filesystem would be an issue
It is pretty easy to endow JavaScriptCore with new capabilities by plugging in a little native code here and there.
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 😉
@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.
yeah, I see.
@mfikes: excellent
love the name too
@shaunlebron: Can you guess at the reference for the name?
I don’t know much about physics, but yes, a planck length!
err, I think it’s the smallest measurement of space or time
Excactly. Was thinking of this thing: https://en.wikipedia.org/wiki/Planck_time
that is an unfathomably short length of time
yeah, great name
@shaunlebron: about as long as my kids’ attention span
lol, presciently short
No… but I hope people are interested in contributing to it, or using it as inspiration
@mfikes seriously great stuff!
just ran it, that is very fast
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.
the -e
switch would make it easier to time the bootup. timing with a quick ^C
will always go over
That’s true. And perhaps there are ways to make it even faster. It is currently loading :none
files as fast as it can.
I really like slurp
and spit
functions
@andrewmcveigh is working on these io type functions for node in
https://github.com/andrewmcveigh/cljs.node.io
@mfikes: hey with some more work you could have something cooler than Node.js target for ClojureScript users
I need some help building JSC for android
@lazy-lambda: seems tough, I really wish React Native for Android would get released to see how they do it
@lazy-lambda: There is a React Native app for Android available (from Facebook)
@dnolen: cljs modules. fiiiinally getting to this. couple questions: can i include a :main per ‘end’ module?
@robert-stuttaford: does not work that way but it doesn’t need to
cool. spinning it up now
man that is impossibly fast - I love it
at first I instinctively sat there staring at the screen waiting and then realized it was ready before I even started waiting.
just playing with planck: super stuff again Mr @mfikes
time echo '(+ 1 2)' | ./planck 3 real 0m0.671s user 0m0.726s sys 0m0.102s
blimey
what is planck? *fomo *
Fear Of Missing Out
It is a REPL I made for the desktop based on JavaScriptCore and bootstrapped ClojureScript
got a direct link? nothing’s jumping at me
http://blog.fikesfarm.com/posts/2015-07-16-fast-javascriptcore-desktop-clojurescript-repl.html
Sorry, @robert-stuttaford I’m being a dork
whoa, interesting!
unfair comparison but the standard lien repl on my MBP gives
time echo '(+ 1 2)' | lein repl user=> (+ 1 2) 3 user=> Bye for now! real 0m3.475s user 0m4.809s sys 0m0.338s
man, this is going to change things quite a bit
good old dependable HN
It’s down at #16
Ahh… yeah. It initially had a controversial title, which probably put it at #1, and then its title was revised by the HN admins.
@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.
i could add all the nses to entries, but that doesn’t feel like the way you would have put it together
@robert-stuttaford: no where has such a statement been written
😁 damn!
you don’t have to enumerate every last module, but anything obvious should be declared
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.
ok, thanks
i’m going to keep digging at it
by library, you mean namespace, right?
that’s the problem
good old (defonce app-state (atom {}))
ok. thank you. i have a path to follow
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
@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 ?
sorry, single file per module, i should have said
ok. cool. just trying to be clear about what i’m seeing
:simple
and :advanced
should work the same here, I didn’t try :simple
that much since not expected to be a common pairing.
it would be awesome if :entries
could take wildcards
is that kind of thing possible, dnolen?
for the future, i mean. i realise it’s not supported now
@robert-stuttaford: not going to do that
basically everything ClojureScript takes needs to be in a fully decomplected data only form
that’s true. gotta be strict about making it do more
this is just a poor understanding on my part, but how do macro namespaces play out?
should i include them in :entries?
i must say, it feels like cljsbuild isn’t really doing anything any more - it’s all in the compiler now
yeah cljsbuild (which is great but old) got too quirky for me so I moved the essential services in
cljsbuild got us here
ok, i’m having some success
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
well. not completely, but it’s closer than it was before
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
i’m happy. thanks dnolen for your help!
@robert-stuttaford: no problem
new question: is there a safe way to load two separately compiled :advanced js on the same page?
almost certainly with differing clojurescript versions
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
legacy code we haven’t had the time to port 😐
that can never work unless you marshal between the two via JSON or Transit or something like that
the API between the two is very small, just one fn with two string args
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
i guess because they both live in the global scope
anyway. just a curiosity. we’re close to not needing the old code now
Should I learn React before learning Reagent?
@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.
@dnolen: I’m looking to migrate a couple of .cljx
projects (including garden), but not sure how I should go about it.
Currently, I hook up lein-cljx
in the build, along with figwheel, so figwheel picks up the cljs sources.
@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
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})`
I noticed that; perhaps it would be useful to update lein meis or a bare bones repl running a cljc example.
@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