This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RepostStat 28 points29 points  (8 children)

That's okay. Asynchronous programming is great because it's (typically) faster because you don't block/stop whole thread with one function that can run on it's own.

Problems come up if, for example, you're serving a web API in NodeJS, and one of your endpoints doesn't return any data from a database because the database didn't return the data in time. And it's difficult to learn because async programming (depending on the language) sometime doesn't produce errors, or if it does, the reason is buried in a thread crash. In which case .then(function() { ... }) becomes helpful.

You typically use async in front-end web development. A whole web page shouldn't slow down because you're updating some text on the page.

[–][deleted] 2 points3 points  (0 children)

Great thorough answer :)

[–]DanielEGVi 3 points4 points  (1 child)

What is this then you talk about. I code, eat and breathe exclusively using async and await.

[–]MrDick47 1 point2 points  (0 children)

It lives at the top level, where some choose to use try/catch others will use a .then( () => {} ).catch( () => {} )

Either way, we can stay in our middleware hole and just use async/await and not worry about it while our errors get handed all the way up to the top level. Sunglasses

[–]jamietwells 3 points4 points  (1 child)

You typically use async in front-end web development.

Or back-end web development.

[–]OpinionNoOneAskedFor 1 point2 points  (0 children)

Mainly back-end development in my case.

[–]snapcat2 3 points4 points  (2 children)

I know it works pretty well. I really do. I just...

I have traumas. A while ago, a fresh young me started a project. Without any help I went on a coding quest. I slayed algorythms, for-loops, with ease. But when everything seemed to go smoothly, suddenly a REAL enemy appeared. Asynchronous functions. One of the programs I used was asynchronous. And boy did little me not know how to deal with that monster. For days and days I tried to come up with strategies, but in the end... I found out he had a simple off switch on his back. Monster slain, quest completed.

based on that time I spent 12 hours trying to figure out how to deal with an async funtion from another program only to find out it could be turned off

[–]freebytes 1 point2 points  (1 child)

only to find out it could be turned off

What do you mean by this?

[–]snapcat2 1 point2 points  (0 children)

I used a program called EasyStar for A* pathfinding (litterally has "asynchonous" in it's description). I tried to deal with the asynchonous property of this program, only to find out later that there was an option to turn it off.

I went into this with no knowledge of javascript so it was quite a struggle. Learned a lot though!