Live data from Hacker News

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

yekdeveloper.com

11–20 of 158 posts

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

#11

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…

How did you reduce LoC with a move from PHP to go?

Go is a pretty verbose language, whereas for me PHP is somewhere in the middle of the pack in terms of verbosity (Haskell would be on the terse side, enterprise Java and Go on the verbose end, particularly due to the constant error-checking after every function call).

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

#12

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…

Surprised you made it more compact and not have it turn into 40k lines of if err! = nil

Ive done do rewrites of stuff in python and it gets really verbose, plus dependency injection patterns for testing.

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

#13
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…

Having been in the C# world for a long time, and the various web/api frameworks.

PHP is really nice if you dig into it, it includes so many great functions and functionality built in for creating web stuff.

It also has a number of issues,. but to quikly put something together PHP take the win in my limited opnion.

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

#15
The one thing I don't like about PHP is that the whole application is bootstraped (and autoloading and the configuration is re-evaluated) in every single http request. Sure thing there's cache and all, but it just doesn't feel right (compared, to, for instance, an http server written in golang)

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

#16
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 backend of asio libraries, so you can get pretty fast runtimes: https://github.com/walkor/workerman

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

#18
post #15

The one thing I don't like about PHP is that the whole application is bootstraped (and autoloading and the configuration is re-evaluated) in every single http request. Sure thing there's cache and all, but it just doesn't feel right (compared, to, for instance, an http server written in golang)

There are well documented and production-ready libraries that you can use to run your own servers with PHP alone, no need for fpm or mod_php. PHP's JIT is pretty impressive and you would be blown away by the results.

https://reactphp.org/

https://www.php.net/manual/en/book.ev.php

https://bitbucket.org/osmanov/pecl-event

https://www.workerman.net/

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

#19
post #15

The one thing I don't like about PHP is that the whole application is bootstraped (and autoloading and the configuration is re-evaluated) in every single http request. Sure thing there's cache and all, but it just doesn't feel right (compared, to, for instance, an http server written in golang)

It doesn't have to be. Some PHP runtimes allow an application to run in a mode where a single script execution processes multiple HTTP requests:

https://frankenphp.dev/docs/worker/

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

#20
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…

Having been in the C# world for a long time, and the various web/api frameworks. PHP is really nice if you dig into it, it includes so many great functions and functionality built in for creating web stuff. It also has a number of issues,. but to quikly put something together PHP take the win in my limited opnion.

The only reason PHP still exists is because of shared hosting companies and Wordpress.

PHP’s initial appeal was you could do scripting on the server side, “turn off PHP with a ?>” spit out normal html, and “turn back on PHP with a For a beginner programmer, it was simple, easy to understand, and had an include so your designs were’t nested table hairball messes of garbage. (but your CSS was definitely garbage).

Today, it’s so easy to run JavaScript, I can build a basic jsx site in under an hour, just like I can with PHP and includes. With Bun, I can quickly write a data access layer as well and wire up crud APIs w/ JWT auth. A weekend project in both.

Post reply on HN