Fork me on GitHub
#clojurescript
<
2016-06-09
>
stewsquared02:06:02

I'm sure this gets brought up often enough someone could point me to a few good links: I have a colleague who's vehemently opposed to transpilers because they add a layer of complexity to the execution model. Not that he prefers JS for performance first, but that he wants to know what his program is executing and be able to optimize it if needed. This is a common sentiment, right? What are some of the best cljs-specific blog posts addressing this?

dnolen04:06:11

@stewsquared: ClojureScript is designed to reach whatever perf characteristics JS has if that’s what you want

dnolen04:06:55

not clear what else is needed beyond that

fasiha04:06:39

This works: (.findAll coll #js {"e" 2} #js {"e" 3}) where coll is a JS object with a method function findAll. I'm trying to use apply because I have the two maps in a ClojureScript vector but I can't quite get the incantation right. I understand there's some hijinks when the JS method function uses this, but it's not clear to me what the apply call would look like assuming no this problems were there. (apply .findAll coll [...])?

fasiha04:06:09

The function findAll (not mine, from a library) uses arguments and its code appears to include this. Does this use of this in the body imply I cannot use a straightforward apply (whatever that would look like)?

fasiha05:06:00

Got it. (.apply (.-findAll coll) coll #js [ #js {"e" 2} #js {"e" 3}]) works whereas what I think would be an equivalent, (`(apply (.-findAll coll) #js [ #js {"e" 2} #js {"e" 3}]) ; :(`) doesn't work. So I'm guessing findAll uses this and I can't use ClojureScript's apply. No worries

stewsquared07:06:20

@dnolen: I suppose he's worried about not being able to optimize past clojurescript's base overhead. Admittedly, his concerns seem really vague.

meowy07:06:45

@stewsquared: By the same logic, writing C is adding a layer of complexity on top of pure machine code. You don't know what your program is executing (because compilers do some wacky stuff to your code) and it's prety hard to optimize it, too!

meowy07:06:06

Premature optimization's never a good idea. It's fine to roll with ClojureScript, and it does turn out to be not performant enough, you can always refactor your ClojureScript code or, if all else fails, just embed plain old JavaScript.

wilkerlucio11:06:10

I'm trying to use the function decodeStringToUint8Array from http://google.github.io/closure-library/api/namespace_goog_crypt_base64.html, but it doesn't seem to be available, what can I do to have it available?

anmonteiro12:06:00

@wilkerlucio: looks like it is unavailable in clojurescript because it was added in a newer version of the closure library

wilkerlucio12:06:40

humm, ok, makes sense

wilkerlucio12:06:52

how we go about updating it? can I expect it to be updated in a near future version of clojurescript?

anmonteiro12:06:41

@wilkerlucio: no idea, maybe better to ask in #C07UQ678E

dnolen12:06:50

@wilkerlucio: we need to cut a new release of the closure library that we build

wilkerlucio13:06:24

@dnolen: can we do that for the next release? can I help somehow?

dnolen13:06:54

@wilkerlucio: in this case unfortuantely not, I just have to kick off a build, will do this tomorrow

dnolen13:06:44

@wilkerlucio: you can file a ticket in JIRA and set the fix version to Next

wilkerlucio13:06:57

@dnolen: filed http://dev.clojure.org/jira/browse/CLJS-1675, I just didn't figured how to change the fix version

dnolen13:06:27

@wilkerlucio: you submitted a CA right?

wilkerlucio13:06:55

@dnolen: not yet, can you send me one please?

dnolen13:06:11

@wilkerlucio: you need to do the official one 🙂

wilkerlucio13:06:28

where can I find it to sign?

dnolen13:06:05

you can do it online, soon as you send that let me know and I will bump your JIRA privileges so you can always do what you need in JIRA

wilkerlucio13:06:54

@dnolen: ok, submitted 🙂

dnolen13:06:36

@wilkerlucio: you should be able to edit the ticket now

wilkerlucio13:06:54

ok, just did, should I assign the ticket to you?

cldwalker14:06:14

Morning. Anyone now why find-ns-obj works in advanced mode for user-defined namespaces but not for cljs.core?

dnolen15:06:02

@cldwalker: none of thing at the bottom of cljs.core is intended for anything except bootstrapped

dnolen15:06:11

advanced compilation and bootstrapped do not mix

dnolen15:06:45

happy to take a docstrings patch that mark those things as bootstrap only

cldwalker15:06:57

@dnolen: Good to know. Thanks!

darwin16:06:01

it is possible to somehow get docstrings dynamically during runtime? I don’t see them emitted in the generated js sources, so I doubt it.

darwin16:06:53

I mean in dev mode, with optimizations :none

anmonteiro16:06:38

@darwin: I suppose this is not “dynamically” ?

cljs.user> (defn a "docstring here" [] 42)
#'cljs.user/a
cljs.user> (-> #'a meta :doc)
"docstring here"

darwin16:06:54

@anmonteiro: thanks, my situation is, that someone gives me “a” as a string dynamically

anmonteiro16:06:01

I doubt that’s possible because of the static nature of vars in CLJS

anmonteiro16:06:10

happy to be proven wrong though 🙂

danielcompton17:06:27

SEVERE: ERROR - Duplicate input: file:/C:/Users/Us/.m2/repository/org/clojure/google-closure-library/0.0-20151016-61277aea/google-closure-library-0.0-20151016-61277aea.jar!/goog/base.js

Jun 09, 2016 9:06:16 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 1 error(s), 0 warning(s)
ERROR: JSC_DUPLICATE_INPUT. Duplicate input: file:/C:/Users/Us/.m2/repository/org/clojure/google-closure-library/0.0-20151016-61277aea/google-closure-library-0.0-20151016-61277aea.jar!/goog/base.js at (unknown source) line (unknown line) : (unknown column)

danielcompton17:06:40

Has anyone seen that error and know what causes it? Happens on OS X too.

dnolen17:06:24

somehow you’re loading that file twice

dnolen17:06:44

make sure you don’t somehow have your output directory on the classpath or something like that

dnolen17:06:09

@darwin: not possible

dnolen17:06:24

except in bootstrapped

danielcompton21:06:10

(ns hara.common.checks
  #?(:cljs (:require [goog])))

;; ## Type Predicates
;;
;; Adds additional type predicates that are not in clojure.core

(defn boolean?
  "Returns `true` if `x` is of type `java.lang.Boolean`.

   (boolean? true)   => true
   (boolean? false)  => true"
  {:added "2.0"}
  [x]
  #?(:clj  (instance? java.lang.Boolean x)
     :cljs (goog/isBoolean x)))
I’ve tracked it down to this code

danielcompton21:06:09

am I requiring goog in the wrong way here?

darwin22:06:42

@danielcompton: do not require goog, it gets required automatically

darwin22:06:08

just today I hit similar issue, requiring goog is side-effecting and wipes out goog’s internal data structures

danielcompton22:06:57

so just call goog/isBoolean?

darwin22:06:18

not sure, you can always fall back to js interop

darwin22:06:05

take my words with grain of salt, I didn’t have time to investigate it further, but in my situation, this line was the first major issue: https://github.com/google/closure-library/blob/master/closure/goog/base.js#L840

darwin22:06:28

second inclusion of goog, deleted previously initialized goog.dependencies_

danielcompton22:06:04

Looks like goog is imported by default