planck

Planck ClojureScript REPL
johanatan 2016-06-08T01:58:44.000047Z

hi, is core.async supported on planck? I am getting namespace not found on cljs.core.async

mfikes 2016-06-08T02:01:33.000048Z

@johanatan: There is a port called Andare that works with bootstrap ClojureScript: https://github.com/mfikes/andare

mfikes 2016-06-08T02:02:58.000051Z

And post (which probably doesn’t offer more info): http://blog.fikesfarm.com/posts/2016-05-15-bootstrap-core-async.html

johanatan 2016-06-08T02:21:38.000052Z

@mfikes: how would I go about adding andare as a dependency?

johanatan 2016-06-08T02:22:12.000053Z

[I'm not using lein or boot or anything as it's a pretty simple script: in fact, here's the entire project: https://github.com/johanatan/screencap ]

mfikes 2016-06-08T02:24:03.000055Z

@johanatan: just download the JAR and use Planck's -c option with the JAR

johanatan 2016-06-08T02:24:15.000056Z

ahh awesome! thx!

johanatan 2016-06-08T02:25:08.000057Z

by download, you mean clone the src and build the .jar myself? or is it hosted somewhere?

johanatan 2016-06-08T02:25:13.000058Z

@mfikes: ^

mfikes 2016-06-08T02:29:12.000059Z

@johanatan: It is on Clojars… hmm is there a way to just download directly from there without any other tooling?

johanatan 2016-06-08T02:29:24.000060Z

oh, ok. i'll take a look

mfikes 2016-06-08T02:30:07.000061Z

If you have lein, you can make a small project.clj file specifying [andare "0.1.0”] just to get it

johanatan 2016-06-08T02:31:32.000062Z

ok that would work. thx!

johanatan 2016-06-08T02:32:17.000063Z

btw, is there an async version of sh ? i'm guessing not since there wouldn't really be any way to express that without andare

mfikes 2016-06-08T02:32:59.000064Z

@johanatan: Also, once you set up Planck to use it you’ll definitely be interested in Planck’s ability to cache with -K or -k /some/path/to/cache-dir, otherwise it can take 15 seconds or so to load the core.async namespaces

mfikes 2016-06-08T02:33:43.000065Z

No, none of the side libraries in Planck currently offer callback-based async support.

mfikes 2016-06-08T02:33:56.000066Z

(In fact, Andare was created after planck.http)

mfikes 2016-06-08T02:34:29.000067Z

But, you could imagine an async sh which called back with the results instead of returning them

johanatan 2016-06-08T02:34:38.000068Z

this is really nice btw. way better than using bash or python or what have you

👍 1
johanatan 2016-06-08T02:35:05.000069Z

[right]

mfikes 2016-06-08T02:35:09.000070Z

Yes. To be honest, I never can remember how to even build up strings in Bash. In ClojureScript we all know it is done with str 🙂

johanatan 2016-06-08T02:35:52.000071Z

haha yea

johanatan 2016-06-08T02:38:12.000072Z

case statements are a disaster in bash too

noonian 2016-06-08T02:38:26.000073Z

It really makes bash utilities way more useful to me since I never learned/internalized enough bash to do anything reasonably complex. Even something as trivial as iterating over the output lines from ls goes a long way. Especially when you can do that sort of thing to get some input data or what have you and then you’re back in Clojure.

mfikes 2016-06-08T02:39:51.000076Z

@johanatan: That’s a cool script. Yes, you should be able to use cljs.core.async/timeout to make your loop at the bottom sleep a bit before looping back around

mfikes 2016-06-08T02:43:12.000077Z

@noonian: Yes. One thing that shows just how far we have come with ClojureScript (and is close to your example) is the one-liner in https://gist.github.com/mfikes/9503aa2555aac1cafaf4 where Rich’s demo involved first AOT-compiling some code and then running it in Node

noonian 2016-06-08T02:46:57.000078Z

Quite amazing 🙂

johanatan 2016-06-08T06:06:44.000079Z

Ran into a little snag: having just a top-level go routine with infinite loop inside returns immediately (whether or not it is inside a main and -m is passed).

johanatan 2016-06-08T06:07:16.000080Z

When I do this from a regular Node.js ClojureScript project, it works as expected-- i.e., the program hangs while the go routine handles all processing rather than exiting immediately.

johanatan 2016-06-08T06:07:58.000081Z

@mfikes: ^

mfikes 2016-06-08T13:47:01.000083Z

@johanatan: Thanks! Fix pushed to master. Now code like the following will keep script processing “alive” until complete:

(go
  (loop [n 10]
    (when (pos? n)
      (<! (timeout 1000))
      (println n)
      (recur (dec n)))))
You can brew master (see http://planck-repl.org/setup.html) or let me know if you’d just like a binary you can download.

fasiha 2016-06-08T14:07:16.000084Z

Reading @johanatan's screencap—did not realize that planck included goog.*! I realized I have a very hazy idea about the differences between Planck/JavaScriptCore and "regular Cljs"/Google Closure

mfikes 2016-06-08T14:08:35.000085Z

@fasiha: Yeah, it is most of the Google Closure library

fasiha 2016-06-08T14:08:51.000086Z

Uh oh, most? 🙃

mfikes 2016-06-08T14:09:33.000087Z

If interested, here is how Planck includes stuff in its binary: http://blog.fikesfarm.com/posts/2015-07-27-island-repl.html

fasiha 2016-06-08T14:09:33.000088Z

I've had this feeling before (the surprise at finding out google closure was included), when I found out Planck included transit

fasiha 2016-06-08T14:10:43.000089Z

It's like Aladdin's cave

mfikes 2016-06-08T14:10:49.000090Z

Yes, Transit is kind-of exposed by accident. I should probably just commit to it being there and list it in http://planck-repl.org/dependencies.html

mfikes 2016-06-08T14:11:17.000091Z

I haven’t thought of a good way to cope with the fact that some of the things that Planck uses are simply available to Planck end-users.

mfikes 2016-06-08T14:12:20.000092Z

In terms of what “most” means wrt Google Closure, stuff is pulled in intentionally here: https://github.com/mfikes/planck/blob/master/planck-cljs/src/planck/bundle.cljs

fasiha 2016-06-08T14:14:59.000095Z

@johanatan: I don't think you have to do the stuff with st and eval in screencap's main.cljs just to read in the EDN config. This seems to be sufficient: (1) add [cljs.reader] to your requires, and (2) (def config (cljs.reader/read-string (slurp "./config.edn")))

mfikes 2016-06-08T14:17:17.000096Z

FWIW, there is also planck.core/eval and I’m working on adding read if it proves to be useful: https://github.com/mfikes/planck/commit/f1b8547bf2a42bc06d04e81d52048555ba223c60

johanatan 2016-06-08T16:48:11.000097Z

@fasiha: ahh, nice. Ya I tried to get reader to work but didn't stumble onto that particular incantation I suppose

johanatan 2016-06-08T16:49:12.000098Z

Doesn't help that everything returned from google when searching for 'ClojureScript reader' involves the 'reader conditional'

fasiha 2016-06-08T17:05:45.000099Z

The words 'magic' and 'Clojure' go together uncomfortably often 😕

fasiha 2016-06-08T17:06:44.000100Z

🔮

noonian 2016-06-08T17:07:37.000101Z

"Any sufficiently advanced technology is indistinguishable from magic.” 🙂

fasiha 2016-06-08T17:08:47.000102Z

@mfikes: I'm reading Clojuredocs for read and read-string side by side trying to understand the difference—it looks like the former consumes something not-stringy, a "push-back reader"?

mfikes 2016-06-08T17:13:40.000103Z

@fasiha: Yes. For example, the version of read I’ve been working on for Planck supports unread: https://github.com/mfikes/planck/blob/f1b8547bf2a42bc06d04e81d52048555ba223c60/planck-cljs/src/planck/core.cljs#L69-L72

fasiha 2016-06-08T17:18:00.000106Z

I'm guessing reading a Clojure expression from a stream, then unreading it (pushing it back) is useful even though I can't see how.

mfikes 2016-06-08T17:40:21.000107Z

@fasiha: I think it is just a concession that makes a reader easier to implement. For example, when reading 17(+ 2 3) the reader starts parsing the number at the beginning, but then it hits the ( and concludes that the number 17 has been fully parsed and simultaneously puts the ( back on the stream, unwinds the stack and continues, starting afresh with (+ 2 3) in the stream.

fasiha 2016-06-08T17:40:55.000108Z

@mfikes, OH that is useful, got it! Thanks for explaining