Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to avoid callback hell?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 76 - 100 of 139 - Collapse all  -  Translate all to Translated (View all originals) < Older  Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Isaac Schlueter  
View profile  
 More options Apr 10 2012, 10:17 pm
From: Isaac Schlueter <i...@izs.me>
Date: Tue, 10 Apr 2012 19:17:52 -0700
Local: Tues, Apr 10 2012 10:17 pm
Subject: Re: [nodejs] Re: How to avoid callback hell?

On Tue, Apr 10, 2012 at 19:16, Isaac Schlueter <i...@izs.me> wrote:
> It is not our goal to make programs look blocking when they are in
> fact parallel (that's a bad complexity trade-off).

s/parallel/nonblocking/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Hahn  
View profile  
 More options Apr 10 2012, 10:21 pm
From: Mark Hahn <m...@hahnca.com>
Date: Tue, 10 Apr 2012 19:21:08 -0700
Local: Tues, Apr 10 2012 10:21 pm
Subject: Re: [nodejs] Re: How to avoid callback hell?

>   when things break I even get line numbers :)

I can tell you went to a lot of work writing those diplomatic even-handed
posts.  But then you couldn't resist taking a shot at the end.  :-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruno Jouhier  
View profile  
 More options Apr 11 2012, 2:27 am
From: Bruno Jouhier <bjouh...@gmail.com>
Date: Tue, 10 Apr 2012 23:27:17 -0700 (PDT)
Local: Wed, Apr 11 2012 2:27 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

depend is not a very good measure either. Streamline is more for people who
write applications than for library writers. And people don't publish whole
applications to NPM. There are also a few who use it browser side.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Axel Kittenberger  
View profile  
 More options Apr 11 2012, 2:54 am
From: Axel Kittenberger <axk...@gmail.com>
Date: Wed, 11 Apr 2012 08:54:01 +0200
Local: Wed, Apr 11 2012 2:54 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

> If you are ignoring coffeescript because of this then that is a shame.  I
> use absolutely nothing but coffeescript and I can't imagine living without
> it.

Yes it's a make or break for me. A language that doesn't even get its
scoping at least somewhat right is a no-go for me .Introducing a new
global variable messes up some code that worked before far below just
because it happens to have a local variable named the same way? I
don't even understand what a "great idea" it was to go back to
implicit variable declaration, global or local, while everyone else
after years of experience is pushing that down, a few characters for
declaring a varible (local and global) is nothing compared to the
hours of joy debugging. Javascript idiosyncratic scoping is already
scraping that limit for me, and if it wouldn't have the momentum of
being the web language, I'd already frown about that.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Axel Kittenberger  
View profile  
 More options Apr 11 2012, 2:57 am
From: Axel Kittenberger <axk...@gmail.com>
Date: Wed, 11 Apr 2012 08:57:57 +0200
Local: Wed, Apr 11 2012 2:57 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

> I disagree about my benchmarks being incorrect.

No, as long the two "benchmarks" behave different IO wise, they are
incorrect and you compare apples with oranges. E.g. If you want to
fill buffers to full limit, and do it both wise. And try to come up
with aproperiate flow control in vanilla code, yes its not uber
trivial to write. Thats the whole point. There is no overhead in
runtime, since streamline will translate to script you would write
anyway. The only overhead is during startup when streamline does the
parsing/generating.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Hahn  
View profile  
 More options Apr 11 2012, 3:22 am
From: Mark Hahn <m...@hahnca.com>
Date: Wed, 11 Apr 2012 00:22:20 -0700
Local: Wed, Apr 11 2012 3:22 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

>   A language that doesn't even get its scoping at least somewhat right is

a no-go for me .

Any yet you use a language that defaults everything to global.

The lack of the var statement is the only thing wrong with scoping at the
moment and I showed you a nice workaround.  Otherwise scoping is more
than "somewhat"
right and a big improvement over javascript.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Axel Kittenberger  
View profile  
 More options Apr 11 2012, 3:31 am
From: Axel Kittenberger <axk...@gmail.com>
Date: Wed, 11 Apr 2012 09:31:53 +0200
Local: Wed, Apr 11 2012 3:31 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

> Any yet you use a language that defaults everything to global.

Its not like you got much choice when you do client-side web
development. Default to local is IMHO not any better than default to
global. Why default to anything? Jhint warns nicely about any default
to globals.

> The lack of the var statement is the only thing wrong with scoping at the
> moment and I showed you a nice workaround.  Otherwise scoping is more than
> "somewhat" right and a big improvement over javascript.

Bringing us back to the topic of "workarounds" to "problems" not
acknowledged as problems but canted to the "way of [X]".

If I ever put up the focus, I'd rather get my own
javascrip-meta-language that eases/encorages heavy use of immutables
to get another advantage of functional programming in.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Hahn  
View profile  
 More options Apr 11 2012, 3:37 am
From: Mark Hahn <m...@hahnca.com>
Date: Wed, 11 Apr 2012 00:37:58 -0700
Local: Wed, Apr 11 2012 3:37 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

You would obviously be happy with Erlang.  Can't you code server-side in
Erlang?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Axel Kittenberger  
View profile  
 More options Apr 11 2012, 4:11 am
From: Axel Kittenberger <axk...@gmail.com>
Date: Wed, 11 Apr 2012 10:11:37 +0200
Local: Wed, Apr 11 2012 4:11 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
I've code sharing between server and client. So unless Erlang
translates to Javascript, node.js is the way to go.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richard Marr  
View profile  
 More options Apr 11 2012, 5:18 am
From: Richard Marr <richard.m...@gmail.com>
Date: Wed, 11 Apr 2012 10:18:59 +0100
Local: Wed, Apr 11 2012 5:18 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
On 10 April 2012 14:46, Bruno Jouhier <bjouh...@gmail.com> wrote:

> It's like you have to follow the dogma and the last thing you should do is try things out and make up your own mind.

> Come on guys, I don't care if you'll end up using streamline or not but please BE CURIOUS AND TRY THINGS OUT.

Considering the variety of replies in the thread I don't think its
fair to call it dogma.

Absolutely people should try new things out, but some have implied in
this thread that suggesting that the solution to (not knowing what to
do about) 'callback hell' is to add abstractions and meta-languages...
which seems hasty to me.

I'd be surprised if didn't agree on some level that it's worthwhile
encouraging incoming coders to first reach a fairly basic level of
familiarity before they explore that stuff.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Isaac Schlueter  
View profile  
 More options Apr 11 2012, 5:24 am
From: Isaac Schlueter <i...@izs.me>
Date: Wed, 11 Apr 2012 02:24:15 -0700
Local: Wed, Apr 11 2012 5:24 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
Trying stuff out is great.  Do that.

Also, you should learn JavaScript.  It's unavoidable, after all, so
you'll always end up dealing with it somehow.  (For similar reasons,
you should learn C as well.)

A lot of people seem to be ok with using JavaScript without any meta
language in front of it.  Some of them even claim it's better than the
alternatives, and they have some tricks and practices that make
callbacks decidedly un-hellish.  So maybe try that out, too.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mariusz Nowak  
View profile  
 More options Apr 11 2012, 5:50 am
From: Mariusz Nowak <mari...@medikoo.com>
Date: Wed, 11 Apr 2012 02:50:22 -0700 (PDT)
Local: Wed, Apr 11 2012 5:50 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

Adding to what Isaac said.
Many of us have gone through "callback hell" and don't have that problem
anymore, it's not Node.js or JavaScript issue. Check available solutions,
listen to those who've been there.
Important note: asynchronous programming requires some time to get with it,
and it will always be like that, it doesn't matter whether you work with
plain callbacks or trying out some ready solution.
Never expect to find solution that in 5 minutes will make your problem
gone, from my perspective everyone needs at least few days playing with it
to workout/learn solution that will feel comfortable with.

--
Mariusz Nowak
https://github.com/medikoo
http://twitter.com/medikoo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nuno Job  
View profile  
 More options Apr 11 2012, 6:31 am
From: Nuno Job <nunojobpi...@gmail.com>
Date: Wed, 11 Apr 2012 11:31:26 +0100
Local: Wed, Apr 11 2012 6:31 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

>> Streamline is more for people who write applications than for library

writers.

Thanks for putting that crystal clear Bruno. It's very positive when people
say what their tools are good for, and not so adequate for imho.

The way you write your applications is entirely up to you, and you are
always right to do what you feel confortable. As for libraries, the
decisions you make have implications on those using your libraries.

For people wanting to know a bit more on bruno's views he shared a blogpost
I found very informative:

   -
   http://bjouhier.wordpress.com/2011/05/24/yield-resume-vs-asynchronous...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jann Horn  
View profile  
 More options Apr 11 2012, 9:54 am
From: Jann Horn <jannh...@googlemail.com>
Date: Wed, 11 Apr 2012 15:54:19 +0200
Local: Wed, Apr 11 2012 9:54 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

Am Sonntag, den 08.04.2012, 22:48 -0700 schrieb Mark Hahn:

> In coffeescript it is only nesting heck.

And in coco, it is often not even nesting heck. :)

coffeescript:

foo (resultA) ->
  bar (resultB) ->
    baz()

coco:

(resultA) <- foo!
(resultB) <- bar!
baz!

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jann Horn  
View profile  
 More options Apr 11 2012, 10:00 am
From: Jann Horn <jannh...@googlemail.com>
Date: Wed, 11 Apr 2012 16:00:05 +0200
Local: Wed, Apr 11 2012 10:00 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

Am Dienstag, den 10.04.2012, 20:14 +0200 schrieb Axel Kittenberger:

> On Tue, Apr 10, 2012 at 3:37 PM, Yi Tan <yi2...@gmail.com> wrote:
> > you really should spend a few hours learning coffee script if the js
> > callback syntax make you uncomfortable

> Unless coffee script fixes its "implicit local variable is global if
> the names match and just dont take care to not accidently name it
> equally" I will not touch it with a long stick.

<fanboy>Use coco, it's much better there! And it's cooler
anyway. :)</fanboy>

> Ask Javascript, about 'this'.

Uh... anything wrong about that?

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Coffeescript line numbers" by Jann Horn
Jann Horn  
View profile  
 More options Apr 11 2012, 10:16 am
From: Jann Horn <jannh...@googlemail.com>
Date: Wed, 11 Apr 2012 16:16:25 +0200
Local: Wed, Apr 11 2012 10:16 am
Subject: Coffeescript line numbers

Am Dienstag, den 10.04.2012, 18:50 -0700 schrieb Mikeal Rogers:

> > I'm working at the app level and I have 10,000 lines of coffeescript.  I can't imagine coding all that in javascript.

> I have about 10 times that in javascript and it's quite easy, when things break I even get line numbers :)

Hey! There are patches for error reporting with token precision!
https://github.com/jashkenas/coffee-script/pull/2050

(well, apart from string interpolations, correct source positions are a
bit tricky for those)

  signature.asc
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "How to avoid callback hell?" by Jorge
Jorge  
View profile  
 More options Apr 12 2012, 5:27 am
From: Jorge <jo...@jorgechamorro.com>
Date: Thu, 12 Apr 2012 11:27:43 +0200
Local: Thurs, Apr 12 2012 5:27 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
On Apr 11, 2012, at 2:16 AM, Joe Ferner wrote:

> (...) Methods with callbacks are not required to have async code in them, they just generally do. If you replace doIt with say a getUserFromCache method where 99% of the time you get cache hits and the function just returns the user this would be completely valid (...)

You can do that but I think the consensus is that it's not a good idea because it complicates reasoning about your code:

method(params, cb);
doSomethingElse();

Will doSomethingElse() run before or after cb() ?
--
Jorge.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roly Fentanes  
View profile  
 More options Apr 12 2012, 5:33 am
From: Roly Fentanes <r...@markover.me>
Date: Thu, 12 Apr 2012 02:33:54 -0700
Local: Thurs, Apr 12 2012 5:33 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

If your function is asynchronous only sometimes, consider getting rid of
that ambiguity by using process.nextTick() on your callback in the cases
where calling it won't be async.

--
*Roly Fentanes*
r...@markover.me
480 200 3369

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge  
View profile  
 More options Apr 12 2012, 5:35 am
From: Jorge <jo...@jorgechamorro.com>
Date: Thu, 12 Apr 2012 11:35:09 +0200
Local: Thurs, Apr 12 2012 5:35 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
On Apr 10, 2012, at 9:48 PM, Alexey Petrushin wrote:

> When a question rises again and again it's a good sign of problem.

> To make clear I'm not in any way blame the node on it, it has tons of advantages and it's ok to have problem.
> Every advanced machinery have some sort of problems or limitations - it's ok.

> But what's not ok - is to have false delusion, to believe that a problem is a feature, or even worse - call it "The Rails/Node way".

> Because if You call the problem as it deserves - the problem - there's always room for progress and improvement. And maybe someday it will be completely fixed and become not a problem but another advantage.

> But when You ignore it or believe that it's a "feature" or "the right way" - the problem always will be there, it's a way to stagnation.

> Yes You can become tolerable to ugly code and buy wider screen to fit all those callbacks, but it doesn't matter.
> Perceptions doesn't change the objective reality, no matter how much people believe that false is true, false still and always will be the false.

> So, maybe it's worth to stop call this problem a "feature"?

+1
--
Jorge.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge  
View profile  
 More options Apr 12 2012, 5:40 am
From: Jorge <jo...@jorgechamorro.com>
Date: Thu, 12 Apr 2012 11:40:48 +0200
Local: Thurs, Apr 12 2012 5:40 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
On Apr 10, 2012, at 10:01 PM, Joe Ferner wrote:

> I think I'm done writing benchmarks.  Even if I come up with a
> benchmark that shows streamline is faster I'm still not going to use
> it and I couldn't recommend anyone else use it either. The community
> as a whole doesn't back that kind of syntax so I couldn't submit a
> module to npm if I wrote it using streamline.

You could of course, yes. There's people writing their modules in CS and publishing/pushing just the JS output to npm. E.g. pdfkit:

<https://github.com/devongovett/pdfkit/commit/08c1b65067df7dba18b9e87f...>

> (...)

