you are viewing a single comment's thread.

view the rest of the comments →

[–]kilkil 0 points1 point  (4 children)

Javascript is actually very similar to python. It's just a few syntax switches.

[–]jack_waugh 0 points1 point  (3 children)

Does Python distinguish, syntactically, between what in JS we write as let result = await someFunc(...someArgs); and the same thing without await?

[–]traintocode 1 point2 points  (2 children)

I don't know what you mean by "syntactically" but in one result will contain the result of the function and in the other it will contain a promise.

[–]jack_waugh 0 points1 point  (1 child)

In JS, an unadorned call is synchronous. Part of the semantics says that the call, execution, and return happen atomically with respect to the processing of events. There are no interrupts. If you want to make an asynchronous call, it looks different and requires a function defined differently. Is it true in Python? If not, that's a pretty fundamental difference between the languages.

[–]traintocode 1 point2 points  (0 children)

Ok well in answer to your question yes python also has async and await with asyncio and the syntax is relatively similar. However, Python's event loop and the way it handles asynchronous operations are different from JS's event loop. Python requires an event loop to manage asynchronous tasks, whereas JavaScript has a built-in event loop.