Fork me on GitHub
#clojurescript
<
2016-12-16
>
darwin00:12:57

I always thought a straightforward reimplementation of core.async to async/await would not be possible (await returns one value, but channel is continuous stream of values). But if there ever was any kind of rewrite plan, I would like to assist. I’d like the new design to consider adding some dev-time debugging capabilities: https://github.com/binaryage/dirac/issues/36

sova-soars-the-sora01:12:46

Yay clojurescript!

cdine05:12:15

why can't (var some-symbol) work in cljs ?

thheller10:12:48

@cdine var is incompatible with google closure :advanced optimizations

mitchelkuijpers11:12:42

@ashnur what really helps with keeping your parens balanced in spacemacs is using lisp-mode: http://spacemacs.org/doc/DOCUMENTATION.html#lisp-key-bindings

Aron11:12:09

thanks, will try

Aron11:12:52

how about the code i shared? yesterday i was ignored again all day, i am starting to think it depends on the weather. on rainy days i am ignored, on clear days i am not 😄

Aron12:12:51

or maybe its the other way around? :))

jrychter13:12:28

Hmm. I'm looking at the output of :advanced compilation and I see many of my string constants are duplicated in the resulting code (e.g. they appear twice in JavaScript). I don't think this is good.

rauh13:12:14

@jrychter That's on purpose, actually google closure used to assign them to variables and reference them but then went the other way, it turns out there is little savings after gzip

jrychter13:12:57

@rauh: oh! Good to know. And now I feel ashamed for not having checked the FAQ first.

rauh13:12:45

Yeah I assign global variable R to React.createElement only to realized that I saved 400(!) bytes after gzip 😞

jrychter13:12:20

I do a sanity check from time to time, as my app grows. I am at 1.94MB uncompressed, 487kB compressed right now.

rauh13:12:30

@jrychter I automatically gzip the data after an advanced compile. See :watch-fn compiler option that gets invoked after cljs compiler is done

jrychter14:12:27

I will take this occasion to thank everyone for the mindblowing awesomeness of ClojureScript. I can write apps with isomorphic rendering that load and work blazingly fast, and easily maintain complex functionality because Clojure and ClojureScript do not require a lot of code. And the best part — every once in a while I stumble upon an article with "X ways to make sure your React app is fast", and then discover that none of the advice applies to me: all the hard work has already been done for me. So, thank you!

dbsgtk14:12:12

I'd like to restrict the input of a text field in a reagent form to a subset of the alphabet. (one letter abbreviations for amino acids, for the curious). i'm sure this is simple, but i'm at a loss. Does anyone here have any suggestions?

pesterhazy14:12:02

@dbsgtk in a controlled component you can just refuse updates that include disallowed characters, can't you?

dbsgtk14:12:09

@pesterhazy I'm sure that's the case. 🙂 My embarrassment should be evident; this is my first reagent app.

pesterhazy14:12:19

check the example here: https://reagent-project.github.io/ (search for on-change)

pesterhazy14:12:54

if you choose not to reset! the atom, the input field will refuse the keystroke

nha14:12:53

@jrychter I collect my boot tasks related to minification there: https://github.com/nha/boot-uglify

dbsgtk14:12:13

@pesterhazy thanks. I was using reagent-forms, but maybe I won't for that component.

pesterhazy14:12:22

@dbsgtk may be a good idea to start with simple reagent so you know what's the fault of specific libraries

dbsgtk14:12:50

good point.

Aron14:12:40

is there a way for (pprint) to show the original location of where it was used?

danielgrosse15:12:06

I had to made a change to the goog.dom.fullscreen.js file, and as suggested by @thheller I put it into my cljs sourcepath. But cljsbuild don't compile it or copy it to the correct folder. How could I use this file, so it gets correctly resolved by goog.require?

thheller15:12:58

@danielgrosse it needs to be on the java classpath. if you have a seperate src/cljs or so for cljsbuild that won't work

thheller15:12:13

it must be on the :source-paths of leiningen

thheller15:12:01

but you probably won't get hot-code reloading for it from cljsbuild/figwheel

thheller15:12:16

try running a CLJ repl and do

thheller15:12:34

