Live data from Hacker News

Moving from Go to PHP Again

dannyvankooten.com

81–90 of 371 posts

Re: Moving from Go to PHP Again

#81

Earlier quoted context omitted.

Its a quirky little language and the early versions weren't great. The language can be inconsistent in places, and embedding php in the html made for a rapid though sometimes trying experience. Its keeps backward compatibility which keeps those quirks in there. (though with new 7 series php versions older stuff is starting to break.) Someone wrote an article with a title like "php a language with terrible design" tha…

"and embedding php in the html made for a rapid though sometimes trying experience." Funny, that is React/JSX's biggest sell

JSX adding HTML literals to JS is fundamentally different than embedding PHP in HTML.

Re: Moving from Go to PHP Again

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

> For example Wordpress, running off of php files can download plugins to its own server (which are just more php files) to instantly extend itself. Without restarting or redeployment. (What other web platforms can do this?)

I'm quite sure you can achieve this in golang with plugins[1]. That not as flexable as PHP, mainly because it involves a static type system and a compile phase (and more work in general).

1: https://golang.org/pkg/plugin/

Re: Moving from Go to PHP Again

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

> Each PHP file is an endpoint. As opposed to having routers in code or client side SPA routing.

I mean that's just how CGI works, most every HTTP server still supports CGI, nothing stops you from deploying that way. Unless you're using Java or the like of course, then it's not very convenient.

Re: Moving from Go to PHP Again

#84
post #54
post #49

Earlier quoted context omitted.

I inherited a Symfony2 app and it was a bitch to deploy. It definitely had an asset pipeline. php app/console cache:clear --env=prod --no-debug php app/console assetic:dump php app/console cache:warmup --env=prod --no-debug chown -R apache:apache . # fix owner chmod -R u=rwx,g=rwx,o=rx app/cache # fix cache perms apachectl restart # bounce Apache, otherwise it can throw segfaults

That chown looks super suspect. Usually you wouldn't want the webserver to have write access to the web application it is executing; that's how you get backdoored.

This is my concern with things like the Wordpress auto updater, but it seems the trade off is not having to worry about manual patch management. Security vs convenience as always.

Re: Moving from Go to PHP Again

#85

[deleted]

To be clear, this just means that PHP has libsodium as an official language extension. Most modern languages have better package management than PHP and make pulling it in as a library trivial. This has nothing to do with homomorphic encryption, unless I'm missing something.

  composer require some/library
That's PHP's package management. What's so non-trivial about that?

Re: Moving from Go to PHP Again

#87
post #54
post #49

Earlier quoted context omitted.

I inherited a Symfony2 app and it was a bitch to deploy. It definitely had an asset pipeline. php app/console cache:clear --env=prod --no-debug php app/console assetic:dump php app/console cache:warmup --env=prod --no-debug chown -R apache:apache . # fix owner chmod -R u=rwx,g=rwx,o=rx app/cache # fix cache perms apachectl restart # bounce Apache, otherwise it can throw segfaults

That chown looks super suspect. Usually you wouldn't want the webserver to have write access to the web application it is executing; that's how you get backdoored.

The chmod is pretty suspect as well.

Re: Moving from Go to PHP Again

#88
post #42
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 Static Analysis Tool ( https://github.com/phpstan/phpstan ) is pretty good at surfacing that kind of thing.

Phan (https://github.com/phan/phan) is another one.

Other potentially useful tools:

- PHP_CodeSniffer (https://github.com/squizlabs/PHP_CodeSniffer)

- GrumPHP (https://github.com/phpro/grumphp)

- PHP Mess Detector (https://phpmd.org/)

Re: Moving from Go to PHP Again

#89
post #64

Earlier quoted context omitted.

You can create a mess of code, open security holes, and/or be hit with ‘gotchas’ in any web framework. PHP is much less complex than most.

These are things very specific to PHP. Yes, there are language-specific gotchas in many environments. But I'm criticising specific things that do exist and that I've seen causing issues in real deployments. Things that make PHP accessible make it also an excellent footgun.

So.. what you're trying to highlight is that a language is supposed to make up for the incompetence of the person using it?

Re: Moving from Go to PHP Again

#90
post #33

Earlier quoted context omitted.

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.

> 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? How is Go any different?

Go has been well received outside of Google. Wikipedia even has a list of companies known to use Go. I'm not sure how up to date it is, but the list includes Cloudflare and Netflix. At least some of them might have the oomph to fork, take over, or otherwise influence Go if Google ever dropped the ball.

Meanwhile, I can't think of any major online service that relies on Hack apart from Facebook and its subsidiaries.

Post reply on HN