--
Jorge.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jorge  
View profile  
 More options Apr 12 2012, 5:53 am
From: Jorge <jo...@jorgechamorro.com>
Date: Thu, 12 Apr 2012 11:53:30 +0200
Local: Thurs, Apr 12 2012 5:53 am
Subject: Re: [nodejs] Re: How to avoid callback hell?
On Apr 12, 2012, at 11:33 AM, Roly Fentanes wrote

>> On Thu, Apr 12, 2012 at 2:27 AM, Jorge <jo...@jorgechamorro.com> wrote:
>>> On Apr 11, 2012, at 2:16 AM, Joe Ferner wrote:

>>> (...) Methods with callbacks are not required to have async code in them, they just generally do. If you replace doIt with say a getUserFromCache method where 99% of the time you get cache hits and the function just returns the user this would be completely valid (...)

>> You can do that but I think the consensus is that it's not a good idea because it complicates reasoning about your code:

>> method(params, cb);
>> doSomethingElse();

>> Will doSomethingElse() run before or after cb() ?

> If your function is asynchronous only sometimes, consider getting rid of that ambiguity by using process.nextTick() on your callback in the cases where calling it won't be async.

Exactly...
--
Jorge.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oliver Leics  
View profile  
 More options Apr 12 2012, 7:05 am
From: Oliver Leics <oliver.le...@gmail.com>
Date: Thu, 12 Apr 2012 13:05:46 +0200
Local: Thurs, Apr 12 2012 7:05 am
Subject: Re: [nodejs] Re: How to avoid callback hell?

On Tue, Apr 10, 2012 at 10:13 PM, Naouak <tard...@gmail.com> wrote:
> Am I the only one that thinks that we talk about Callback Hell only because
> we are not used to used callback everywhere ?

No. *wink*

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruno Jouhier  
View profile  
 More options Apr 14 2012, 12:30 pm
From: Bruno Jouhier <bjouh...@gmail.com>
Date: Sat, 14 Apr 2012 09:30:33 -0700 (PDT)
Local: Sat, Apr 14 2012 12:30 pm
Subject: Re: How to avoid callback hell?

I posted a follow-up on my blog:
http://bjouhier.wordpress.com/2012/04/14/node-js-awesome-runtime-and-...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
r...@tinyclouds.org  
View profile  
 More options Apr 14 2012, 8:35 pm
From: r...@tinyclouds.org
Date: Sat, 14 Apr 2012 17:35:09 -0700
Local: Sat, Apr 14 2012 8:35 pm
Subject: Re: [nodejs] Re: How to avoid callback hell?

On Sat, Apr 14, 2012 at 9:30 AM, Bruno Jouhier <bjouh...@gmail.com> wrote:
> I posted a follow-up on my blog:
> http://bjouhier.wordpress.com/2012/04/14/node-js-awesome-runtime-and-...

Bruno, we are evangelizing callbacks because this is the only it can
possibly work in JavaScript. You can add a preprocessing step (which
is apparently what streamline is doing) - we will not do that. You can
add some crazy longjmp  in your extension and juggle executions stacks
and try to forget how much memory they are or fight with stack over
flows - we will not do that. JavaScript has a run-to-completion model
which we do not seek to circumvent. Node is JavaScript - even more
than that - Node is V8 JavaScript. If V8 adds generators, we will have
them - if not then not. One of the key reasons Node is successful
(unlike all of other server-side JS systems) is because it actually
uses JavaScript and not some JavaScript-like language.

I'm glad you like Node.  As you said, it is simple and fast. It got
that way by keeping things simple and fast. It will remain simple and
fast by continuing to strive for those goals.

This is a discussion to bring up with the EcmaScript committee.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Caswell  
View profile  
 More options Apr 14 2012, 11:30 pm
From: Tim Caswell <t...@creationix.com>
Date: Sat, 14 Apr 2012 22:30:49 -0500
Local: Sat, Apr 14 2012 11:30 pm
Subject: Re: [nodejs] Re: How to avoid callback hell?

I commented in long form on Bruno's blog, but it's not showing for some
reason.  Here are the highlights:

...(paragraphs talking about my experience helping newcomers)...

Node had "promises" early on and we learned a very important lesson with
them.  Hiding the non-blocking nature of code is bad! ...  Node "promises"
had a method called "wait" that would just suspend the current stack and
return the value after the promise was resolved.   This was dangerous ....
 Luckily Ryan has the sense to remove this feature quite quickly, but it
left a bad taste in all our mouths ever since for ... faux blocking.

...(some paragraphs saying that streamline isn't as evil as promise.wait
was)...

I think streamline is a brilliant piece of engineering and I'm sure there
are people who really benefit from such a tool.  Just understand it's not
for everyone.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 76 - 100 of 139 < Older  Newer >
« Back to Discussions « Newer topic     Older topic »