[ClojureScript] Scripting with Clojure(Script) : Plain Clojure ? Node.js ? Boot ? Planck ? Pixie ?

2015-08-25 Thread Khalid Jebbari
Hi every one,

Just starting this thread to gather feedback from people who used CLJ(S) to 
script and replace, you know, shell/Python/Ruby/Whatever. Pretty sure it's a 
dream to code AND script with CLJ(S). I know that it's possible to do it with 
CLJS backed by Node.js/io.js, with Boot somehow, with plain Clojure, with Mike 
Fikes' Planck (only OSX for now though), and Timothy Baldridge's Pixie which is 
not Clojure but quite close.

If you use any or several, please post your feeback here. It's a nice time to 
CLJ(S) all the things :)

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] [ANN] Planck 1.6

2015-08-25 Thread mikefikes18
Hi gvim,

ClojureScript libraries are generally packaged and made available as JAR files. 
Also, the file names and paths used in ClojureScript follow classpath 
conventions.

Planck is just supporting the existing ClojureScript ecosystem. It's not trying 
to reinvent or innovate in this area.

- Mike

 On Aug 25, 2015, at 9:49 AM, gvim gvi...@gmail.com wrote:
 
 The pace of development is amazing, Mike.
 
 I'm a bit confused about Planck accessing JAR files. I thought it was all 
 Objective C + Javascript Core?
 
 gvim
 
 
 
 On 24/08/2015 20:06, Mike Fikes wrote:
 http://planck.fikesfarm.com
 
 New Features
 
  * Support JAR deps
  * Support |-c| / |--classpath| for specifying source directories and
