Earlier quoted context omitted.
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.
If your lines are too long with 4 spaces, then you either have a tiny screen, or aren't line-breaking when you should be. Or you're in callback hell...
Callback Hell (2016)
81–90 of 170 posts
Re: Callback Hell (2016)
#82Earlier quoted context omitted.
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.
Let me guess... It is hard for you to read long lines or your monitor isn't big enough? You might call that an accessibility thing right? You get what I'm getting at. You traded one accessibility that is fairly easy to fix (at worse case you have line wrapping) for one that is almost impossible to fix (zooming and large font don't really help).
I don't think 4 spaces makes it easier to know in what scope I'm in when there are a lot of scopes. The amount of white space is a bit overwhelming to me.
But you know, it's no big deal, just a matter of taste. Maybe 3 spaces is a better answer, which I guess we'll never know...
Re: Callback Hell (2016)
#83I stopped reading right there (well, it's near the end of the article anyway, and I did continue, but you get my point).
Re: Callback Hell (2016)
#84Earlier quoted context omitted.
If your lines are too long with 4 spaces, then you either have a tiny screen, or aren't line-breaking when you should be. Or you're in callback hell...
yeah tiny screen, does that make me a bad programmer?
Re: Callback Hell (2016)
#85Serious question: what is considered async? From the site, I get that add(1+1) doesn't require a callback, whereas downloadFile(url) does. What about somethingHarderThanAddition(noExternalDependency)? My question is, what is the threshold that I can assume that my code will run sync, and when it cant?
It will always run sync, unless you call something that accepts a callback (either at the first level, or nested in something else you call).
Re: Callback Hell (2016)
#86Serious question: what is considered async? From the site, I get that add(1+1) doesn't require a callback, whereas downloadFile(url) does. What about somethingHarderThanAddition(noExternalDependency)? My question is, what is the threshold that I can assume that my code will run sync, and when it cant?
Generally you won't have a choice. If something in your function calls another async function, the function as a whole is forced to be async. If not, then it won't be.
It's possible to make a function fake-async even if it doesn't call any async functions, by just calling the callback at the end. But there's not much point -- and callers may make assumptions about the the callback being called in a separate iteration of the event loop, so doing that could cause subtle bugs. That latter problem is solvable by calling the callback in a setImmediate callback, but again, no point unless you have a good reason to.
(Exception: there are a few apis where you do have a choice, e.g node's randomBytes can be either sync or async. Generally they're things that might block, where the sync version returns an error if it can't satisfy immediately. But generally you don't.)
Re: Callback Hell (2016)
#87Earlier quoted context omitted.
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.
Sure, but criticising a rant about the propogation of misconceptions by propogating a misconception seems like a self-undermining position :)
Re: Callback Hell (2016)
#88Earlier quoted context omitted.
Let me guess... It is hard for you to read long lines or your monitor isn't big enough? You might call that an accessibility thing right? You get what I'm getting at. You traded one accessibility that is fairly easy to fix (at worse case you have line wrapping) for one that is almost impossible to fix (zooming and large font don't really help).
It's hard for me to read long lines. I don't think 4 spaces makes it easier to know in what scope I'm in when there are a lot of scopes. The amount of white space is a bit overwhelming to me. But you know, it's no big deal, just a matter of taste. Maybe 3 spaces is a better answer, which I guess we'll never know...
If you are say 4 levels deep the additional characters used over 2 spaces is 8 characters. You got whopping 8 additional characters to make an even longer line of code (code to be interpreted or read) and screwed over the people who need the indenting.
If long lines are a problem than just refactor. I agree long lines are hard to read but there is a simple fix. Either refactor or just put in a line feed (or however the PL deal with long lines aka \ for bash or python).
Re: Callback Hell (2016)
#89Serious question: what is considered async? From the site, I get that add(1+1) doesn't require a callback, whereas downloadFile(url) does. What about somethingHarderThanAddition(noExternalDependency)? My question is, what is the threshold that I can assume that my code will run sync, and when it cant?
In other words, it's an engineering decision, based on the expected consequences of the overall design in the context of understanding how the event reactor works.
Re: Callback Hell (2016)
#90I 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.