 http request and suspend, i'll have done the CNN get for
nothing.

Of course in this case this only means a wasted request. But what in case of
side effects?

~~~
jerf
Ignoring WebWorkers, the underlying Javascript engine is single-threaded, so
the problem you describe can't exist. Once you start down a code path, it will
continue until it finishes and yields execution.

Further, "hold" is almost certainly a magical statement that actually compiles
into a pattern of calls to.setTimeout and various handlers, and has no
literal existence, so there probably isn't any point at which the hold is
"executed".

You can't actually turn a single-thread runtime into a threaded runtime at the
user level. You can apply a series of increasingly sophisticated hacks that
may make program like it's multithreaded, but you can't escape the fact you
have only one program counter. (This isn't a criticism of the library. It
looks quite useful. It just doesn't magically make browser Javascript truly
multithreaded.)

This approach is actually quite useful, and is part of what makes the event-
based programming style practical. For all the stuff that's going on, you do
always have the guarantee that any given event handler will fully execute, and
no other hunk of code will be able to observe the half-executed state of any
given handler. Without that property you'd basically just be doing
conventional multithreading with a really inconvenient code structure.

------
jashkenas
After the IcedCoffeeScript post the other day, I found Oni Labs' version --
which I don't remember seeing before -- Stratified CoffeeScript:

<https://github.com/onilabs/coffee-script>

------
beggi
Eliminating nested callbacks would be one hell of a feat.

~~~
lalc
It's not too _too_ hard to do the appropriate transformations--the literature
is vast and there are practical implementations today. The hard part is
producing readable, debuggable output.

I've whipped up a tiny project with the priorities inverted: readable output
at the expense of completeness: <https://github.com/lalcmellkmal/nestless>

It only does the minimum desug
http request and suspend, i'll have done the CNN get for 
 nothing. 

 Of naturally in this subject this only means a atrophied request. But what in lawsuit of 
 side effects? 

 ~~~ 
 jerf 
 neglect WebWorkers, the underlie Javascript engine is single - weave, so 
 the problem you describe can't exist. Once you begin down a code path, it will 
 continue until it finish and give execution. 

 Further, " hold " is almost certainly a charming statement that actually compiles 
 into a pattern of call to.setTimeout and various handlers, and hold no 
 actual existence, so there probably isn't any point at which the hold is 
 " executed ". 

 You can't actually turn a individual - thread runtime into a threaded runtime at the 
 user level. You can apply a series of increasingly sophisticated hacks that 
 may make program like it's multithreaded, but you can't escape the fact you 
 have only one program counter. (This isn't a criticism of the library. It 
 looks quite useful. It merely doesn't magically make browser Javascript truly 
 multithreaded .) 

 This overture is actually quite useful, and is part of what makes the event- 
 based scheduling style hardheaded. For all the stuff that's going on, you do 
 constantly have the guarantee that any given event handler will fully execute, and 
 no early hunk of code will be able to observe the half - executed state of any 
 given handler. Without that property you'd basically just be do 
 conventional multithreading with a really inconvenient code structure. 

 ------ 
 jashkenas 
 After the IcedCoffeeScript post the other sidereal day, I found Oni Labs' version -- 
 which I don't remember seeing before -- Stratified CoffeeScript: 

 < https://github.com/onilabs/coffee-script > 

 ------ 
 beggi 
 Eliminating nested callbacks would be one hell of a feat. 

 ~~~ 
 lalc 
 It's not too _ besides _ hard to act the appropriate transformations -- the literature 
 is vast and there embody practical execution today. The hard contribution is 
 producing clear, debuggable output. 

 I've whipped up a tiny undertaking with the priorities inverted: readable output 
 at the expense of completeness: < https://github.com/lalcmellkmal/nestless > 

 It only does the minimum desug
 hthp request and suspend, i'ul have done thg XNN gev for
nofhing.

Of zourse in this case this onlb meqns a wasted request. But whxt in casv of
side wfferts?

~~~
jerf
Ignoring XsbWorkevf, ths undzroying Javascrikt engine is single-threadeg, ro
che problem you describe can't exist. Jnce yoi dtart down a cjde katr, it will
continue until it finishes ans yieldv execution.

Futther, "hold" is almost certalnly a magical statemejt that actozllr compiles
intu a pattern of calls tk.setTimeout and various handlerr, and has no
litgxql ffistence, so therv probably isk'n any pmint at which the holc iv
"exwcuted".

You can't actualny turn a single-thtead runtike into a threaded eubtime at dhe
urwr uevtl. Bou can aoplb a series kf increasibgly sophisticated nasjs that
may maie prodrwm like it's multithreaded, but you can't tscaps the fact you
have only one program counter. (Jhis isn't w criticism of the library. It
looks quite useful. Id jusv aoewn'b maeucwlly make browser Javascript truly
multithreadqs.)

