Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HHVM hacklang async and await keywords on the roadmap #305

Closed
RdeWilde opened this issue May 8, 2014 · 8 comments
Closed

HHVM hacklang async and await keywords on the roadmap #305

RdeWilde opened this issue May 8, 2014 · 8 comments
Labels

Comments

@RdeWilde
Copy link

RdeWilde commented May 8, 2014

Now that HHVM is released with support for HACK-lang, it is possible to use new features like 'async' (http://docs.hhvm.com/manual/en/hack.async.php). What will be the impact on React?

Will React make use of these features? As I'm not very familiair with React yet, what would be important differences between React promises and Hack asyncs?

@cboden cboden added the question label May 8, 2014
@cboden
Copy link
Member

cboden commented May 8, 2014

Currently async/await are syntactic sugar (which isn't a bad thing). I asked a FB engineer how this functionality was implemented about a month ago. Their implementation is more suspended processing (like generators/co-routines) on a single core that can work with an asynchronous socket - unlike other implementations that would offload the work to a thread and be concurrently processed.

The advantage of this technique is you can make network requests asynchronously (such as MySQL), carry on execution of your code, and then choose when to block the application. Much like mysqli::reap_async_query but through a nicer and more generic interface.

Hack's async/await lets you make a request asynchronously over a network and choose when to block execution whereas everything in React is meant to be asynchronous all the time. React is run in an event loop and a notification is received and propagated when the async request is done whereas Hack is procedural and the developer decides when to block execution to wait for the response.


Given their documentation I wouldn't be surprised if Hack eventually changed the engine of async/await to offload all processing to be concurrent, but that doesn't seem to be the case today.


Promises are an object that represent a future value. They will eventually be resolved and can have callbacks triggered when they become a value.

@JordanRL
Copy link

JordanRL commented Dec 1, 2014

Interesting.

I'm currently building a very big application based on React. Basically a whole framework. I have 7 developers on my team right now that are all working to develop this application, and we plan on open sourcing it once we have an initial stable version.

Part of our architecture is that we split the Model/Domain into different servers, so we make socket connections to those servers in order to request and receive processed data from the Model.

I had been considering firing all those requests at once with async in Hacklang, and then having an await at the bottom of the controller right before it wraps everything up. It sounds like this sort of network communication is exactly what async is for in Hacklang, correct? Does it provide any sort of benefit over React's default handling of such a situation?

@cboden
Copy link
Member

cboden commented Mar 6, 2015

@no1youknowz Facebook seems to be putting a lot more into async now. I'll be revisiting it once they have streams supporting the async syntax.

@joshdifabio
Copy link

@aftabnaveed
Copy link

is ReactPHP supported on HHVM ?

@clue clue changed the title HHVM hacklang on the roadmap HHVM hacklang async and await keywords on the roadmap Feb 1, 2016
@clue
Copy link
Member

clue commented Feb 1, 2016

is ReactPHP supported on HHVM ?

Yes, ReactPHP does support running on HHVM.

(Though this issue is more geared towards taking advantage of HHVM hacklang's async and await keywords)

@clue
Copy link
Member

clue commented Jul 6, 2016

I'd like to make this actionable, so I'm wondering what needs to be done here? 👍

React runs on both Zend PHP and HHVM and it's unlikely this is going to change any time soon.

The async and await keywords are currently only supported on HHVM and we currently do not take advantage of them.

How could we possibly take advantage of them? What kind of benefits would this give us?

@clue
Copy link
Member

clue commented May 8, 2017

I'm closing this for now as it hasn't received any input in a while and I believe this has been answered. Please come back with more details if this problem persists and we can reopen this 👍

@clue clue closed this as completed May 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants