Live data from Hacker News

Callback Hell (2016)

callbackhell.com

61–70 of 170 posts

Re: Callback Hell (2016)

#61
post #26

Earlier quoted context omitted.

You can now use async/await directly in node (no transpiler necessary), and both Babel and TypeScript can compile them for browser use. Also there are now many more libraries that use native ES6 promises. Before: function getPhoto(callback) { someCustomHttpGet("/favorite_photo_id", function(err, data) { if (err) { return callback(err) } try { var dataJson = JSON.parse(data) someCustomHttpGet(dataJson.url, function(er…

Your try catch is useless here, AFAIK JSON.stringify doesn't throw. and you can't catch someCustomHttpGet() "exceptions" if the latter is supposed to be asynchronous. relevant: http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...

> let a = []; a.push(a); JSON.stringify(a)

TypeError: Converting circular structure to JSON

Re: Callback Hell (2016)

#62
post #52

Earlier quoted context omitted.

> A lot of beginner guides to various programming languages make this mistake of associating a certain property with a language as if it's inherent. In this case, async code - while sold as a main feature of the NodeJS platform - is in no way exclusive to, or even an inherent part of, Javascript/ES the language. Exclusive no, but considering JS's original environment and constraints it is in fact pretty inherent. `se…

Actually `setTimeout` is not part of the core language, it's a Web API.

I think the point they were trying to make is that all JS is almost always used with a run loop.

Whereas Ruby and Python are often used without a run loop.

Re: Callback Hell (2016)

#63
I don't consider myself a huge code style pusher but when I see two space indentation I have to really ask... seriously... why???!!!

Its funny to me because the languages where you get massive nesting you almost want greater indentation as it gets extremely confusing as to what scope you are in.

While I prefer either 4 spaces or tabs (obviously not mixed) I'm not completely revolted with 2 spaces in Algo languages like Java, C or Go (although I suppose Go you have no choice) because you just don't have much nesting.

But Scala and Javascript.... wholly crap is there a lot of nesting. Please for god sakes if you absolutely need that much indenting either refactor or give into the glorious evil that is TAB.

In all serious there is an accessibility thing with 2 spaces. You are hindering people with bad eye sight. I just don't have the visual acuity anymore to discern two spaces easily and I imagine there are many more. It is sort of like building a building and making the stairs extremely steep because you don't like taking lots of steps with your long legs.

Re: Callback Hell (2016)

#64
post #52

Earlier quoted context omitted.

> A lot of beginner guides to various programming languages make this mistake of associating a certain property with a language as if it's inherent. In this case, async code - while sold as a main feature of the NodeJS platform - is in no way exclusive to, or even an inherent part of, Javascript/ES the language. Exclusive no, but considering JS's original environment and constraints it is in fact pretty inherent. `se…

Actually `setTimeout` is not part of the core language, it's a Web API.

[deleted]

Re: Callback Hell (2016)

#65
post #63

I don't consider myself a huge code style pusher but when I see two space indentation I have to really ask... seriously... why???!!! Its funny to me because the languages where you get massive nesting you almost want greater indentation as it gets extremely confusing as to what scope you are in. While I prefer either 4 spaces or tabs (obviously not mixed) I'm not completely revolted with 2 spaces in Algo languages li…

I started using two spaces because it was the default with C on emacs. I took a liking to it.

Re: Callback Hell (2016)

#66
callback, n: 1. a function passed as a parameter. asynchronous programming, n: 1. code written to manage interrupts, often called signals.

This article is exemplary of why any educated and trained developer will not go anywhere near the Javascript community.

Re: Callback Hell (2016)

#67
Callback hell is due to everything being async in javascript. Naming functions and handling errors is how you may get by a little better.

For instance every database call is async, so for an operation that requires 3 chained calls, you'll have to nest these callbacks together.

Re: Callback Hell (2016)

#68
post #63

I don't consider myself a huge code style pusher but when I see two space indentation I have to really ask... seriously... why???!!! Its funny to me because the languages where you get massive nesting you almost want greater indentation as it gets extremely confusing as to what scope you are in. While I prefer either 4 spaces or tabs (obviously not mixed) I'm not completely revolted with 2 spaces in Algo languages li…

I'm a tab heretic for this reason -- every user can adjust their editor to show tabs with whatever width they like.

Re: Callback Hell (2016)

#69
post #63

I don't consider myself a huge code style pusher but when I see two space indentation I have to really ask... seriously... why???!!! Its funny to me because the languages where you get massive nesting you almost want greater indentation as it gets extremely confusing as to what scope you are in. While I prefer either 4 spaces or tabs (obviously not mixed) I'm not completely revolted with 2 spaces in Algo languages li…

It's because when you use 4 spaces, the lines just become too long. I use 4 spaces in C and 2 in javascript and that makes sense visually for me.

Re: Callback Hell (2016)

#70
post #63

I don't consider myself a huge code style pusher but when I see two space indentation I have to really ask... seriously... why???!!! Its funny to me because the languages where you get massive nesting you almost want greater indentation as it gets extremely confusing as to what scope you are in. While I prefer either 4 spaces or tabs (obviously not mixed) I'm not completely revolted with 2 spaces in Algo languages li…

I used to feel the same way. Any confusion goes away after you get used to it. Used 4 spaces for ~14 years, used 2 spaces now for 3 years. Now feel the same way about 4 as I once felt about 2 spaces.
Post reply on HN