Live data from Hacker News

The Rise of Hybrid PHP: Blending PHP with Go and Rust

yekdeveloper.com

101–110 of 158 posts

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#101
post #5

> In short, the modern PHP ecosystem gives us the best of both worlds: the ability to build quickly and confidently in PHP, while still having powerful options (C, Rust, Go) for performance-critical parts. This hybrid approach lets us stay productive without sacrificing speed where it matters most. I understand this for a large codebase where rewriting is not feasible. But if that wasn't the case, a C# APIs achieves…

Author here. thanks for reading my post. actually you still don't need rewrite. running php with workers (swoole, frankenphp, ...) may be as fast as node. and for typed array php has static analysers like phpstan. it support generics and typed arrays with typed comments.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#102
post #68

Earlier quoted context omitted.

Do we need to post that JS' weird things link here? Of the basics of JS, few things are sound. The "firm foundation" idea doesn't really work for JS. It might even work better for PHP, and I am saying that as someone, who doesn't want to do PHP ever again.

JS is very much a minimal language that has a handful of choices. E.g. arrays being objects with field names that are sequentially numbered integers. The initial equality operator was a mistake, but that was rectified over a decade ago with `===`. Not having a proper int type sucks and holds the language back in a number of ways, but otherwise the language is wonderfully regular. And anyone who complains about the ec…

You shouldn’t compare backwards.

Saying “at least x isn’t as bad as y” doesn’t further a discussion, it only acknowledges denial about just how bad the problems are with x.

This is particularly true when we weren’t even discussing y (in our case, Python) in the first place.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#103

Joined {{company}} when everything was using 5.4, there was a big distaste of PHP back then. But as PHP have released newer versions I'm convinced our migration away from PHP (which is just finishing) is probably a step backwards _now_ that PHP is awesome. Everyone still thinks it is like 5.x days, it really isn't.

4 years ago we have been in same situation and we choosed to continue in php with choosing version 8. so far it works for us all these years.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#104

Pasir is like frankenphp, but in Rust. Very promising, but still early in development: https://github.com/el7cosmos/pasir Which uses the following Zend API bindings for Rust: https://github.com/davidcole1340/ext-php-rs There's also all sorts of interesting experiments, like ngx-php, which basically embeds PHP via Zend API inside an nginx binary: https://github.com/rryqszq4/ngx-php And workerman, which has a hybrid ba…

thanks for suggestion. looks cool. but as you said far from production ready. we choosed frankenphp since we saw it got support by php foundation.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#106

Reminds me of how Yahoo! worked back in the day. All their display logic in PHP, with the hard business logic in c extensions.

if you know more about it, i would glad to hear which extension they did developed for business logic. i used a lot of Yahoo! in back days.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#107
post #73

When I do stuff like this, I just write the front app in the new/fast language, then reproxy the stuff not written in the fast language to the legacy app. You can even add middlewares or caching or metrics in the new app for requests going to the old one, as you can run (fast) code around both the request and the response. It’s the best of both worlds - the new app gets to see all of the traffic, but doesn’t need to…

good idea, which language you choose for that ? also with frankenphp you can just write those required apis to be really fast as go extensions.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#108

I bit the bullet rewriting my app from PHP to Go and it paid off for my company, we're talking 20K lines of PHP code, reduced to 4K lines of Go and with the added efficiency gains with it. I think some orgs just need to take the jump and plan a rewrite, add tests (easier with Go) and just do this if they are a PHP shop, I would say it's worth it. Instead of blending Rust/PHP or Go together and having an unmaintainabl…

i don't recommend rewrite in anycase (had done 2 successful rewrite before but still i don't choose that my self) and new php run times can may be really fast. you can checkout benchmarks. swoole for instance if used with all the functionalities like its specific caches may be so fast (in some cases as fast as Go)

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#109

This sounds absolutely disgusting to maintain. Where are you going to hire devs that want to work on crap like this?

as i mentioned we just choosed frankenphp which is officially supported by php foundation. also only less than 5 percent of our code base is in Go. i don't see any problem to hire developers.

Re: The Rise of Hybrid PHP: Blending PHP with Go and Rust

#110
post #107
post #73

When I do stuff like this, I just write the front app in the new/fast language, then reproxy the stuff not written in the fast language to the legacy app. You can even add middlewares or caching or metrics in the new app for requests going to the old one, as you can run (fast) code around both the request and the response. It’s the best of both worlds - the new app gets to see all of the traffic, but doesn’t need to…

good idea, which language you choose for that ? also with frankenphp you can just write those required apis to be really fast as go extensions.

Go, naturally.
Post reply on HN