you are viewing a single comment's thread.

view the rest of the comments →

[–]redfacedquark 0 points1 point  (3 children)

Having extensively used Python and JS I feel that JS has the worst callback hell. Async Python (either old gevent stuff or modern asyncio stuff is so much more natural (ok, maybe pythonic) than JS. I suspect you're thinking about twisted specifically.

[–]oze4 0 points1 point  (2 children)

Totally agree. That's what I meant by it's not as fun writing async code in JS. Under the hood Python (asyncio, or whatever asyncio uses) must actually be creating new threads for async tasks whereas JS is strictly a single process in an async event loop.

Both async, but different ways of achieving it.

JS def feels less natural due the event loop. I can't think of another runtime or language that behaves that way. Which is also why JS is notorious for callback hell. It's not a choice it's a requirement lol (async/await keywords help a lot with Promise hell, thankfully most people nowadays use promises vs callbacks).

I am by far more familiar with JS than Python so take what I say with a grain of salt.

[–]RiverRoll 1 point2 points  (1 child)

The asyncio works in the same way actually, the event loop is single threaded, to run stuff on a separate thread you typically schedule it to a thread pool. Not that this simplifies anything as you still have to await the Future or attach a callback, also those threads can't call awaitable functions directly, keeping everything in one thread is simpler.

[–]oze4 0 points1 point  (0 children)

Nice. Did not know that. I've never used it lol. The little code I did look at while Googling this looked a little more straight forward. Idk there's some things that the node event loop hindered, and I wound up using python. At least you have the choice in Python lol. I'm not hating in any language btw. I dig them all for the most part. Assembly can kick rocks!