Fork me on GitHub
#clojurescript
<
2022-01-02
>
Chase15:01:33

I'm curious if a lot of production cljs uses the Google Closure library. I know the compiler uses it for optimizations but do folks also use the library and it's functions as well?

Chase15:01:45

The cljs book I'm reading is introducing it and it seems like something I would want to invest some good time into.

Chase15:01:58

I'm also creating an issue for clojure-lsp to get some documentation and autocompletion support for it but didn't want to waste their time if the community doesn't use the library much for some reason.

😀 1
borkdude15:01:58

Yeah, goog.object, goog.string, goog.function, etc are pretty good

1
p-himik16:01:32

Just in case - Google Closure Compiler is used for building and optimization. Google Closure library is used by CLJS itself, right in core.cljs. In fact, the CLJS part of cljs.core doesn't require anything but the goog stuff.

Chase16:01:44

Ahh, thanks for the clarification. I didn't know cljs itself was written using the library.

Chase16:01:47

That seems like a solid endorsement

valtteri16:01:45

Closure library contains tons of useful utils. Usually when I have an itch to pull in a library I first check if closure lib has something. And quite often it does. Upside is that “it’s already there” and the closure compiler can do advanced dead code elimination on all that.

valtteri16:01:32

Downside is the lack of usage examples

valtteri16:01:25

Grepping from one of my projects and found these in addition to borkdudes list: goog.array goog.color goog.crypt goog.labs.userAgent.browser goog.date.duration

Chase17:01:57

Yeah, so are you using their autogenerated api to explore then?

Chase17:01:21

usage examples would be quite helpful for sure

valtteri17:01:12

Yes that’s where I explore

valtteri17:01:56

And then try out in repl

misha23:01:49

greetings! given

ClojureScript 1.10.339
(pop [])
Can't pop empty vector

(pop ())
Can't pop empty list

(pop nil)
nil

(pop (seq ()))
nil
are there any objections to something like: ?
(extend-protocol IStack
      cljs.core/Cons
      (-peek [coll] (-first coll))
      (-pop  [coll] (-rest coll))

      cljs.core/IndexedSeq
      (-peek [coll] (-first coll))
      (-pop  [coll] (-rest coll))))
because:
(pop (new IndexedSeq [1 2] 0 nil))
No protocol method IStack.-pop defined for type cljs.core/IndexedSeq

(pop (cons 1 [2 3]))
No protocol method IStack.-pop defined for type cljs.core/Cons: (1 2 3)

(type (seq [1]))
cljs.core/IndexedSeq