Problem is that Js kind of encourages this being single threaded and using callbacks for anything blocking. To be fair, the new async syntax sugar helps in modern Js, but nesting a bunch of callbacks or promises was basically the way you did stuff for the longest time.
Yes and no. Any programming language encourages nesting as in the end the computer does nest your code. So it is only normal and predictable that languages would reflect that. BUT! Nest logic can often be inverted and by doing so, reduce how much nesting you need to do.
If (data is not null) {
If (data has field x) {
Return data x
} else return null
} else return null
Can be
If (data is null) return null
If (data hasn't field x) return null
Return data x
the loop or match statement could possibly be extracted to another function, depending on the situation. rustc will most likely inline it so its zero cost
Back when I was still in school, I ran a few tests on real world LISP and Java (the then dominant language, this was in the late days of Sun Microsystems succes).
Turns out most LISP programs had fewer parentheses then Java had braces, parens and brackets.
Yeah - pure functions and immutable data aren't always the right answer, but appreciating that they're damn good most of the time is a good first step. Writing obvious code that does exactly what it appears to do at first glance and not one thing more? Your colleagues will thank you when they have to work with your stuff.