News for hackers. Stuff that matters.
Re:React/JavaScript fatigue by ilostmykeys on Monday December 28, 2015 @10:43AM (#10801583)
Can you expand that to the concurrent scenario?

Show us how you implement this simple and very common concurrent pattern with ClojureScript. I've seen stuff that implement this in ClojureScript and it ain't pretty (to say the least) Impress me! :)

In ES7:

async function fAsync() {

try { var results = await Promise.all([asyncOpA, asyncOpB, asyncOpC]) } catch (e) { ... } }

Re:React/JavaScript fatigue by Skinney on Monday December 28, 2015 @10:01PM (#10804915)
From reading core.asyncs documentation, it sounds like this should do the trick:

(go (try (let [ops [asyncOpA asyncOpB asyncOpC]] (core.async/take (count ops) (apply core.async/merge ops))) (catch js/Error e ...)))

Where asyncOp* uses go-catching.

Re:React/JavaScript fatigue by yogthos on Monday December 28, 2015 @02:47PM (#10802949)
Re:React/JavaScript fatigue by ilostmykeys on Monday December 28, 2015 @04:28PM (#10803496)
I couldn't find example in the docs for that library showing concurrent async ops with simple try/catch type error handling. So it's still not clear to me how you would rewrite the above shown async/await concurrent scenario using this library.
Re:React/JavaScript fatigue by mad-mad-beaver on Monday December 28, 2015 @05:37PM (#10803828)
Just use promesa/all then catch :)

Moreover, it has funcool/cats bindings, so you can use promises in mlet and alet macros if you are into monad thing ;)

Re:React/JavaScript fatigue by ilostmykeys on Monday December 28, 2015 @06:55PM (#10804234)
Oh right, that makes sense but does not make async code organize the way synchronous code does (as async/await sugar enables) but is a fair deal if you don't mind your async code using a different organizing pattern or if you specifically want it to be that way... :)

Re: cats

Not a big fan of abstractions that don't contribute to code simplicity. What is the percentage of programmer who dig monads? Less than 1% probably.

Re:React/JavaScript fatigue by yogthos on Monday December 28, 2015 @07:38PM (#10804397)
You're just cherry picking though. When it comes to complexity there's plenty more of it in Js than there's ever likely to be in ClojureScript.
Re:React/JavaScript fatigue by ilostmykeys on Tuesday December 29, 2015 @05:01PM (#10809369)
I am biased. Just as you are.
Re:React/JavaScript fatigue by yogthos on Tuesday December 29, 2015 @09:41PM (#10810411)
Objectively speaking, Js is a far more complex language than ClojureScript.
Re:React/JavaScript fatigue by Skinney on Monday December 28, 2015 @10:06PM (#10804938)
It's a trivial matter to wrap promise/all in a core.async channel, providing the exact orginzation pattern you're looking for.
Re:React/JavaScript fatigue by ilostmykeys on Tuesday December 29, 2015 @05:01PM (#10809367)
Show me the code! Go ahead and let's see how pretty that is, and son't forgeg error handling and concurrency.
Re:React/JavaScript fatigue by Skinney on Tuesday December 29, 2015 @10:29PM (#10810530)
I've provided all the code you need to put the pieces together quite trivially. Using go-catching, <? and the promise library (or just the core.async snippet I wrote earlier), you should be able to write the following:

(go-catching (<? (async-all [asyncOpA asyncOpB asyncOpC])))

And yes, that handles errors exactly like synchronous code does. The total number of lines for implementing go-catching, <? and async-all shouldn't take more than 20-30 loc, if not less.

Now, if 20-30 loc is too much for you to write, then by all means use JS.

Re:React/JavaScript fatigue by yogthos on Monday December 28, 2015 @06:51PM (#10804216)
So what you're saying is that you can't be arsed to spend 15 minutes to learn a library, but you're ok gobbling up all of ES6/7 without problems?
Re:React/JavaScript fatigue by ilostmykeys on Tuesday December 29, 2015 @05:02PM (#10809374)
That's an argument plot, not a genuine question. :)
Re:React/JavaScript fatigue by yogthos on Tuesday December 29, 2015 @09:42PM (#10810414)
ah so just trolling then :P