JAR deps
  * Support for OS X 10.8 Mountain Lion
  * Ship with bundled |cljs.pprint| and |cljs.test|
  * Support |source| REPL special
  * Support |import| REPL special
  * Support for |planck.core/*command-line-args*|
  * Support |:encoding| option for file I/O
  * Support for byte-oriented streams (|planck.io/input-stream| and
|planck.io/output-stream|)
  * |doc| output for macros
  * |doc| and tab completion for special forms
 
 Changes
 
  * Read pre-compiled namespaces and analysis metadata for faster loading
  * Deprecate |-s| / |--src| in favor of using |-c| / |--classpath|
  * Revise |planck.core/file-seq| to be lazy (in terms of |tree-seq|)
 
 Fixes
 
  * Capture stderr for |planck.shell/sh|
  * Fix a glitch in brace highlighting when vertically aligned
  * Properly exit if |planck.core/exit| is called with |0|
  * Don't block on I/O in |planck.core/shell/sh|
  * Properly decode UTF-8 from stdin
 
 
 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google
 Groups ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojurescript+unsubscr...@googlegroups.com
 mailto:clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com
 mailto:clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.
 
 -- 
 Note that posts from new members are moderated - please be patient with your 
 first post.
 --- You received this message because you are subscribed to the Google Groups 
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: Clojurescript async not yeilding for CPU intensive work

2015-08-25 Thread Daniel Kersten
The browser does not support threads so neither can core.async.

To expand on that, core.async uses cooperative multitasking, which means
you have to give control back every so often so it can schedule other go
blocks to be run. Calls like ! will do this while they block (which is why
timeout works).

On Tue, 25 Aug 2015 at 09:23 Thomas Heller th.hel...@gmail.com wrote:

 This has nothing to do with core.async or the go macro. If you block the
 CPU you will block the UI. The browser does not support threads so neither
 can core.async.

 What the timeout achieves is that you give some control back to the
 browser so instead of 1sec blocking you get 5x200ms blocking. Still far
 from 60fps but better than 0.

 If you want to do CPU intensive work without blocking the UI you'll need
 to use one or more WebWorkers. You could layer core.async on top of that to
 communicate between the Workers and the UI but core.async itself does
 nothing in that regard.

 WebWorkers are pretty easy to get going but carry their own set of
 drawbacks so it is very dependent on your use case whether they make sense
 or not.

 HTH,
 /thomas



 On Monday, August 24, 2015 at 5:33:48 PM UTC+2, Timothy Pratley wrote:
  I have an issue where work inside a 'go block' is blocking my UI.
  Inserting a (! (timeout 1)) 'fixes' it.
 
  ** Is there a more idiomatic way? **
 
  Here is a cut down version built from a fresh template:
  If you run this code, you don't see the thinking deeply countdown, and
 you cannot click the other button.
 
  If you uncomment the timeout 1, it works better.
 
 
 
  (defn hello-world []
[:div
 [:h1 (:text @app-state)]
 [:button
  {:on-click
   (fn [e]
 (swap! app-state assoc :thinking true :thinking-deeply 5)
 (go
   (while (pos? (:thinking-deeply @app-state))
 ;(! (timeout 2000))
 (apply * (rest (range 1000)))
 ;(! (timeout 1))
 (swap! app-state update :thinking-deeply dec))
   (swap! app-state dissoc :thinking :thinking-deeply)))}
  The button!]
 (when (:thinking-deeply @app-state)
   [:h2 Thinking deeply  (:thinking-deeply @app-state)])
 (when (:thinking @app-state)
   [:h2 Thinking])
 [:button The other button]])
 
  Full source code is attached
 
 
  Regards,
  Timothy

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] Re: Clojurescript async not yeilding for CPU intensive work

2015-08-25 Thread Thomas Heller
This has nothing to do with core.async or the go macro. If you block the CPU 
you will block the UI. The browser does not support threads so neither can 
core.async.

What the timeout achieves is that you give some control back to the browser so 
instead of 1sec blocking you get 5x200ms blocking. Still far from 60fps but 
better than 0.

If you want to do CPU intensive work without blocking the UI you'll need to use 
one or more WebWorkers. You could layer core.async on top of that to 
communicate between the Workers and the UI but core.async itself does nothing 
in that regard.

WebWorkers are pretty easy to get going but carry their own set of drawbacks so 
it is very dependent on your use case whether they make sense or not.

HTH,
/thomas



On Monday, August 24, 2015 at 5:33:48 PM UTC+2, Timothy Pratley wrote:
 I have an issue where work inside a 'go block' is blocking my UI.
 Inserting a (! (timeout 1)) 'fixes' it.
 
 ** Is there a more idiomatic way? **
 
 Here is a cut down version built from a fresh template:
 If you run this code, you don't see the thinking deeply countdown, and you 
 cannot click the other button.
 
 If you uncomment the timeout 1, it works better.
 
 
 
 (defn hello-world []
   [:div
[:h1 (:text @app-state)]
[:button
 {:on-click
  (fn [e]
(swap! app-state assoc :thinking true :thinking-deeply 5)
(go
  (while (pos? (:thinking-deeply @app-state))
;(! (timeout 2000))
(apply * (rest (range 1000)))
;(! (timeout 1))
(swap! app-state update :thinking-deeply dec))
  (swap! app-state dissoc :thinking :thinking-deeply)))}
 The button!]
(when (:thinking-deeply @app-state)
  [:h2 Thinking deeply  (:thinking-deeply @app-state)])
(when (:thinking @app-state)
  [:h2 Thinking])
[:button The other button]])
 
 Full source code is attached
 
 
 Regards,
 Timothy

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: Clojurescript async not yeilding for CPU intensive work

2015-08-25 Thread Thomas Heller
On Tuesday, August 25, 2015 at 10:59:53 AM UTC+2, Daniel Kersten wrote:
 The browser does not support threads so neither can core.async.
 
 
 To expand on that, core.async uses cooperative multitasking, which means you 
 have to give control back every so often so it can schedule other go blocks 
 to be run. Calls like ! will do this while they block (which is why timeout 
 works).
 

While that is correct let me emphasize that timeout is not a solution!

Do you always know how long task X will run or whether you are going to need to 
chunk it? Is it even possible to split up? A task that may complete in 10ms 
on your machine might take 100ms on another one or even 500ms on yours if the 
computer is doing something else.

If you need to do CPU intensive work in the browser use a WebWorker. It is 
their purpose. While not perfect it is far better than trying to be 
cooperative in your code.

My 2 cents,
/thomas



-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: Clojurescript async not yeilding for CPU intensive work

2015-08-25 Thread Mike Thompson
On Tuesday, August 25, 2015 at 7:45:28 PM UTC+10, Thomas Heller wrote:
 On Tuesday, August 25, 2015 at 10:59:53 AM UTC+2, Daniel Kersten wrote:
  The browser does not support threads so neither can core.async.
  
  
  To expand on that, core.async uses cooperative multitasking, which means 
  you have to give control back every so often so it can schedule other go 
  blocks to be run. Calls like ! will do this while they block (which is why 
  timeout works).
  
 
 While that is correct let me emphasize that timeout is not a solution!
 
 Do you always know how long task X will run or whether you are going to need 
 to chunk it? Is it even possible to split up? A task that may complete in 
 10ms on your machine might take 100ms on another one or even 500ms on yours 
 if the computer is doing something else.
 
 If you need to do CPU intensive work in the browser use a WebWorker. It is 
 their purpose. While not perfect it is far better than trying to be 
 cooperative in your code.
 
 My 2 cents,
 /thomas


You have a problem, and you decide to solve it via webworkers.

Later you'll WISH you'd chosen regexs instead :-)

--
Mike

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] [ANN] Planck 1.6

2015-08-25 Thread gvim

The pace of development is amazing, Mike.

I'm a bit confused about Planck accessing JAR files. I thought it was 
all Objective C + Javascript Core?


gvim



On 24/08/2015 20:06, Mike Fikes wrote:

http://planck.fikesfarm.com

New Features

  * Support JAR deps
  * Support |-c| / |--classpath| for specifying source directories and
JAR deps
  * Support for OS X 10.8 Mountain Lion
  * Ship with bundled |cljs.pprint| and |cljs.test|
  * Support |source| REPL special
  * Support |import| REPL special
  * Support for |planck.core/*command-line-args*|
  * Support |:encoding| option for file I/O
  * Support for byte-oriented streams (|planck.io/input-stream| and
|planck.io/output-stream|)
  * |doc| output for macros
  * |doc| and tab completion for special forms

Changes

  * Read pre-compiled namespaces and analysis metadata for faster loading
  * Deprecate |-s| / |--src| in favor of using |-c| / |--classpath|
  * Revise |planck.core/file-seq| to be lazy (in terms of |tree-seq|)

Fixes

  * Capture stderr for |planck.shell/sh|
  * Fix a glitch in brace highlighting when vertically aligned
  * Properly exit if |planck.core/exit| is called with |0|
  * Don't block on I/O in |planck.core/shell/sh|
  * Properly decode UTF-8 from stdin


--
Note that posts from new members are moderated - please be patient with
your first post.
---
You received this message because you are subscribed to the Google
Groups ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send
an email to clojurescript+unsubscr...@googlegroups.com
mailto:clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com
mailto:clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


--
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups ClojureScript group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.