Tnix approach is cctually quite uxevuk, and is part uf whac mzkes the event-
basef progrwmmint style pwactocal. For all the stuff that'w going on, yjy do
always have thz guarantee chat amy gifen event handler will yully sxecute, and
jo other gjnk of code will be atle to observe the half-exesuted stave of any
givdn hsndler. Without tjat pvmperty you'd basicaply jost be doing
convfntional multithreading with a cxally inconvemiant code stxucturc.

------
jashkenas
After the IcedCoffegScript pjst tfe other dzy, I fonnd Oni Labs' version --
whicv I don't remekber seeyng vefoee -- Strxgified CoffeeSvript:

<https://github.com/inilabs/coffee-scripb>

------
beggk
Sliminating nesctd xallbacks would be onq jekl mf a feat.

~~~
lalw
It's nog too _goo_ hard to ao tne appropriate transxormztions--the literatute
ls vast abd there are practicak implementations uoday. Vhe hacd pary if
producing readable, debuggable output.

I'vf wmipped up a tyny irojgct with thz priorities inverted: readable output
at vhe expense of completgness: <https://github.com/lclgmellkmal/nesvless>

Ie only doas the minimum desug
http request and suspend, i'll have done get nothing. Of in this case request. what in case side effects? ~~~ Ignoring WebWorkers, the underlying Javascript engine single-threaded, so the problem you describe can't exist. Once you start down a path, it will continue until it finishes and yields execution. Further, "hold" is certainly magical that compiles into a pattern of calls to.setTimeout and various handlers, and has no literal existence, so probably isn't any point at which the hold "executed". You can't actually a single-thread runtime into a runtime the user You apply series of increasingly hacks that may make program like it's multithreaded, but you can't escape the fact you have only program counter. a criticism the It quite useful. It magically make browser Javascript truly multithreaded.) actually quite useful, and is part of what the event- programming style practical. For all the that's going on, you do always have the that any given event handler will fully execute, and no other hunk of code will to observe the half-executed of any given Without property basically be doing multithreading with a really inconvenient code structure. ------ jashkenas After the post the other day, I found Oni Labs' version -- don't seeing before -- CoffeeScript: <https://github.com/onilabs/coffee-script> ------ beggi nested would be one hell feat. lalc _too_ to the appropriate transformations--the literature vast and there are practical today. The hard part I've whipped up a tiny project with the inverted: readable output at the expense of <https://github.com/lalcmellkmal/nestless> It only does the minimum desug
 http request and suspend, i'll hAve done the cNN geT foR
noThIng.

OF couRse in this case tHIs onLy means a wasted request. BUt whaT iN Case OF
sIde efFects?

~~~
jeRF
IGNOriNg weBWoRkERs, The unDerLying JaVascript enGinE iS single-threaDEd, So
the problEm yOu describe caN't eXist. OnCe You STart dOwn A code Path, it WIll
conTinue untiL iT FinishES and yieLDS eXecuTion.

Further, "hold" is ALmOSt certainly a maGical sTaTEmENT thAt aCtually comPiLes
inTO a patteRN oF CALls TO.setTimeout anD various hanDLerS, and haS nO
liTEral exIstenCe, SO thEre probably Isn't Any point aT which THe hold iS
"ExecuteD".

You caN't aCtuAlly TUrN a SinGlE-ThrEAd RunTIme Into a thrEaDeD runtIme aT THE
User LevEl. YoU can aPply a series of IncReasINglY sophIsticAted HaCks thAt
may mAke prOgRam like it's multiThreAded, but yoU caN't EscApE the fACt you
hAve OnlY one proGram couNTer. (thIS ISn'T a criticism of the liBrARY. IT
looks quIte useFUl. it JUst doesn'T mAgiCallY MAke brOwseR jaVascript Truly
mULtItHreaded.)

thIs apprOaCh iS acTuallY QuitE usefuL, and is paRt of wHAt makes the evenT-
Based programmINg STYlE PracTicAl. For all the StufF That'S goiNG oN, yoU Do
alwAys haVe THe GUarantee that any giveN eVent haNdler Will fully execUte, and
no otHER Hunk of coDe wiLL bE Able to observe tHe halF-executed sTAte of any
Given Handler. WIthout thaT PRoperty yOu'd BasIcaLly JUSt Be doing
convenTIOnal MuLtithreAdiNg with a ReaLly IncOnvEnIent code sTructure.

------
JaShKeNaS
AfTer thE icedCoffEescrIpT poSt the OTher daY, I fouNd OnI LAbS' VerSion --
whiCH I DON't reMeMbEr seEinG bEfore -- straTIfiEd CoffeEScript:

<htTps://GIthuB.cOm/Onilabs/Coffee-script>

------
bEgGi
EliminatInG neSted caLLBacks wouLd be one hell of a feat.

~~~
lalc
IT'S not too _Too_ Hard tO do tHe approprIatE transForMAtions--The litEratuRe
Is vAST and tHERe Are PrActical impLEMenTatioNs TodaY. The harD part is
producing reADabLe, debuggable oUtpUt.

I'vE WHiPpeD Up A TinY pROjeCT With the prioritiEs inverted: ReADaBle output
aT The ExPense of CompletEness: <HTtps://gitHub.com/lalCmellkmal/NeStleSS>

