Fork me on GitHub
#clojurescript
<
2017-01-22
>
Jon10:01:39

Any numbers to see how many people actually using ClojureScript? I saw questions in the comments on HN on "most-used".

ejelome12:01:25

what do you use to inspect data structures in clojurescript? (like console.dir() for JS or dir() for Python)

ejelome12:01:35

oh, found it, via .-map, e.g. (.then #(prn (.-map (.-headers %))))

andrewboltachev14:01:20

Hi. What's the fastest way to obtain AST for a single *.cljs file?

andrewboltachev14:01:14

however clojure/tools.reader is telling me ExceptionInfo No reader function for tag js clojure.core/ex-info (core.clj:4617)

dnolen14:01:27

@jiyinyiyong I’m not aware of any hard numbers, but if you estimate the number of Clojure users, the yearly surveys consistently show that > 60% use ClojureScript as well

andrewboltachev14:01:37

And it turns e.g. "(ns foo)" into '(ns foo) IIRC it's possible to see another form, consistng of a lot of maps, sth. like {:type :ns, :name 'foo}

andrewboltachev14:01:39

(or probably {:type :symbol, :name "foo", :namespace nil})

dnolen14:01:47

@jiyinyiyong I don’t think the claim is really that far off the mark - ClojureScript is the most mature compile to JS FP solution I’m aware of

yassin_02:01:58

dnolen: Bucklescript (ocaml) does a good job too:)

dominicm14:01:30

@andrewboltachev rewrite-cljs has something like that.

andrewboltachev14:01:47

@dominicm thanks, will check it out

zilvinasu17:01:34

Hey, what would be an easy way to check investigate CLJS compiler to see the output before Google Closure and after ?

darwin18:01:47

@zilvinasu if you don’t strictly require an easy way, I think you can patch this line and spit the files somewhere: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1261

zilvinasu18:01:50

@darwin kinda wondering, basically taking compiler jar feeding it some source with optimizations one, isn’t that the actual result of ClojureScript compiler since there were no optimizations set by Google Closure ?

darwin18:01:17

Chances are you are right. But I don’t know exactly.

dnolen18:01:02

@zilvinasu :none is almost what’s generated before Closure sees it

dnolen18:01:30

@zilvinasu however we generate slightly different code for :advanced

dnolen18:01:03

:advanced implies :static-fns true :optimize-constants true

zilvinasu18:01:35

thanks! 🙂

dnolen18:01:51

@zilvinasu so just use :none with those additional options

futuro21:01:38

I'm working on creating a host agnostic I/O library for ClojureScript, and the two current major approaches I'm thinking about involve using either dynamically bound fn vars, like with *print-fn* in cljs.core, and/or to use protocols with defined methods.

futuro21:01:39

Ideally I'd like the heavy lifting to be managed by the host environments, as files/sockets/etc are all host dependent. I'm curious if anyone else has attempted something like this, or has advice on gotchas or previous work.

futuro21:01:11

To clarify that, it seems like it would make the most sense to have the host systems implement the actual logic to, say, read and write a file, and have a way to read from and write to that file without the library knowing anything about the specifics for each host.

dnolen21:01:43

@futuro yes it’s been discussed before, the primary problem is that JS means the I/O interface has to be async

dnolen21:01:03

that’s not necessarily idiomatic for JVM usage

pat21:01:02

I wrote https://github.com/pkpkpk/cljs-node-io and landed on prefixing async fns, ie 'aslurp', and returning a channel, and leaving streams separate

pat21:01:16

On nodejs, many calls to libuv are called after js/process.nextTick() to allow event cb setup. So things like syscalls to create fd streams are fundamentally asynchronous. In contrast on the JVM fd's can be opened and streamed synchronously. You can mimic this on node with readFileSync but it consumes memory & does not use a pipe'able stream, so it has different semantics

pat21:01:26

I think @mfikes has work cooking with this, but I do not know if planck has async calls yet

pat21:01:12

we should start a kickstarter for him to plugin libuv 🙂

mfikes21:01:27

Planck 2 has an async version of sh

futuro22:01:28

@dnolen My current goal is to abstract over the various host implementations for IO with self-hosted CLJS, but async/sync is a useful lens to think of host agnostic IO through.

futuro22:01:48

@pat Thank you, I'll take a look at that!

dnolen22:01:22

@futuro I just meant that because of the philosophical divide I just don’t know how useful it would be to many people

futuro22:01:07

@mfikes I definitely need to give the Planck code a more thorough read through

futuro22:01:00

@dnolen Specifically a JVM/JSVM agnostic IO library, or even an IO library that's agnostic over the various JS hosts?

rparra22:01:17

I’m starting to play with cljs using chestnut. I have 2 (probably stupid) questions so far: 1) Should adding [cljsjs/react-bootstrap “0.30.7-0”] to my project.clj dependencies handle adding CSS to my index.html? It seems like it doesn’t or I’m doing something wrong. 2) After adding the dependency I require it in my main file, but get a compilation error from Figwheel. It is only solved after restarting the REPL. Is this expected behavior or is there a command to refresh dependencies from the REPL? If this channel is not appropriate for these questions, please let me know. Otherwise, thanks in advance!