(require '[ :as io]) (io/resource "goog/dom/fullscreen.js")

thheller15:12:10

that should give you your file not the file from the jar

danielgrosse15:12:23

I put it into the directory src/clj/goog/dom/fullscreen.js and the repl returns the correct file. But cljsbuild don't copy it into the goog/dom directory

thheller15:12:36

never at all?

thheller15:12:17

I might actually be wrong about cljsbuild then, I know this works in shadow-build cause I have done that several times

thheller15:12:39

try deleting the target file if it is there already

thheller15:12:11

I assume it is the cache so try cleaning things first

Aron15:12:32

so, i realized i probably shouldn't be using vectors because i have to check if there is a value in it and it seems they are not very good at this

danielgrosse15:12:19

@thheller I will try it later.

Aron15:12:21

is there a beginners channel specifically for clojurescript? i have not seen in the list but maybe it's not public or something

borkdude15:12:51

Would like to have some feedback. I need to filter and return an array in ClojureScript. Is this good enough? (to-array (filter #(…) the-array)

pesterhazy15:12:45

if it works it works!

borkdude15:12:21

I could also just do (.filter the-array #(…))

pesterhazy15:12:44

did you mean into-array?

borkdude15:12:06

to-array worked

borkdude15:12:32

I’ll go for .filter

borkdude15:12:42

We don’t have to support old browsers

borkdude16:12:25

and it seems to be well supported now: http://caniuse.com/#feat=es5

chrisoakman16:12:07

@borkdude By using (filter #(...) the-array) instead of the JS interop .filter your code will be more portable to CLJC. Not sure if that matters to you or not.

borkdude16:12:22

Not here, this is code for a C3 chart

chrisoakman16:12:31

In general I try to use the core library as much as possible over JS interop.

borkdude16:12:24

I prefer that too, but there are exceptions 🙂

Aron16:12:48

1.5 years ago i had to use ext.js that also has .filter, but no reduce http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.Array

Aron16:12:21

couldn't convince my colleagues to use it though. they preferred the usual multiple nested levels of fors and ifs

borkdude17:12:20

They seem to do the same thing. Why not call the one implementation?

darwin17:12:33

I think it is just for some historical reasons. They should do the same thing I believe. to-array it closer to bare-metal and generates more straightforward javascript code.

darwin17:12:17

ok, good point, I take my words back, I thought reduce will add chunking, like doseq does

borkdude17:12:49

into-array doesn’t seem to produce seq-using code but an indexed-based loop

borkdude17:12:08

sorry, that was just the varargs handling

borkdude17:12:05

and then the arity2 function produces code that calls reduce.

borkdude17:12:43

@darwin so you were right after all 🙂

darwin17:12:27

btw. to play with well with dead code elimination I had to implement another version: https://github.com/binaryage/cljs-oops/blob/d530a3cdf8cbab39bd2699c36caded4414224c50/src/lib/oops/helpers.cljs#L26 but unfortunately I don’t remember the details… the problem was related to protocols

borkdude17:12:07

@darwin Cool library btw!

darwin17:12:19

or maybe this is not the case I vaguely remember, once I had to drop protocol dynamic checks to get proper DCE

darwin17:12:51

@borkdude I skimmed the cljs.core sources just briefly and it seems reduce does not do chunking, so it should generate similar code, maybe with some extra varargs handling

darwin17:12:06

but from your screenshot it looks like into-array is actually more efficient code, cljs.core.first and cljs.core.next do protocol checks

darwin17:12:28

ok, I stop here, don’t know enough about this 🙂

samueldev18:12:42

I'm working on porting a clj lib to cljs and it uses multimethods with special characters on some methods

samueldev18:12:05

eg

(defmethod some-multimethod := (...))

samueldev18:12:17

the compiler seems unhappy with this https://puu.sh/sRHsS/6c43382081.png

angusiguess18:12:13

^ Just to add to this

angusiguess18:12:33

It seems particularly sad when we expand a macro that emits a defmethod

samueldev18:12:41

(Sidenote @angusiguess : get nick in here 😛 )

angusiguess18:12:17

(defmacro unary
  [type f & [e-parse]]
  (let [e-parse (or e-parse identity)]
    `(defmethod expression ~type [[_# exp1# & extra#]]
       (if (seq extra#)
         (throw (parse-exception "%s only accepts 1 argument. Provided: %s" (name ~type) (vec (cons exp1# extra#))))
         (if exp1#
           (fn [x#]
             (~f (~e-parse ((expression exp1#) x#))))
           (throw (parse-exception "%s requires 1 argument. Provided: %s" (name ~type) exp1#)))))))

dnolen18:12:08

@samueldev doesn’t seem necessarily to have anything to do with the compiler at this point

dnolen18:12:51

@samueldev technically that’s not even a valid keyword far as I can tell

dnolen19:12:02

so the fact that it works in Clojure is just happenstance

samueldev19:12:45

one alternative I had suggested (did nick try it @angusiguess?) is simply to write plain-english versions of those multimethod identifiers with no special characters

samueldev19:12:04

also: did not know that those aren't valid keywords, good to know

angusiguess19:12:10

(unary :not not) isn't compiling either?

angusiguess19:12:18

It may just be that we're not requiring the macros properly.

samueldev19:12:34

I know support very recently changed for that

dnolen19:12:37

nothing really fundamentally changed, really sugar and a bit more smarts

ghosttoaster20:12:27

Beginner question: I'm trying to get into clojurescript development, am I confused in thinking that neither boot-cljs nor lein-cljsbuild support clojurescript > 1.7.2? And therefore neither supports clojure.spec? If so are clojurescript developers running custom scripts to compile their code? Not doing spec? Or am I missing something? Thanks for your help.

tankthinks20:12:48

has anyone done om/reagent with webcomponents like https://x-tag.github.io/?

dnolen20:12:56

@cdimara ClojureScript is just a library, so I think you may have come to the wrong conclusion here

ghosttoaster20:12:19

Okay. I saw Clojurescript is listed as an out of date dependency on the boot-cljs homepage but that must not mean what I think it means: https://jarkeeper.com/adzerk/boot-cljs

stbgz22:12:19

hey all do we have when-let* in cljs?

sova-soars-the-sora23:12:42

Ah I'm just getting into om + cljs and, coming from a brief clojure+ring background, I just gotta say thanks!!!