Re: [ClojureScript] basic conceptual question: clojurescript & core.async

2016-08-08 Thread Jamie Orchard-Hays
Important concepts to understand are:

* Concurrency
* Parallelism

People often use the terms as synonyms, but they are not. You can have 
concurrency in single-threaded environments, but you can not have parallelism 
in single-threaded environments.

This recent talk, “From Concurrent to Parallel”, by Brian Goetz talks about 
both concepts:

https://www.youtube.com/watch?v=QicNusGdz4g

Jamie

> On Aug 8, 2016, at 12:27 PM, Brian Beckman  wrote:
> 
> On Monday, August 8, 2016 at 6:30:14 AM UTC-7, Moe Aboulkheir wrote:
>> By no means is it typical that in a JS runtime, external interactions (I/O) 
>> would block the execution thread - if that were the case, the callbacks 
>> would not be necessary.
>> 
>> 
>> Take care,
>> Moe
> 
> Let's see whether I understand: The code running on the JavaScript main 
> thread (call it A) makes a non-blocking call to a service (say I/O, call its 
> code B) and passes in a callback C written by me. The call to B returns 
> immediately and my main JavaScript code A continues doing whatever it was 
> doing (say servicing the user interface). The callback code C executes on 
> _another_ thread, a thread under control of the B. I write code A and I write 
> code C, but my code A runs on the JavaScript main thread and my code C runs 
> on some other thread. Is that right?
> 
> -- 
> 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 https://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 https://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: basic conceptual question: clojurescript & core.async

2016-08-08 Thread Moe Aboulkheir
Brian,

The callback (C) is going to be invoked on the main thread (A), but
everything else sounds good to me.  There's a decent explanation here
http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/ which
I think generalises to other/similar runtimes.

Take care,
Moe

On Mon, Aug 8, 2016 at 12:27 PM, Brian Beckman  wrote:

> On Monday, August 8, 2016 at 6:30:14 AM UTC-7, Moe Aboulkheir wrote:
> > By no means is it typical that in a JS runtime, external interactions
> (I/O) would block the execution thread - if that were the case, the
> callbacks would not be necessary.
> >
> >
> > Take care,
> > Moe
>
> Let's see whether I understand: The code running on the JavaScript main
> thread (call it A) makes a non-blocking call to a service (say I/O, call
> its code B) and passes in a callback C written by me. The call to B returns
> immediately and my main JavaScript code A continues doing whatever it was
> doing (say servicing the user interface). The callback code C executes on
> _another_ thread, a thread under control of the B. I write code A and I
> write code C, but my code A runs on the JavaScript main thread and my code
> C runs on some other thread. Is that right?
>
> --
> 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 https://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 https://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: basic conceptual question: clojurescript & core.async

2016-08-08 Thread Brian Beckman
On Monday, August 8, 2016 at 6:30:14 AM UTC-7, Moe Aboulkheir wrote:
> By no means is it typical that in a JS runtime, external interactions (I/O) 
> would block the execution thread - if that were the case, the callbacks would 
> not be necessary.
> 
> 
> Take care,
> Moe

Let's see whether I understand: The code running on the JavaScript main thread 
(call it A) makes a non-blocking call to a service (say I/O, call its code B) 
and passes in a callback C written by me. The call to B returns immediately and 
my main JavaScript code A continues doing whatever it was doing (say servicing 
the user interface). The callback code C executes on _another_ thread, a thread 
under control of the B. I write code A and I write code C, but my code A runs 
on the JavaScript main thread and my code C runs on some other thread. Is that 
right?

-- 
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 https://groups.google.com/group/clojurescript.


[ClojureScript] Re: basic conceptual question: clojurescript & core.async

2016-08-08 Thread Thomas Heller
You can have concurrency without parallelism.

core.async is "A Clojure library designed to provide facilities for async 
programming and communication". Parallelism is just a bonus side-effect, but 
not required or even the goal. Reducers for example have the goal of 
parallelism over concurrency.

http://joearms.github.io/2013/04/05/concurrent-and-parallel-programming.html
https://vimeo.com/49718712

So you don't need 2+ threads for core.async to be useful. Basically it lets you 
write concurrent code without callback hell. You can write code that looks like 
it would block but is converted to something else under the hood.

HTH,
/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 https://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: basic conceptual question: clojurescript & core.async

2016-08-08 Thread Moe Aboulkheir
By no means is it typical that in a JS runtime, external interactions (I/O)
would block the execution thread - if that were the case, the callbacks
would not be necessary.

Take care,
Moe

-- 
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 https://groups.google.com/group/clojurescript.


[ClojureScript] Re: basic conceptual question: clojurescript & core.async

2016-08-08 Thread Brian Beckman
The quote puzzles me. I would be less puzzled if it said "... turns the 
Asynchronous-looking channel reads and write into Synchronous calls."

I don't understand the source of asynchrony in single-threaded JavaScript. I 
can see that a go block can implement something equivalent to an iterator via a 
state machine and queues, so a data-producer and a data-consumer can have the 
illusion of asynchrony while executing on a single thread. I can see that 
JavaScript may interact with external software by blocking the JavaScript 
thread and by responding through callbacks that run on the JavaScript thread. 
Those callbacks could implement the channel abstraction of clojure.async. Am I 
missing some other kinds of interaction? Have I got an accurate or inaccurate 
picture of what's going on in JavaScript?

-- 
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 https://groups.google.com/group/clojurescript.


[ClojureScript] Re: Having trouble with Japanese text input that reads values from a reagent atom

2016-08-08 Thread Ikuru Kanuma
Thanks for the suggestion, Christopher!
Using re-com with on-blur automagically solved the problem!

Ikuru

-- 
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 https://groups.google.com/group/clojurescript.


[ClojureScript] Re: basic conceptual question: clojurescript & core.async

2016-08-08 Thread Walter van der Laan
A quote from https://www.infoq.com/news/2013/07/core-async:

"The "magic" of core.async is that internally it converts the body of each go 
block into a state machine and turns the synchronous-looking channel reads and 
writes into asynchronous calls."

-- 
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 https://groups.google.com/group/clojurescript.