dnolen22:01:52

@futuro I mean all those things sound like tough sells to me

futuro23:01:19

:thinking_face:

pat23:01:13

@rparra 1) no 2) leiningen grabs missing deps at jvm startup, so if you add a dep you must restart the process

dnolen23:01:39

@futuro if your idea is more narrow like - common stuff just between Node.js / JVM then that sounds useful

dnolen23:01:49

my sense so far is that the desire for something like that is surprisingly modest

futuro23:01:08

It's actually really focused on abstracting over JS VM I/O so creating a self-hosted compatible nREPL is simpler, but I wanted to start with the widest gaze on project goals. Realistically I would avoid thinking about the JVM, as there's already libraries for that.

dnolen23:01:52

so with the latest changes in master, ClojureScript is a pretty sweet ES6 compiler 🙂

dnolen23:01:16

it turns out that how Node.js and the browsers have evolved ES6 support makes the outcome even better than I could have imagined

dnolen23:01:35

the Closure pass just rewrites to a Closure module - so it’s very fast

dnolen23:01:49

all the ES6 stuff is untouched - Node & the browser just make it work

dnolen23:01:08

at the same time when you go to advanced compilation - Closure can lower ES6 to ES3 and apply all the fancy stuff like DCE

dnolen23:01:30

it also means you can decide to write an ES6 module for open source reasons but with the expectation that you will consume from ClojureScript and reap all the benefits w/ fewer downsides

dnolen23:01:49

for example Transit.js was done this way - but it’s unidiomatic for most JS devs (Google Closure namespaces)

dnolen23:01:01

not so w/ the enhanced ES6 support

dnolen23:01:41

also provides a potentially interesting story for onboarding people to ClojureScript - we’ll see if that pans out

dnolen23:01:59

but in anycase having designers write ES6 / JSX modules is now totally practical

dnolen23:01:35

the last piece of the puzzle is Closure landing Node resolution which is imminent

richiardiandrea23:01:50

@dnolen with this and the hints for externs, do you think cljsjs packaging will be needed less and less often?

richiardiandrea23:01:18

Oh that's great, I consider this a very good thing

richiardiandrea23:01:23

it is not of course about cljsjs per se, but about generating externs mainly, that master seems to make waaay more easier

lockdownz23:01:25

dnolen by node resolution you mean node module support?

pat23:01:39

curious to see if inference stuff has impact on :adv payload size

dnolen23:01:47

@lockdown yes, you will just be able to supply your .node_modules directory to ClojureScript and it will just work

dnolen23:01:04

however the caveat here is always going to be advanced compilation

dnolen23:01:36

so it’s not like it means you can use JS libs willy-nilly for production

dnolen23:01:03

but the friction around trying random JS libs will be gone

dnolen23:01:32

@pat it won’t since we only produce them if you didn’t supply it

dnolen23:01:52

zero impact for advanced that you wouldn’t already have

dnolen23:01:17

and now you have warnings about stuff that isn’t going to work - instead of futzing with :pseudo-names

dnolen23:01:43

the warnings features + return type propagation also makes writing externs way more fun

dnolen23:01:55

the compiler guides you to do right thing

pat23:01:17

very cool

lockdownz23:01:44

what module systems does closure currently supports?

pat23:01:06

hiring designers to do their normal thing shouldnt be underestimated 😉

dnolen23:01:07

I’ll be working on externs guide around the new feature for the website

dnolen23:01:23

this will address one of the biggest pain points I think for beginners

dnolen23:01:46

@lockdownz AMD, CommonJS, ES6, and Closure require/provide

ag23:01:50

@dnolen Yeah, I have the dependency already, seems it’s missing some config values, thanks, I’ll play with it

dnolen23:01:51

@ag you just need to inject it

dnolen23:01:26

in your compiler config :preloads '[devtools.preload]

darwin23:01:19

+ you need to use recent clojurescript, :preloads don’t work in older clojurescripts (silently)