This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-17
Channels
- # admin-announcements (22)
- # beginners (15)
- # boot (38)
- # cider (16)
- # clojure (68)
- # clojure-android (1)
- # clojure-berlin (27)
- # clojure-japan (7)
- # clojure-nl (7)
- # clojure-poland (2)
- # clojure-russia (164)
- # clojure-uk (2)
- # clojurescript (321)
- # datomic (42)
- # editors (45)
- # events (4)
- # indycljs (2)
- # jobs (7)
- # ldnclj (7)
- # liberator (4)
- # off-topic (29)
- # om (5)
- # onyx (8)
- # re-frame (6)
- # reagent (44)
- # slack-help (9)
@mfikes a lot is perceptual since all of Clojure has to load before you get the prompt
Yes. iOS apps appear to launch quickly by employing static launch images that look like the initial UI in order to deceive and give an impression of faster launch. Planck is employing that trick.
@dnolen: yeah. I was also trying to think of ways to optimize further. If that could be achieved, then it becomes even more relevant to scripting.
Could someone show me how to run a ClojureScript test, for example https://github.com/clojure/clojurescript/blob/master/src/test/cljs/cljs/core_test.cljs?
I noticed there's a test_runner.cljs at https://github.com/clojure/clojurescript/blob/master/src/test/cljs/cljs/test_runner.cljs.
@mfikes I'm really not sure what more you could. Pretty sure that's just parsing time.
So, a couple hours ago I released my first ClojureScript/Clojure app to Heroku! However, Bootstrap's Carousel runs locally after I run lein uberjar
, but not on Heroku. I'm curious about why they're behaving differently, as I figured Heroku used uberjar. Does anyone know why the difference?
@coyotespike: just to be sure, after lein uberjar
, are you running the jar locally in the exact same way as you have in your Procfile?
huh... my Procfile has web: java $JVM_OPTS -cp target/myapp.jar clojure.main -m myapp.server
, but I run my local jar with java -jar target/myapp.jar
Should I do that differently?
@nberger - I've reproduced a second error locally - a navbar dropdown menu has stopped working. So that's something.
@coyotespike: bootstrap navbar is just css, isn't it? the html is being generated correctly?
Yes, the html looks all right. The pictures just don't scroll.
If anyone’s interested in using cljs repls without any deps, I just released 0.2.1 of a tiny library that might be easier
@dnolen: it’s basically putting all your scripts into functions so they can be fired as tasks
Max OSS maintenance long ago achieved for me, too busy even for reviewing PRs these days sadly.
@pri: I tried it and it worked for me. (At least for Node.) I’ve never seen build output right in the REPL… that’s new for me. Sometimes my terminal would be a little funny (erasing on its own to the left)—perhaps that a consequence of build output interleaving.
Otherwise, changing the hello.core
ns to define new symbols, (require .. :reload)
worked, etc.
@pri: It is when I manually type a (require
at this point in the video https://www.youtube.com/watch?v=mp3cfgI0Yvc#t=00m044s
planck is very nice
@wildermuthn: Thanks… it may lead to something useful.
I suppose one advantage of wrapping JavaScriptCore yourself is: If you need it to do anything, then it is up to you. I suspect the same may be true for Node.js, but I don’t know.
You have a gist or github?
Yeah, that’s what I meant
I don’t know much about JavaScriptCore
That injects a global JavaScript function into JavaScriptCore named PLANCK_SLURP_FN
that accepts a single string argument and returns a string.
ah, the slurp and spit?
I see, very interesting!
Here is the “fake” slurp
being defined: https://github.com/mfikes/planck/blob/master/planck/Planck.m#L98
Clojure is ready to conquer every platform. I love it.
But the JavaScriptCore bit you were interested in is the context
variable on the fist line I linked to.
That’s blowing my mind a bit, cljs -> js -> objectiveC
This REPO has an interesting mixture of Java and JavaScript all essentially in the same process as well: https://github.com/swannodette/jsx-fun
ClojureScript is hosted on JavaScript, but then JavaScript could be thought of as hosted in a sense in another container environment that may be in another language.
Nice work!
Thanks! (It was one of those things that, once I realized it could be done, it had to be done.) That seems to be happening frequently lately.
@shaunlebron: Still a WIP, don’t think I’ve got the right abstraction with http://cljs.node.io
I get ERROR: JSC_DUPLICATE_PARAM. Parse error. Duplicate parameter name "default_option"
in :advanced
compilation mode because I have both default_option
and default-option
names in my function. Is it documented anywhere that names diffing only in underscore/hyphen should be avoided? Will such use lead to unexpected/erroneous behavior in compiled code?
these are arguments to the function? when I try that, compilation fails
same with (defn foo [param! param-BANG-] ...)
in advanced compilation mode am I supposed to provide goog/base manually? I thought it would be included in main.js?
I have a cljsbuild for dev with optimisations: none. If I change that to :advanced it can’t find goog/base.
First time I have tried to use anything other than :none so I fully expect this is me being a numpty...
@colin.yates: It should be included
Can you show your compiler config?
sure:{:dev {:source-paths ["src/cljs" "src/cljc"] :compiler { :output-to "resources/public/out/main.js" :output-dir "resources/public/out" ;; figwheel needs this to be none :optimizations :none :source-map true}} :prod {:source-paths ["src/cljs" "src/cljc"] :compiler {:output-to "resources/public/out/main.js" :optimizations :advanced}}}
javascript errors:
Uncaught TypeError: (void 0) is not a function(anonymous function) @ main.js:26618(anonymous function) @ main.js:34585(index):2 Uncaught TypeError: goog.require is not a function
@ul if I've understood you correctly, when I try that it works just like regular shadowing, so if you need two different names with two different values, you won't get the expected result
@colin.yates: Are you using cljsbuild?
latest versions of all libs as well
this is a re-frame app if that helps
Can you check the js file? TBH, it looks to have too many lines to be an advanced compiled js file
it is 1.5M
If you can read function names, it’s not minimized.
876K of my cljs
everything looks like obfuscated source code used to so I assume that is minimised
Ah, ok that seems right.
So, I’m kind of guessing here… but maybe goog.require has been minimised?
ah hang on - I am still including the figwheel connection code in the JS - let me remove that first...
Yeah, that could be it.
If you’re trying to call goog.require from static js, maybe it got minimized
simple is 4.8M BTW
I am using google closure (for dom events for example) in cljs. I assumed the closure lib would be externed already so I am not doing anything special there
Yeah, it should be. But, often you’ll have goog.require
lines in your page, for repl stuff
Searching for goog.require in my cljs has 0 hits
removing figwheel hasn’t helped. Assuming it is the same error in simple and advanced I will try simple and see if that provides more context
Yep, if you try simple mode, the error will go away if it’s a minimising issue.
@ul seems like a minor edge case - file a bug. Don’t really have any good ideas about solving that one at the moment. Thanks.
@colin.yates: this is why you never wait to do advanced builds
Your issue is absolutely typical. To fix it enable :pseudo-names true :pretty-print true
compiler options. You should be able to see what got renamed that you didn’t expect.
good advice @dnolen. I have incorrectly assumed advanced was only about filesize and given this app is on a low latency internal LAN I wasn’t really that concerned. Now I understand it has performance benefits I thought I would take a look. But yes, fail early indeed.
It is failing at the figwheel code, but I don’t understand why. I have #_ the figwheel fragment in my cljs although the (:require [figwheel..]) is still there. I am surprised any figwheel code made it into my main.js?
I assumed dead-code elimination would remove it - #_ is equivalent to deleting the code in cljs isn’t it?
@colin.yates: that's not how dead-code eliminations works
ah ok, I see.
is it sufficient to #_
so flip me - wow. Now it works it is significantly faster!
@colin.yates: I would probably split out figwheel into a different build profile so you don’t have to comment out code to make a production build
yes, indeed Once again I am pleasantly surprised at how easy these sort of things are to do in Clojure and horrified at how many unfounded assumptions I make
Thanks @dnolen and @andrewmcveigh
any nifty tricks for removing (.log js/console …) from production builds? I could use a wrapper fn or maybe macro - any tricks?
@colin.yates: we use a macro to check an env var, and omit based on that
@colin.yates consider https://github.com/ptaoussanis/timbre, it supports CLJS
(defmacro dev-only [& body]
`(when-not (= (System/getenv "APP_ENV”) “production”)
(do ~@body)))
^^ something like that
@colin.yates: in production I do this: (set! cljs.core/print-fn identity), but that's just for disabling println
@colin.yates: check out the configuration of this project for different dev and prod config: https://github.com/borkdude/lein2boot
thanks all - great ideas.
@colin.yates: If you want more control over what logging goes intro production. Check out the macros file from my project: https://github.com/rauhs/klang#with-deployment-to-clients In fact, I stole the whitelist/blacklist stuff from timbre.
If curious: There have been 81 downloads of the Planck binary, getting bootstrapped ClojureScript some direct exposure to people. Unknown how may have tried Joel's Node and web variants. A total of 123 beta testers of Replete currently. Excited to see where this leads when Replete, and later, Replicator are available in their respective stores.
@mfikes: I think there’s huge potential for Planck in the long view particularly its embeddability over Node.js.
Yes, Planck (I can’t spell it either hah!) could evolve into something actually pragmatic and useful
For educational purposes (schools with Macs or PCs), it would be interesting to have something free in the MAS (or equivalent Windows store)
(I really think Clojure is an understandable language for students, over the complexity of Java or even Python.)
at least under OS X platform where you can link to JSC.Framework, that’s a pretty sweet small thing.
Nice. I was even thinking that the reader/analyer/parser could even be :advanced
in a separate JSC instance just to be used as a local compiler service. But achieving that would be a bag of hurt right now. And questionable for future maintenance.
@mfikes: advanced would actually be pretty problematic, it makes looking up core stuff way harder
mfikes: I certainly agree re: Clojure (or a LISP generally) being a suitable language for students
For students (with Macs) a MAS free app that comes with a canvas would be interesting.
@mfikes: if you had a self contained JSC + ClojureScript bootstrapped you could probably expose some kind of simple API for C/C++/Objective-C a la RT.java for Clojure?
it's maybe not the best, because it's hosted and it's always handy to know something about the hosting enviroment
I recall in college really getting the initial courses in Scheme, and then when we wanted to e.g. start working with files or (gasp) network sockets the answer was “well that’s kind of …a pain, how about you do that project in your data structures class (taught in Java) instead"
the idea of having a LISP-for-teaching that is also able to get out to the impure world of “actually doing things with the computer” is brilliant IMO
@borkdude: @chris_johnson: Something like this thing: https://itunes.apple.com/us/app/clozure-cl/id489900618?mt=12
I wonder how kids nowadays pick up programming. Do they open the browser console and try things, like I just tried GW Basic once I discovered it on my brothers PC?
my 9 year old has been using https://scratch.mit.edu for the past couple of years and picked it up really quickly.
I started with the ZX Spectrum - the best machine ever. I still miss the ‘music’ of loading from tape!
+1 for scratch, my daughter was able to pick it up pretty fast
another interesting ticket for the would-be ClojureScript compiler hacker http://dev.clojure.org/jira/browse/CLJS-1343
There was a recent Cognicast where Craig Andera was discussing that it turns out learning FP first can be natural
Newbie ClojureScript JIRAs: http://dev.clojure.org/jira/secure/IssueNavigator.jspa?mode=hide&requestId=10616
@dnolen: Sorry I marked that ticket as newbie without reading what it was. Maybe that one isn't
And people interested in the ClojureScript compiler, here are tickets with patches that could be tried out: http://dev.clojure.org/jira/secure/IssueNavigator.jspa?mode=hide&requestId=10707
A part of me wants to one day see the technical stunt of having bootstrapped ClojureScript compile the compiler. (It will have reached its fixed point.)
@mfikes: that’s probably not so far off it’s pretty close to compiling the standard library
@mfikes: back to my point about Planck, this just seems to me to be a really nice way for interacting with C based systems if the size of JSC isn’t a concerning factor. While I sympathize with Clojure-C and similar ventures, with JSC you’re getting the world class GC and JIT you’d never have the time to write yourself.
@dnolen: Compiled JSC is 17 MB
@borkdude: I volunteer at our local CoderDojo, teaching kids to program. We start with http://code.org, then move to Scratch. We’re looking into the next step now.
One candidate is Snap! (http://byob.berkeley.edu/), which is basically Scheme implemented with a block-based UI.
@cfleming: nice - I was wondering how to amuse 4 kids for the next 7 weeks. The 3 year old is probably a bit too young still.
@colin.yates: Yeah, my daughter is 17 months so it’ll probably be at least 6 months before I get her programming
colin.yates: I'm going to test http://www.robotturtles.com/ on 3yo
@dottedmag: Nice, I have a copy at home waiting for the right moment, I bought it off the KickStarter.
@dottedmag: nice. I am surprised this market isn’t being more exploitive. It seems ripe for a bit of disruptive technology to make a killing….
@cfleming: they make the best testers at that age though!
dribble, crumbs, randomly hitting the keyboard etc. Great stuff.
@lazy-lambda: yeah not that big for 2015
@lazy-lambda: I wonder, if you use a WebView on Android, what JavaScript engine is in it? Is it JSC?
@mfikes: In current-generation Android releases, there's a pretty tight link between WebView and Chrome for Android
So, if React Android becomes very popular (used in multiple apps on a given user’s device), then there would be multiple copies of JavaScriptCore. I guess that’s no big deal.
Yeah. I was thinking of memory (RAM) sharing of the JSC code pages. I dunno if that happens for JSC on iOS, but it could make launch quicker. But then, again, mobile devices are getting so darn fast these days.
hi, any recommendations for a minimalistic clojurescript lib to persist state to a server/database for reagent/om?
@robert-stuttaford: @dnolen wrt clj-refactor and cljs support of advanced features needing an AST: what is basically missing is plugging in tools.analyzer.js and see if it produces an AST we can work with. loads of stuff implemented in emacs-lisp works even now of course
I think they’re probably surprised people aren’t pushing it further it works really well
@arnaudsj: I don’t have any code to show but I use edn to transfer over the wire and then stick it in the DB - trivial and works for us.
There’s probably something basic I’m missing here:
(ns test.core
(:require [cljs.nodejs :as nodejs]))
(nodejs/enable-util-print!)
(println "First try")
(->> ["one" "two" "three"]
(map println))
(println "Second try")
(->> ["one" "two" "three"]
(map println)
println)
(defn -main [& args])
(set! *main-cli-fn* -main)
The output of this is:
First try
Second try
one
two
three
(nil nil nil)
Why does the code under “second try” print while the code under “first try” does not? (Both work fine in a repl)
This is on the latest versions of cljs and io.js.henrik: laziness; the first try just creates a lazy sequence that does not get realized, the second try passes that lazy sequence to println which forces it to be realized; similarly running in a repl forces it to be realized. You could use doall
instead of println
to force it as well
@pbostrom, doh, of course. Thank you. It’s like I have to learn everything all over again when I haven’t been programming for a while.
benedek: awesome
Is there any way in chrome to quickly see the original .js version of a file from the .cljs source-mapped version? I am aware that I can globally enable and disable source maps, but was wondering if I could quickly peek at the .js from the .cljs?
@samedhi: not a direct answer, but if you want to see code for a fn, evaluate it in a REPL to see its unreadable firm. Also, :repl-verbose
is handy
@samedhi: There's a file tree under the "Sources" tab that includes both .cljs and .js files. You can view the .js files directly.
I've pondered this before but I'm wondering if a periodic ClojureScript developers Google Hangout might not be a good thing
seems like a good way to get the overview in my brain out to people and to highlight issues that need working on
@dnolen: +1 I find a high-level overview invaluable in getting started
What's the preferred way to write Number.MAX_VALUE
in ClojureScript?
@stuartsierra: there is no reliable way to write that other than writing out the literal
Number/MAX_VALUE
does't work.
js/Number.MAX_VALUE
?
(.-MAX_VALUE js/Number)
?
Oh, you mean the MAX_VALUE
constant is not always available?
Ah, JavaScript.
It doesn't have to be an integer. I just want a number bigger than any other number.
@stuartsierra: In that case perhaps Number.MAX_VALUE? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE
maybe https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity
@dnolen I am talking about Number.MAX_VALUE
, which is standard JavaScript, not MAX_SAFE_INTEGER
@stuartsierra: ah k, so working with double
yeah, a floating-point number is fine. This is just for a default value to use in a compare
@stuartsierra: weird then js/Number.MAX_VALUE
works for me
Yeah, that works. I just wanted to know if it's correct.
@stuartsierra: the later two are correct
OK, good. I haven't developed an intuition about dotted literals in ClojureScript.
@stuartsierra: yeah basically ClojureScript supports a property access form that Clojure does not
Thanks!
@stuartsierra: https://github.com/cljsinfo/cljs-api-docs/blob/catalog/refs/syntax_Infinity.md
Infinity
can be used on its own, read by tools.reader
thank you @mfikes and @exupero, gets me close enough; though I still wish there was a more direct way to do it.
@dnolen: a google hangout would be great
@shaunlebron: yeah just figuring out a good time is the main problem. I mostly work through JIRA on Fridays. Not everyone can do OSS on Friday’s though and not everyone is EST time zone.
I think I remember hangouts having a record button for youtube uploads?
if not, someone attending can record and upload
I’d volunteer for that
maybe poll for available times on mailing list
@dnolen: I would love it if you could do a hangout with @mfikes and chat with him about all the awesome cljs repl stuff that's going on these days. Seems like every day there's something new and awesome.
@shaun-mahood: right would also be a way to get people talk about cool ClojureScript related things being worked on
That would be really great. So much good stuff going on right now.
I’d love to join.
is there a way to get the name of the function from within a function definition for use in place of code like this:
(defn start-rendering! []
(console/info "start rendering")
@meow: there isn’t, to do it correctly would require reflective machinery not present in the host
@dnolen: okay, cool. Was looking at goog.debug/getFunctionName but figured I'd ask first
New post: What is Bootstrapped ClojureScript? (this one is short and sweet): http://blog.fikesfarm.com/posts/2015-07-17-what-is-bootstrapped-clojurescript.html
What is going on? I'm getting clojure.lang.ExceptionInfo: No such namespace: goog.async, could not locate goog/async.cljs, goog/async.cljc, or Closure namespace "goog.async" at line 1
I'm using lots of stuff from goog and in my :require I've got
[goog]
[goog.async]
[goog.async.AnimationDelay]
I just added [goog.async]
to start using goog.async/nextTick
and now I get this error. Should be something simple, I just don't see it.
@meow: THis is really just google closure. You always have to require the namespace of where the function is actually at
Classic example is the format require: goog.string.format
which is required even is you require the goog.string
namespace.
Easiest is to look at the _tests.js file in google closure: https://github.com/google/closure-library/blob/eb26f425dbd99a70d2955d8fcc892f2fd0178acb/closure/goog/async/run.js
@meow: it’s a wart in Google Closure Library itself, not much we can do about that. It’s for this reason we added :import
On the subject of Planck timing perception and UX, in Replete, when you evaluate a form, there is actually a 50 ms artificial delay added before the form is sent for evaluation. Otherwise both the entered form and the result animate out at the same time, which results in this odd feel that is at odds with the notion that you are having a “dialog” with the evaluator. (You have to try it without the small delay to see it—strangely adding a delay can change the feel of the UX.)
It is odd the way human interfaces work out—telephone handsets playing your own voice back, etc.
@dnolen: Is there a wiki about the pros and cons and roadmap of bootstrapped cljs ?
@lazy-lambda: nothing about pros and cons, mostly because the cons right now are pretty obvious
So, something is off because I'm getting intermittent fps values of like 333
and 500
that are way beyond what you expect, which is around 60
or less, but this version has no atoms!!!
(defn measure-fps!
[callback previous]
(letfn [(step
[timestamp]
(let [previous (or previous (- timestamp 17))
elapsed (/ (- timestamp previous) 1000)
fps (->> (/ 1 elapsed) (.floor js/Math))]
(if (callback fps)
(request-animation-frame (measure-fps! callback timestamp)))))]
step))
(defn listen-fps!
"Executes callback at every frame returning the frames-per-second."
[callback]
(request-animation-frame (measure-fps! callback nil)))