Live data from Hacker News

Moving from Go to PHP Again

dannyvankooten.com

31–40 of 371 posts

Re: Moving from Go to PHP Again

#31
post #2

For the kinds of applications people tend to build in PHP, PHP is probably a better choice than Go. I'd still do Django or Rails before PHP, but Go just isn't designed to make serverside-rendered database-backed websites especially pleasant to write.

Flask is a good alternative to Django for building web apps with python on the backend. If I'm using react or vue with a JSON API, I don't need the form support in symfony or django.

However, deploying a Flask/Django/Rails app still is usually less fun than deploying a PHP app of the same spec written w/ Symfony or Laravel.

Configuring a service to monitor gunicorn, which itself took a bit to configure, before I begin configuring NGINX or Apache... it's really a pain in the butt.

LAMP/LEMP stacks just... are

Re: Moving from Go to PHP Again

#32
post #9

> Honestly, Go is great. Its simplicity is refreshing and its performance unmatched. I would still pick it if we need a small API or something that requires high throughput. I wonder which part is performance unmatched? My opinion would be Crystal language for its simplicity and higher throughput but unmatched performance is behind Rust and C.

Not sure about the OP, but for many Go is the only compiled language they ever used, so they get to attribute features to Go that aren't that unique of it.

Re: Moving from Go to PHP Again

#33

Why not try out Hack? It's kind of a cross between PHP and Go. Hack has a real type system, and HHVM is incredibly fast.

Perhaps because they don't want to incur technical debt to a language/runtime that could change at the whim of one company that probably doesn't have other companies' best interests in mind?

The speed advantage of HHVM has also been largely erased. Some high-profile PHP sites migrated to HHVM before and up to ~2015, but I haven't heard of a single site doing that since PHP 7.0 came out.

Re: Moving from Go to PHP Again

#36
post #13

Each PHP file is an endpoint. As opposed to having routers in code or client side SPA routing. PHP files can be deployed independently, swapped out or updated live. No building/compiling of the php files needed. A single layer as opposed to 'modern architecture' where there's client side back/front end layers, api layer, logic, validator, data access, and ORM layers. Can extend itself as it runs. For example Wordpres…

Apache MultiViews makes pretty URLs easy.

  www.example.com/widgets.php
can be reached at:

  www.example.com/widgets
But here's the kicker:

  www.examples.com/widgets/123
will also route to widgets.php, with "/123" in the $_SERVER['PATH_INFO']. No mod_rewrite needed.

  www.example.com/widgets/you/can/have/multi-segment/paths
goes to widgets.php too, with its PATH_INFO set to "/you/can/have/multi-segment/paths", but I don't usually go that far. Usually the script name roughly corresponds to the name of a table (or database view), and the PATH_INFO corresponds to the primary key.

Re: Moving from Go to PHP Again

#37
post #14

Is there any way to test php code the same way a compile phase does in other languages to catch obvious mistakes from hitting your users?

PHP 7 has type hints and a strict mode. Probably as close as you're going to get. It prevents execution from the interpreter.

Re: Moving from Go to PHP Again

#38
post #3

Earlier quoted context omitted.

I have not written a new PHP app in years but recently I had a look at the latest and greatest from the PHP community and its pretty good. The frameworks and tooling look about as good as you will get anywhere and PHP appears to be fast now.

Symfony and Laravel are really nice. It's still a horrible abomination of a language that invites bugs and requires A LOT of care to not produce buggy code, though.

Does it? If you declare strict, use strict comparison operators and typehint your arguments and returns, what more care do you need? These are not particularly onerous, the strict declaration is trivially templateable in any editor as it's the first line, you'd write types in any language and getting used to only use === !== and forget == and != is ... easy?

Re: Moving from Go to PHP Again

#40
post #11

Can relate, after 7+ years I am again using WordPress and PHP again. I am impressed by PHP 7.

Hm, I hate to be on the bandwagon, but why WordPress? One of the things that has made PHP become what it is today is a focus on good software engineering and the introduction of language features that are required by that. WordPress did not keep up on the engineering front and there are so many amazing options out there now for well written, well engineered platforms. Even in pre-built blog platforms. You're not alon…

Projects like https://roots.io bring modern PHP practices to WordPress development.
Post reply on HN