This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-07-30
Channels
- # admin-announcements (24)
- # beginners (27)
- # boot (32)
- # cider (9)
- # cljs-dev (2)
- # clojure (96)
- # clojure-berlin (33)
- # clojure-dev (2)
- # clojure-gamedev (2)
- # clojure-germany (1)
- # clojure-italy (8)
- # clojure-japan (2)
- # clojure-russia (21)
- # clojurescript (178)
- # clojutre (3)
- # code-reviews (4)
- # core-async (58)
- # core-logic (22)
- # core-matrix (4)
- # cursive (10)
- # datomic (131)
- # events (9)
- # ldnclj (31)
- # off-topic (57)
- # onyx (9)
- # reagent (23)
@dnolen: https://github.com/clojure/core.async/commit/a833f6262cdaf92c6b16dd201d1876e0de424e14
I'm working on a core.async example for the wiki if anyone wants to help with it: https://github.com/clojure/core.async/wiki/Sieve-of-Eratosthenes
I'm getting stack overflow errors when I try to consume 7000 primes in a repl using (time (consume 7000 (chan-of-primes)))
@meow: What if you change consume to:
(defn consume [n ch] (take n (repeatedly #(<!! ch))))
any tips for why an uberwar-deployed app would barf with "[Error] ReferenceError: Can't find variable: goog (anonymous function) (app.js, line 1)" ? It looks to me like advanced compilation didn't run, but this is my first time trying to deploy to tomcat.
@angusiguess: To get a timing value I need to eliminate the default lazy behavior of clojure, that's why I defined it as:
(defn consume [n ch]
(dorun (repeatedly n #(<!! ch))))
there's even a js/out directory, which shouldn't be there if it was picking up the :uberjar profile settings. Or at least that's my weak understanding of it so far.
yikes... If I try and run lein uberjar
I get:
Compiling "resources/public/js/app.js" failed.
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.io.ByteStreams.limit
lein deps :tree to the rescue... something was pulling in a really old version of guava, so at least now it compiles in advanced mode.
confirmed... lein uberjar
runs advanced compilation, which gets bundled by ring uberwar, but uberwar won't do the advanced if it's run clean.
@dnolen: When you have time could you look into applying the patch for CLJS 836? http://dev.clojure.org/jira/browse/CLJS-836
@spinningtopsofdoom: hrm weird have you ever submitted a CA?
@spinningtopsofdoom: applied thanks for the bump
@spinningtopsofdoom: there’s also a #C07UQ678E chan
ah did not know that thanks!
based on http://dev.clojure.org/jira/browse/CLJS-1363, we can pass a namespace to compiler options in cljs.js. given the default of ’cljs.user
, guessed I could write something like :ns ‘my-app.core
, but then I see Assert failed: (ana/ast? sym)
. Should this just work out-of-the-box or is there something special to do to prepare?
@dnolen: trying to def into a namespace - https://gist.github.com/mhuebert/315aeaf81307275d35d4
I’m trying to use google analytics, and (when (not (undefined? js/ga)) …)
is giving me: Uncaught ReferenceError: ga is not defined
@mhuebert: thanks for the report http://dev.clojure.org/jira/browse/CLJS-1383
@arohner: compiles to typeof x != “undefined”
which is safe from blowing up if x doesn’t exist
@mhuebert: took a second to test that, cannot reproduce your issue, if you can provide complete steps to repro with master I will take a look.
did anyone here have any luck doing some live development with github's electron. Figwheel style?
fluke777: also curious
martinklepsch: Just tried to run the flappy bird demo and wonders. Works like a charm. I will experiment with this a little more I have some node dependencies I would like to have. Will let you know here.
fluke777: totally, please do!
@arohner: you should use goog.object/get - aget is only for arrays - see: https://github.com/cljsinfo/cljs-api-docs/blob/catalog/refs/cljs.core_aget.md
seriously, though - aget is meant to mimic the functionality of Clojure, where it only works on java arrays
the fact that it works on other types now in cljs is not by design and might go away in the future for compatibility with the concept of Clojure and for type-based performance gains
the goog namespace is always available since cljs uses the goog closure compiler so it is a good choice for things like this
goog.object is for interacting with js objects, and has methods like get
and getValueByKeys
that will perform well and work across all browsers
@fluke777 and @martinklepsch: someone recently posted a link to something for electron based on work done by @shaunlebron and @chrisoakman on cuttle or something.
I can't find it with a google search but I know I just saw something about it like maybe yesterday
@arohner: using aget
incorrectly in the future will likely result in a type warning similar to arithmetic
@meow: Maybe one of these? https://github.com/Gonzih/cljs-electron, https://github.com/karad/lein_template_descjop
@fluke777: found it - it wasn't here, it was on the mailing list: https://groups.google.com/forum/#!topic/clojurescript/nlqZMzgByjI
its a lein template: https://github.com/ducky427/electron-template
@fluke777: np - let me know what you think as electron is something I'd like to get into at some point
aset and aget remain the simplest way to access js properties. using goog.object/get and getValueByKeys and set do the same thing in a more verbose way
and no multi arity set in goog.object
We need to update Cuttle.
I'll try to get that this weekend or next week sometime.
goog.object/get
is not exactly the same — it adds an extra in
check, as its real purpose to exist is for the optional arg — i think it’s worth considering something like oget
in core which skips the extra check and signals intent clearly
agreed
another vote for oget @dnolen
I've always used aget
for JS object property access; is this not recommended?
I always liked that it compiled down to bracket notation using strings.
it’s possible that the compiler could optimize it in the absence of opt_val, at which point they are equivalent and oget
makes no sense
@dnolen just saying that parts of cljs core library already wrap goog functionality for convenience to cljs users
JS strings are always safe for the Google Closure Compiler in any compilation mode (I believe)
people keep asking for oget
and seem completely unaware that goog.object
is a thing which has more
goog.object.get
solves the problem, but it exists to solve a different problem — it’s a subtle point :)
it should clearly be named: get-javascript-object-property
😉
@nullptr: the real problem is the externs problem, and I’ve already said multiple times we’re working on that
dnolen: i hear you — we have tens of thousands of closure (js) code here, and there’s tons of foo[‘bar’] that’s not externed
all im thinking about is UX for new cljs users. having a dead simple function for a common interop reqt
it’s nice to have the option — if you just need access to one thing, externs can be a lot of extra overhead — again goog.object/get
works — just seems mildly hacky (as is aget
)
in the future property access on foreign values will work you won’t need all this stuff
sweet
likely there will need to be a corresponding ^js
if people are doing fancy higher order things
arbitrary json objects though
ux for new users is all im arguing for. simple multi-arity functions
it’s also the case that in watching what developers actually do w/ ClojureScript, they convert JS data immediately
few people want to manipulate JS data directly (except maybe arrays) because the tools are so weak compared to ClojureScript data
i mean, i guess this is a bigger discussion about convenience replaced by complete documentation
but i was working with people who just wanted to manipulate js options map as fast as possible
if they are and it’s that important then writing an extern is the right answer and takes no time at all
i never saw the code actually. there were just noticeable performance hits in creating cljs data structures and converting to js data. i think with clj->js
http://jsperf.com is a cesspool
right i get that
agreed
this was just a side point. the only thing i care about is not telling new users that to do such a simple interop thing by importing three functions from goog.object
if the talking about the awesomess of Google Closure isn’t the first thing covered something is not right w/ the docs
we will have to add that to cljs-api-docs in some capacity
the fact that new users never have to include an additional dep for basic functionality is something to celebrate not hide
@dnolen: as a newcomer, I heard the “Closure is awesome” part, but for some reason the “you are expected to know Closure’s standard lib the way you are expected to know Java’s when using CLJ” was not obvious to me
@arohner: if you rewatch the original ClojureScript announce that’s not what Rich Hickey said
at least we can all agree that aget
is terrible! i can’t tell you how long it took me to figure out that it was “the way” to do that before it wasn’t… exceedingly non-obvious
@dnolen: I’ve put two examples in a clean repo- https://github.com/mhuebert/def-in-ns/blob/master/src/cljs/foo/eval.cljs
evaling ‘(def x 1) with :ns set to ‘foo.other, an existing ns, compiles to “.x = 1”
evaling ‘(do (ns foo.totally-new) (def x 1)) compiles to "(function (){\ngoog.provide('foo.totally_new');\ngoog.require('cljs.core');\n\ncljs.user.x = 1;\n})()\n”
@mhuebert: neither of those example are actually valid though. you never created the namespace first