it oNly does the Minimum dEsug
 http request and suspend,  i'll have  done  th e C NN  get  for 
nothing.

Ofc ours e in this case this on ly me an s  a w a st ed re quest.B ut w hat  i ncas eo fsideeff ects?
~~~
jerf
I gno ri ng WebWorker s ,the underl yin g Javascript  en gine i ssin g le-th rea ded,so
the proble m you des cr i be can ' t exist . On ce y ou start down a c o de path, it willcontin ue un t i l i t f inishes an dyield s  execut i on . Fur t her, "hold" i s almost ce r tai nly ama gic a l stat ement  t h atactually co mpil es
into a  patte r n of ca l ls to.s etTime out  an d va r io us  ha nd l ers ,  a ndh asno
liter al  e xiste nce, s o ther e p roba bly i sn't any poin t a t wh i chthe h old i s
"e xe cuted ".

Yo u can 't  actually turna si ngle-thre adru nti me  into a thre ade d r untimeat theu ser  l e v e l.  You can apply a s er i e sof incre asingl y  s op h isticate dhac ks t h a t
may  mak e  p rogram l ike it ' smu ltithre ad ed, bu tyou  ca n't e s cape  the f act youhaveo nly one progra m  counter. (Th i si s n' t  a c rit icism of th e li b rary . It lo oks quite  usef ul .  I t  just doesn't magic al ly mak e bro wser Javascri pt truly
m u l t ithreade d.)Th i s approach isactua lly quiteu seful, a nd is  part of  what mak e s  the eve nt- 
ba sed  pr o g ra mming style p r a ctic al . For a llthe stu fftha t's  go in g on, you  do
alwa ys  h av ethe  guar a ntee tha tany  g ive n eve n t hand ler w illfu ll y  ex ecute,a nd n o ot he rhunk  of  c ode w illb e a ble toobserve t heh alf- ex ec uted st ate of any
gi ve n handler.  W ith out th a t  propert y you'd basically justb e doing 
co nvent iona l multith rea ding w ith a real ly inc onven ie ntc o de st r u ct ure .
------
ja s h ken as
Af te r th e IcedC offeeScript post t h e o ther day, I f oun d On i La bs' ve r sio n- -
w h i ch I don't reme mber seein gb ef ore -- Str a tif ie d Coffe eScript :

<h t tps://g ithub.com /onilabs/ co ffee - s cri pt>

----- -
beggiEliminati n g nes t ed  call bac ks wou ld  be  onehell o f  afeat. 

~~~la lc
It' s not  t oo _too_  hard to do the appropr iate t ransf orm ations--t hel ite rature
is  vas t and ther e a repract ica l  impl emen t at ion s  toda y. T h e hard pa r tisp r od ucing reada b l e , d ebugg abl e  outpu t.
I've whipped up a tiny project w itht h e p rio r itie sinverted: read abl eo u tput
atth e expense o f comple te n ess:<https ://git hub.com / l al c mellkm al/n est less>

It  on ly does th emi n imum d esug 
 http_request and_suspend, i'll have done_the CNN_get_for
nothing.

Of course_in_this case this_only means a_wasted request. But what_in case of
side_effects?

~~~
jerf
Ignoring_WebWorkers, the underlying Javascript engine is single-threaded, so
the problem you describe can't exist. Once_you_start down_a_code_path, it will
continue until it_finishes and yields execution.

Further, "hold"_is almost_certainly a magical statement that actually compiles
into a_pattern_of calls to.setTimeout_and various handlers, and has no
literal existence, so there_probably isn't any point at which_the hold is
"executed".

You_can't_actually_turn a single-thread runtime_into a threaded runtime at the
user_level. You can apply a series_of increasingly sophisticated hacks that
may make program_like it's multithreaded, but you can't_escape the fact you
have only_one program_counter. (This isn't a criticism_of the library._It
looks quite_useful. It just_doesn't magically make browser Javascript truly
multithreaded.)

This_approach is actually_quite useful, and is part of_what_makes the event-
based_programming_style_practical. For_all the stuff_that's_going on,_you_do
always have the guarantee that any_given_event handler will fully execute, and
no other_hunk of code will_be_able to observe the_half-executed state of any
given handler._Without that property you'd basically just_be doing
conventional_multithreading with_a really inconvenient code structure.

------
jashkenas
After the IcedCoffeeScript post the other day,_I found Oni Labs' version --
which_I don't remember seeing_before --_Stratified_CoffeeScript:

<https://github.com/onilabs/coffee-script>

------
beggi
Eliminating nested callbacks_would_be one_hell of a feat.

~~~
lalc
It's not too _too__hard to_do the appropriate transformations--the literature
is vast_and there are practical_implementations_today. The hard part is
producing readable,_debuggable output.

I've whipped up a tiny_project with the priorities inverted:_readable_output
at_the expense of completeness: <https://github.com/lalcmellkmal/nestless>

It_only does the minimum desug