Skip to content

[Feedback] Welcome to RevoltPhp 🥳  #1

Closed
@b-viguier

Description

@b-viguier

Hi there 👋 😄 ,
I'm Benoit, an enthusiast Php/Async dev, and I just wanted to give my feedback (+ questions) as proposed in this tweet.

First of all, thank you very much for all this work! Even if I have some comments about RevoltPhp design, I'm really convinced that it's an awesome opportunity for Php ecosystem to see ReactPhp & Amp teams (& friends) working together to build such library 👍 🤩

Some context

When I had to choose an EventLoop for my company internal project, I studied a lot ReactPhp and Amp developer experience (DX). I really like the EventLoop Interface in ReactPhp, but I was really concerned by the potential callback hell for my team. In the other hand, Amp use generators with a nice DX (more intuitive to read IMHO), but EventLoop is global and doesn't expose an interface (but driver does). That's why we created Tornado, a modest attempt to abstract both with the Generator approach… So, when I read the first tweet of RevoltPhp I was very curious 😄

Fibers

I'm really excited about Fibers, I think it's the perfect tool to provide a fluent DX for async processing. But surprisingly, RevoltPhp seems to use callbacks extensively… Do you consider RevoltPhp like a very low-level async layer on which we can build some Fiber-oriented libs/projects?
Nevertheless, it seems possible to rely on Fiber with the Suspension concept (example), but it seems very verbose.

$watcher = EventLoop::onWritable($stream, fn () => $suspension->resume(null));
$suspension->suspend();
EventLoop::cancel($watcher);

I was maybe expecting something like this:

EventLoop::waitWritable($stream);

Or maybe keeping the concept of Promise/Future, with something like:

$foo = EventLoop::wait(EventLoop::async(foo(...)));

🤷
Anyway, all these functions can be created from Revolt core functions, it's just to give you my (humble) opinion 😃

Combinators

Do you intend to provide some basic functions to combine asynchronous functions? Like all, race… ?
Once again, it's totally possible thanks to suspension (example), but it's not straightforward IMHO

Conclusion

That's all 😄 Of course, I would prefer to have a non-global EventLoop or an EventLoopInterface (instead of using Drivers), but I don't think it's the most important, just a matter of taste 😉
And once again, thank you for this library 👍 Even with this design, I'm pretty sure it will be very useful as a core component to other projects.
If you are curious, I created a 1-file async-library for an incoming talk, to quickly show possibilities offered by Fibers: https://github.com/b-viguier/Slip . Just for demonstration purpose, but feel free to comment 🤷

Benoit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions