News for hackers. Stuff that matters.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by rubyn00bie on Saturday July 29, 2017 @11:33PM (#14884304)
Honest, sincere, question here:

How is programming in PHP these days? I haven't used the language since 4.x-5.2 or so. I wrote it off completely when Hack and HHVM came out due to the nuances between it and PHP proper (not to say either is bad, it was just another barrier, and set of choices I didn't care to deal with). I typically write Ruby, Elixir, and some JVM based languages these days. Any new features or language changes that make it more pleasant or any good use cases compared to my usual languages? I will add using it anywhere, while a valid use case, isn't something particularly attractive to me.

Edit: just wanted to say thanks for all the good comments posted so far!

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by icelancer on Sunday July 30, 2017 @12:03AM (#14884404)
It's fine. I still write a decent amount of PHP. I also maintain a Wordpress-backed CMS that processes payments and it works just fine to the tune of several million dollars per year, a figure that most people on HN start planning for concurrency, scaling, and doing tons of premature optimizations before hitting.

I helped on the HyperPHP documentation team and debugged a bunch as I wrote some machine learning stuff in PHP as an exercise in developing it with the HyperPHP translator.

I enjoy writing it. I find myself using Python more and more simply because it's easier to find better outsourcers with academic projects in their background (a niche I'm in and something that Python was literally built to service), but PHP 7+ has been great. I don't particularly care for the unbridled hate that comes with PHP historically being "bad" and also extremely popular.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by chx on Sunday July 30, 2017 @02:36AM (#14884709)
The biggest grievances stem from PHP wanting to please you and convert things from one type to another even when it really, really shouldn't. Adding variadics in 5.6, return and scalar types in PHP 7 tunes down this sort of crazy. Not fully, though. String comparison is still broken -- use strcmp() and be happy. Using anything else is dark and full of terrors. Well, at least it's not transitive https://3v4l.org/goSYX

Further, avoid == completely, pass the strict argument to functions that do comparison like in_array(). You don't want https://3v4l.org/mcpi7 to happen. You want https://3v4l.org/Yo6tI instead.

Your functions in 7.1 finally can typehint for iterable (array or Traversable object) although the array_* functions still only accept arrays. There are nice little libraries papering that over and installing libraries is easier thanks to composer.

PhpStorm gives you a fantastic IDE. The language is still ridiculously easy to deploy thanks to a zero share model.

Basically: most of the landmines can be cordoned off with putting declare(strict_types=1) on top of your files or bridged over by libraries like nikic/iter. A few are left but they are easy to avoid.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by Vinnl on Sunday July 30, 2017 @08:02AM (#14885579)
Does PHP have linters or something that force you to use the practices you described? I find in Javascript that works pretty well to restrict the language to a sane subset.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by _cereal on Sunday July 30, 2017 @08:31AM (#14885662)
You can use phpmd: https://phpmd.org/ or phpcs: http://cs.sensiolabs.org/
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by skrebbel on Sunday July 30, 2017 @12:53AM (#14884492)
Pretty independent of recent improvements, but one thing I feel people are forgetting about PHP these days is that, when given to a good hosting provider, PHP is essentially "serverless" programming, but without the vendor lock-in stuff like AWS Lambda give you. (and without the hype)

Admittedly, even on a good host it won't scale as ridiculously well as a lambda function does, but I'd wager scling from 1 to 1 million req/s in an hour and then back again is a pretty marginal use of Lambda. All the other advantages boil down to not having to manage your own server. Just deploy the code, and that's it.

Well, PHP has had this for decades. And I believe that people should really consider this when choosing a language. I don't know of any other language that you can code a backend in without thinking about servers and daemons and keeping nginx up to date, without getting vendor locked-in to something like Lambda or Heroku.

This is also why I don't really see the point of Hack/HHVM for any new product: If you're going to install some random runtime on some server as well, there's probably more ergonomic languages you can choose.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by open-source-ux on Sunday July 30, 2017 @07:53AM (#14885546)
I completely agree with you about the ease of hosting with PHP.

In fact, it's baffling that other popular languages for web development - such as Python and Ruby - have failed to address this issue of easy server installation. Developers underestimate how important this is.

If you want to sell a self-hosted solution to your customers, especially if they are small or medium-size businesses, it's impossible to offer an easy self-install solution using other languages (i.e. easy enough for non-technical users to follow instructions for install success).

Having a ridiculously easy web app installation process for servers would unlock countless opportunities for developers to reach more users or customers.

Programmer Jeff Attwood wrote about this in a critical post about PHP:

"If you want to produce free-as-in-whatever code that runs on virtually every server in the world with zero friction or configuration hassles, PHP is damn near your only option."

Attwood goes on to say we should:

"build compelling alternatives and make sure these alternatives are equally pervasive, as easy to set up and use as possible." [1]

That was written in 2012. And yet here we are in 2017 and there is still no other language that matches PHP for ease of server install, or for choice of hosting providers. I repeat: developers underestimate how important this is.

[1] https://blog.codinghorror.com/the-php-singularity/

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by wwweston on Sunday July 30, 2017 @02:40PM (#14887213)
This. When I got my first explanation of "serverless" (i.e. the details of the runtime and server are managed by the vendor for you) I almost laughed and said "Oh, like PHP on shared hosting."

I've wondered for years where else this aspect of PHP might be appreciated and show up in another ecosystem. In retrospect it almost seems obvious that it'd more likely appear in the form of convergent evolution combining another benefit that's higher status in the industry if less frequently needed.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by cthalupa on Sunday July 30, 2017 @05:00AM (#14885085)
Are you referring to shared webhosting?

Because if so, there's quite a few drawbacks. You're generally not in any sort of scalable setup, no high availability, you're on a shared box with other customers, you are susceptible to IO constraints on the shared disks, etc. You're still going to need a database of some sort for most applications....

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by bkanber on Sunday July 30, 2017 @08:03AM (#14885583)
> You're generally not in any sort of scalable setup, no high availability, you're on a shared box with other customers, you are susceptible to IO constraints on the shared disks, etc.

As you describe acceptable use-case for 99% of all projects.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by joshribakoff on Sunday July 30, 2017 @03:36AM (#14884887)
I get your point but also consider that messing around with installing php extensions and using pecl is more of a nuisance than just deploying your node_modules via something like rsync. The php community solves this by writing polyfill which seems like wasted effort (writing something in php that already exists as a php extension)
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by fredsted on Sunday July 30, 2017 @05:47AM (#14885235)
I don't think pecl sees much use now, depending on your package manager you can just install most modules from there ("apt-get install php-imagick")
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by debaserab2 on Sunday July 30, 2017 @03:25AM (#14884858)
PHP isn't serverless in the same way a lambda function is at all. You still need to host something that responds to HTTP requests and passes them along appropriately to PHP. Just because it has a share nothing model doesn't mean you don't need to provision servers. You still need to do 90% of the work.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by joshribakoff on Sunday July 30, 2017 @03:38AM (#14884896)
I think he meant you can easily find $5 "unlimited" php web hosts. So for all intents and purposes it's serverless as in you can use it on a shared web host, where you do not have to manage the server because the hosting company does it. Not that it's literally serverless. Even lambda uses servers obviously. They just abstract it away which is what he meant. Clearly all cloud offerings are backed by servers, it's just abstracted away to varying degrees
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by cutler on Sunday July 30, 2017 @08:35AM (#14885671)
For $5 a month you can get a Linode VPS with 1GM RAM. After the one-off learning curve of Docker you can image these servers and get much more for your money than what any shared hosting provider has to offer. Better still, you're not tied to PHP either.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by Can_Not on Sunday July 30, 2017 @10:53AM (#14886193)
You're missing the point. The shared PHP host can be $5-$20 per year and handle bursts in excess of 1GB (assuming you're not grossly oversold, which is also common in VPSs).
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by Lazare on Sunday July 30, 2017 @09:54AM (#14885944)
Very good, honestly.

PHP - at least if you're working on a modern 7.1 code base - isn't perfect, but it holds it's own. You do need at least one experienced person to stop you making serious mistakes (and with PHP, there are a lot of mistakes to make!), but in my experience that's true of every language.

Syntax is still a bit janky, the standard library has function names and parameter orders that seem to have been created by feeding the source code through a blender, and nested ternaries are a trap for the unwary due to their completely broken associativity rules.

On the other hand, the syntax isn't that bad, the gradual typing story is starting to get pretty solid, composer is really nice, IDE support is great, and the ecosystem is stable, mature, and deep. (And you shouldn't be using nested ternaries anyhow, come on, this isn't a code golf competition.)

As a general rule, I find the project I'm working on now to be slightly more pleasant to work on than the Python/Django app I worked on before, and significantly more pleasant than any node app I've worked on.

Five years ago, if you told me you were starting a new serious project using PHP for the server side I'd have thought you were probably making a mistake. Today, I wouldn't blink, again, not because it's perfect or the best, but because it's solid and mature and good enough.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by leeoniya on Saturday July 29, 2017 @11:54PM (#14884374)
i think PHP has the opposite problem of JavaScript - a build-in function library that's too big and very inconsistent. much of http://phpsadness.com/ remains in v7+. i tried to get them to change their long-standing, self-admitted improper ternary associativity [1] or at least deprecate it in v7 but it resulted in a huge bikeshed (despite no one actually encountering code that depended on the wrong behavior which has been discouraged for many years) and died a fast death [2]. their "if it's documented [3], it ain't broken" stance is pretty toxic and they maintain BC to a fault, IMO.

also, they've refused to implement native multi-part formdata parsing in anything other than POST requests and dont expose a good/safe way to get this done either, leaving PUT/PATCH request parsing up to the users, which is shitty and has been asked for a long time ago [4]. this means you can't rely on language-level support for basic REST, leaving it up to frameworks/routers.

it's crap like this that moved me on to other languages. PHP7 is fast though, and gets shit done. i'll give it that. i don't see any reason to start a new project with it when you can have node/js/vscode (or better).

[1] http://phpsadness.com/sad/30

[2] http://grokbase.com/t/php/php-internals/14cdp789nk/fix-incor...

[3] http://php.net/manual/en/language.operators.comparison.php#l...

[4] https://bugs.php.net/bug.php?id=55815

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vatotemking on Sunday July 30, 2017 @02:55AM (#14884763)
> i tried to get them to change their long-standing, self-admitted improper ternary associativity [1] or at least deprecate it in v7 but it resulted in a huge bikeshed

Oh man. Remember that drama in the internals when trying to remove T_PAAMAYIM_NEKUDOTAYIM ?

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by detaro on Sunday July 30, 2017 @03:05AM (#14884794)
For those that (like me) hadn't heard of it: https://philsturgeon.uk/php/2013/09/09/t-paamayim-nekudotayi...
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by kalleboo on Sunday July 30, 2017 @04:54AM (#14885070)
Thanks for that link, that was a hilarious read. Highly recommended.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by leeoniya on Sunday July 30, 2017 @03:17AM (#14884831)
the fact that you had to google it is delightfully fitting.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by leeoniya on Sunday July 30, 2017 @03:10AM (#14884807)
don't remind me.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vatotemking on Sunday July 30, 2017 @03:25AM (#14884856)
good times.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by raarts on Sunday July 30, 2017 @01:29AM (#14884559)
At least their reluctance to implement your feature requests for native formdata parsing seems to address your criticism that the built-in function library is too big.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by leeoniya on Sunday July 30, 2017 @01:39AM (#14884586)
they don't need to be functions. PUT/PATCH/etc bodies should be decoded automatically into new superglobals to match the existing $_GET, $_POST and $_FILES. if you're gonna have a shitty API, at least have a uniform shitty API ;)
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by acomjean on Sunday July 30, 2017 @12:28AM (#14884444)
Its good. We use silex/twig for development. Sites/ form processing is pretty straight forward and easy and I like the "microframework" idea of not being too opinionated.

Symfony and Zend have a large library with various functionality and you can pick and choose what you like. The php Composer lets you control dependencies easily.

The main problem is that there are almost too many frameworks and the language has a bad reputation (legacy warts from old generations). I maintain java and perl websites too, and find the php ones easier to maintain.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by frik on Sunday July 30, 2017 @03:10AM (#14884809)
PHP has some design decisions (e.g. shared nothing architecture) that used to be laughed about - nowadays it's obviously known as a big advantage - PHP can scale linearly with no overhead.

[Edit: read what Slack devs wrote about PHP, their server side is written in PHP https://slack.engineering/taking-php-seriously-cf7a60065329 and beside that Facebook uses PHP/Hack and MySQL as core tech)

The syntax is inspired by Perl and C family (C/C++ and Java) and many functions one knows from C family are inbuilt. The advantage, it's friction free, hassles about memory management, dynamic typing allows rapid development, experience, etc.

The focus of PHP is all around the web, it was the first successful language designed for the web. All inbuilt functionality has been carefully selected, everything is built in and can be used from the start. You only need to copy the files via (S)FTP or SCP to the shared hosting server (nowadays it would probably be called "server less", e.g. Amazon Lambda) and press F5 to reload the page. It's basically the easiest environment to start, and can be Sean as the successor of Visual Basic 6 as the entrance for many younger devs after 1999 in the programming world. And the good thing almost all the negative cruft of the earlier era got removed with PHP5 and PHP7 (and the compatibility is still there, old PHP4 code still runs (or with minor changes)).

Today most languages like Python, Ruby, Perl, Java, etc also offer asynchronous frameworks to let them scale a lot better - compared to them, you don't have to change your code with PHP, it was always shared nothing and is fast by default - according to benchmarks often faster than Python, Ruby, etc.

Nodejs, Go and Java offer nowadays very comparable performance (with Java and Go being slightly faster) in common benchmarks and real world. Nodejs with (vanilla) JavaScript and PHP allow for faster development - no static typing, no compiling step.

Erlang/Elixir is the latest hype. Beside some different terminology and focus around functional language parts, actors model, the inner working of ErlangVM and e.g. HHVM are not so different. The shared nothing, one thread per execution model offers similar results. ejabberd XMPP server software written in Erlang and used at WhatsApp (now part of FB) revived the interest of Ericson Erlang eco system. PHP can handle such chat services as well, see Slack. https://slack.engineering/taking-php-seriously-cf7a60065329

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vbernat on Sunday July 30, 2017 @05:50AM (#14885248)
Isn't Slack an example of a non-scalable architecture? There is a long time hard limit to the number of people accepted in a Slack channel (around 10,000 I think).
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by oblio on Sunday July 30, 2017 @08:21AM (#14885638)
Both Erlang (1986) and Beam (Erlang VM, 1992) predate PHP (1995).

And Elrang processes are not OS processes, though I get your main point.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by TomMarius on Sunday July 30, 2017 @03:32PM (#14887402)
While the language itself predates PHP, the hype doesn't.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vrodic on Sunday July 30, 2017 @05:35AM (#14885200)
Unless you are using ReactPHP it's not really for real time apps.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by wolco on Sunday July 30, 2017 @11:38AM (#14886380)
I get the sense that Laravel will come out with an async option next year based on small clues I've been seeing. It will probably end up in 5.6.

I been porting over a game from node/express to phpsocket.io. I'm finding the async server more stable.

https://github.com/walkor/phpsocket.io

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by marcusbrown on Sunday July 30, 2017 @10:48AM (#14886168)
I've been using PHP for many years now and I was very close to switch to NodeJS or Go a couple years ago until I discovered Laravel. That changed my view of PHP completely and it improved my code quality and potential by a 10x factor at least. I think that what Taylor Otwell has done in the last years with Laravel and with its ecosystem has been really underestimated. Not just for Laravel that is an excellent framework in my opinion, but especially with all the other products and libraries that he built along the way. It covers all the needs I had in building my last few SaaS products and it made my life soooo much easier.

A few examples:

Forge and Envoyer: setup and manage your VPS in a breeze and deploy your code with zero downtime.

Spark: create a SaaS product in literally a matter of minutes without having to care about all the boilerplates

Echo: real time notification across multiple channels (mail, Pusher, Slack, etc.)

Passport: OAuth2 API server as easy as it can be

Scout: Redis/Algolia search with just a couple of lines of code

Dusk: test your app easily both for unit and browser testing

Cashier: payments with Stripe and Braintree in a breeze (both for one time payment and recurring ones)

Socialite: OAuth for all kind of services (Facebook, Twitter, Google, ...)

And beside all this, there is the excellent Laracasts by Jeffrey Way that made me learn not just Laravel but PHP and JS in general in a really great way.

And I could go on talking with the great and simple queueing system, the perfect integration with VueJS that I love as well, ...

As you can see I'm a big big fan of Laravel in general and I hope that it will become popular in HN especially over time.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vesak on Sunday July 30, 2017 @03:20AM (#14884841)
PHP in general is easy to write. Philosophically, it's all over the map due to mostly historical reasons. People say that the current development team are making it better and I don't disagree. There's just so much you cannot do when the core is so shakingly built.

Still, most of the uglies of the languages can be learned and then circumvented in action or by using proper tooling.

PHP 7 followed the general trend of bringing stronger types into dynamic languages. You can now annotate function arguments with types. I believe that makes it possible to write a static type checker, but I haven't seen one yet.

Why people hate it? I cannot speak for the whole public, but I dislike the language because it let me down. My first experience with PHP is from 1998ish, when I saw it as a way superior option to Perl, and ported a web application to PHP.

After that, I learned about programming. I didn't touch PHP again until 2013, when I got a job in a PHP shop. I went there with an open mind, thinking that the programming language is one of the least important things when building products. But every step of the way, PHP somehow got in my way. It hadn't gotten better in ways I would've liked. It let me down.

Now, of course, I don't work there anymore, so the amount of fucks I give at the language is slowly declining. Soon, I'll be able to not care at all.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by tannhaeuser on Sunday July 30, 2017 @05:38AM (#14885209)
I can't answer your question, but I'll tell you why I didn't choose PHP many years ago for a web app:

1. PHP is very welcoming to beginners. That's of course a good thing, but the downside is that it's actually quite difficult to get quality answers on StackOverflow, which is rife with clueless trial-and-error answers and "Just use <completely unrelated heavy framework>, dude" kind of responses

2. PHP started out as a simplistic server-side templating/expression language; which is fine by itself, but without any kind of injection prevention is incredibly naive, and the reason for so many DDOS botnets. Of course, using embedded PHP (eg. in a processing instruction in your otherwise static HTML) hasn't been considered best practice for years. But then why use PHP at all, when this distinguished feature isn't usable, and neither is PHP a standardized language, nor is its stdlib any good. In fact, this retargetting of PHP with little or no architectural oversight (from an expression language into a full-blown app language with OOP and whatnot) seems endemic in the PHP world, and is also the case with eg. WordPress.

That said, I quite like the PHP community for their practical-mindedness and their get-stuff-done mentality.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by concede_pluto on Sunday July 30, 2017 @04:04PM (#14887535)
"Welcoming" is not a good thing. The worst thing you can do with a bunch of clueless people is make them prolific at writing code they don't realize is unreliable. We should be teaching the minority who have the aptitude and turning away the rest.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by joshribakoff on Sunday July 30, 2017 @03:32AM (#14884878)
My biggest complaint is that it's associative arrays are different than objects. So serializing and unserializing json can become a nightmare. This is easily circumvented by being careful to be consistent. But big libraries like symfony will change your json around and break things. In node it's just not an issue
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by wolco on Sunday July 30, 2017 @11:27AM (#14886319)
When you decode json there is an option to set a flag that will allow you to use arrays or objects.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by joshribakoff on Sunday July 30, 2017 @01:43PM (#14886989)
Yes I am well aware but the rest of the community didn't get the memo

https://github.com/FriendsOfSymfony/FOSRestBundle/issues/980

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by debaserab2 on Sunday July 30, 2017 @03:22AM (#14884847)
It's still kickin'.

I left the PHP world a few years ago, but I still have to go back occasionally to manage a few old projects. I recently upgraded one to PHP 7.*. It's soooooo much faster than older versions I consider it a must have for anyone working on PHP.

That said one thing I don't regret is not having to deal with composer again. It's basically a shittier version of npm, with a fraction of the speed and a fraction of the logic built in. I have projects that have installs that aren't idempotent due to weird composer caching issues. Composer is a good thing but I can't help but wonder if PHP simply isn't fast enough of a language to build a package manager in.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by wolco on Sunday July 30, 2017 @11:29AM (#14886334)
I agree built in package manager wouid be awesome.

Composer is so much faster than npm in my experience but haven't moved to yarn so I might be missing some speed.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by SergeAx on Sunday July 30, 2017 @05:17AM (#14885147)
You mean not idempotent even with composer.lock in place? Would love to see a reproducible example.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vrodic on Sunday July 30, 2017 @01:56AM (#14884611)
It's weird for me. I used to write both Java and PHP in the past.

Custom PHP framework we built took into account the way PHP is executed: you are stateless and need to setup everything on every request (runtime is fast to start with FPM and opcode cache). Namespaces based cheap autoloader worked great. No composer. We used singletons for getting the configuration and connections to DBs. There was almost no setup code that needed to be run every time other than loading .ini based configuration and connecting to the DB. Our webapp responded under 20ms (DB and Sphinx included), and I could get it to respond in 1 ms for things where we needed to be quick and didn't have to output HTML with Forms. I was really small and you could read the whole framework code in 1-2 hours. It worked with SQL in a reasonable way. You didn't have to write your SQL for simple CRUD, but for larger things involving joining multiple tables and more complex expressions we wrote native SQL.

I switched jobs, and started with Symfony 3. The thing felt like some Java framework, but poorly documented and harder to use than it should be. It had lots and lots of setup code done before handling every request. There's a whole DI framework with it's own tons of setup code for every component. And you have to do setup even though you don't use the component in that particular request. There's ways of doing lazy setup, but you still waste time to wire that up. Framework overhead can be 30-100ms. Other modern PHP frameworks have similar overhead. I know that there's PHP-PM, to save some of that work that isn't really $_REQUEST specific.

Everybody is using type hints wherever they can, and it feels as verbose as Java, but without compile time type safety, and you can't really put type information everywhere (class members for example). Even though PHP runtime has made great progress (it's probably the fastest interpreted language, and it's great it has reference counted garbage collection), it feels like language is struggling to find it's identity, with it taking a lot from Java and still coping with ugly legacy ($, having to use $this inside a class function, php.ini, features for supporting templating even though it's rarely used as a templating lang in modern frameworks).

Doctrine and it's verbosity feels very ugly to me.

Learning Python and Flask (as an example) was much more enjoyable than switching from a nimble custom PHP framework to Symfony.

I'd argue you can write fast, simple and maintainable PHP, using state PHP runtime has setup for you ($_POST, $_GET, $_SERVER etc), namespaces and a namespace based autoloader, trying to use pure functions when you can (using static classes shouldn't be a sin - just to split your code in sensible parts), and using general good practices for writing readable and maintainable code (avoid long functions, huge classes, too much block nesting, decoupling, naming things in a good way). With some conventions you can write a decent and productive framework quickly, but you could do that with a nicer language too, so what's the point?

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by Joeri on Sunday July 30, 2017 @04:37AM (#14885023)
I switched jobs, and started with Symfony 3. The thing felt like some Java framework, but poorly documented and harder to use than it should be. It had lots and lots of setup code done before handling every request. There's a whole DI framework with it's own tons of setup code for every component.

This is also the overarching feeling I get from the big PHP frameworks: Java envy. They picked an architecture which is perfectly sensible in Java, but slow by design in PHP. You also notice this in the language features being added, where gradually PHP is turning into Java. On the Java side instead there is Scala envy, with Java slowly turning into Scala.

I don't mind PHP taking good ideas from Java though, PHP 7.x is much improved and the community overall seems to be moving in the right direction: take the good ideas from Java, without taking on the worst excesses.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by cutler on Sunday July 30, 2017 @09:08AM (#14885786)
Drupal and Symfony have inherited the worst excesses of Java's AbstractSingletonProxyFactoryBuilderContainer culture. Laravel and Symfony also have a preference for docsting annotations which are even worse than Java.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by vrodic on Sunday July 30, 2017 @06:04AM (#14885284)
I've improved this comment a bit over here:

http://vrodic.blogspot.hr/2017/07/my-thoughts-on-php.html

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jchw on Saturday July 29, 2017 @11:42PM (#14884334)
PHP7 has improved life when dealing with legacy systems, but I think all in all you're better off not building new stuff in it. There are almost always better tools for the job than PHP, like Django, Rails, Go's net/http, etc. depending on the kind of thing you're writing.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by icelancer on Saturday July 29, 2017 @11:59PM (#14884391)
>There are almost always better tools for the job than PHP, like Django, Rails, Go's net/http, etc. depending on the kind of thing you're writing.

Except for the time when you are 10 times more proficient in PHP but none of those languages. Then no, none of those languages are better for the job.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by deckiedan on Sunday July 30, 2017 @12:27AM (#14884442)
It depends. I'm way more proficient in Python than anything else, but I'll still reach for PHP fur a single page template / dynamic report, or awk for some jobs, bash for others, Perl if there's exactly the right CPAN lib, ditto ruby or node, c for some jobs...

Some times a different language can so utterly change/simplify your approach to a problem it's 100% worth it.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jchw on Sunday July 30, 2017 @02:25AM (#14884665)
If you don't do very much stuff, then sure. But most people end up coding long enough that learning new things is well worth the time. It's not like it takes more than a few months to learn a new framework or language, and you get benefits beyond just the new tools.

Visual Basic is still a language that many people know better than other languages, but I'd not advise those people to stay on VB just because they know VB. And PHP is getting a fresh coat of paint but that doesn't mean it isn't antiquated - what other web based programming environments provide a CGI model where scripts are in the public directory? How many of them are HTML with directions for the actual programming language?

If PHP is intended to stand on its own as a web development language, they've missed a few bits of low hanging fruit already. Like, take HTML out of the language. Package PHP with Composer. Allow for a new app base model where apps have their own FCGI servers and routing is done in PHP. I mean why not? These are things that modern users of PHP already try to accomplish, sometimes with [ugly hacks that are prone to security issues](https://www.acunetix.com/vulnerabilities/web/nginx-php-code-...).

I don't care if people think I'm just being a hater for the sake of it. I really think PHP is a dead end, and I think that because it seems the focus for PHP development has been toward making older software like MediaWiki run better rather than make PHP a better platform overall. As far as scripting languages go, it has a history of confusing, non orthogonal behaviors, legacy cruft, bad documentation, and designs that promote or directly cause security problems. And it has such a problem with memory management that the gold standard is to simply kill the PHP instance every N requests.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by deevus on Sunday July 30, 2017 @12:53AM (#14884493)
That sounds more like all you know how to use is a hammer, so everything is a nail.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jjeaff on Sunday July 30, 2017 @01:26AM (#14884553)
More like, all you need is a Swiss army knife, and there are dozens of different Swiss army knives that can all get the job done. So use the one you are most familiar with.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by reefoctopus on Sunday July 30, 2017 @01:01AM (#14884509)
Sometimes all you need is a hammer because it's actually a nail.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by icelancer on Tuesday August 01, 2017 @02:02AM (#14898249)
PHP can do probably 95%+ of all functions of the languages you listed. The analogy doesn't quite hold.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by greenhouse_gas on Sunday July 30, 2017 @12:06AM (#14884409)
There's one thing none of those have that PHP has:

Work with off-the-shelf managed hosting.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jjirsa on Sunday July 30, 2017 @12:27AM (#14884441)
This is something programmers will never appreciate, and every small business on earth has already encountered

Go build your client's new website in go, and then spend 80 hours trying to make it work with their $5/month hosting

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by greenhouse_gas on Sunday July 30, 2017 @02:27AM (#14884672)
You can get it to work with a $5 a month VPS. The issue is more that a VPS requires constant maintenance.

Let's say my friend runs a store. He needs a website. I can:

1. Find a $5 a month shared hiding plan. As it's Shared, they don't let you start servers, so go (as well as python) is out of the picture (unless you run it as a CGI - yuck). You develops the site, sell it to him, and fix on contract. You never have to do another thing for him.

2. Get a $5 a month VPS, spend another $1 a month (or more) on an S3 backup. Ensure said backup works (try it out once in a while). Keep OS up to date.

Which is easier? Which is more maintainable?

Does anyone think that if WordPress was written in Python it would get nearly as much traction?

That's why PHP won the internet (and that VPSs were extremely expensive until a about a decade ago) - servlets where around for a long time but you couldn't run it on a shared server - made it dead on arrival.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jjeaff on Sunday July 30, 2017 @01:28AM (#14884556)
And then after you move on, be cursed for all eternity when they have to find and hire someone with go experience to fix that tiny bug. Costing them 3x as much as if it was just PHP where anyone and their brother can work on it.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by cutler on Sunday July 30, 2017 @09:00AM (#14885758)
Just switch them to a $5/mth Linodode VM and push your one-off prepared Docker image. They're now getting 1GB RAM for their money so no complaints.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jjirsa on Sunday July 30, 2017 @11:04AM (#14886231)
This is exactly the type of response I expect from people who have never done this in real life, because real small businesses don't know what to do with that linode VM, don't know what docker is, and will end up undoing it all the day they need to make a 2 line text change and their neighbor who makes those changes for them in notepad can't do it anymore
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by bdcravens on Saturday July 29, 2017 @11:56PM (#14884379)
I haven't built anything in it (and rarely touch PHP, aside from some Wordpress ecosystem stuff), but if I were to build a web app in PHP today, I'd build it in Laravel vis-a-vis "raw" PHP.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by memco on Sunday July 30, 2017 @03:08AM (#14884804)
In addition to PHP itself undergoing a lot of good optimizations a lot of tooling and frameworks have come a long way as well. Composer and most modern frameworks play much nicer in the ecosystem and it is quick and easy to get something up and running which gives access to most of the things you'd need in a webapp. I'm a big fan of Laravel personally but there's plenty of other great options nowadays.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by Can_Not on Sunday July 30, 2017 @10:49AM (#14886173)
Why would you use Django, Rails, Go's net/http, etc. when there's almost always better tools for the job like laravel, symfony, silex, rust, etc?
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by stephenr on Saturday July 29, 2017 @11:47PM (#14884354)
So, framework-vs-language arguments without any kind of explanation why are in huh?

Ok, I can dig it.

Instead of wearing sneakers you should wear cloggs or flip flops.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jchw on Sunday July 30, 2017 @02:36AM (#14884704)
If you want more detail on my position, I wrote more here: https://news.ycombinator.com/item?id=14884665
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by smt88 on Saturday July 29, 2017 @11:36PM (#14884314)
It's not a terrible experience, but it is truly baffling that anyone would start a project in it today. A good static type system is too useful and important.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by pmontra on Sunday July 30, 2017 @01:12AM (#14884531)
That's the last thing I look for when evaluating a new language.

Well, actually I came to dislike static typing so much that's a big point against languages IMHO. I concede that it would have saved me time with data occasionally going to the wrong argument/method/function but every time I understand that I'll have to type almost useless stuff like Map(<String>,<String>) I hit back and return to HN home page. Moving to dynamic typing was as liberating as moving away from malloc/free to garbage collection.

I think I could stand languages with implicit typing. All I want is not to have to annotate my code. I'm happily paying some time and tests for that.

Btw, I don't like people downvoting to express disagreement so I'm upvoting you. My +1.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by noway421 on Sunday July 30, 2017 @09:45AM (#14885908)
Thank you for the insightful comment, all of a sudden static typing increasing coding friction makes sense.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by micaksica on Saturday July 29, 2017 @11:53PM (#14884372)
> A good static type system is too useful and important.

What? A whole lot of web apps these days are built in Python, Ruby, or JavaScript, none of which are statically typed languages. Do you mean a strong type system?

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by rubyn00bie on Sunday July 30, 2017 @12:25AM (#14884438)
I assume mean strongly typed and I can agree with them to an extent. While it does add slight overhead when writing code (not enough to matter I think) it does help eliminate a bunch of errors/edge cases you'd have to unit test for in an dynamically typed language.

Though as I always say: use the right tool for the job. And for a lot of jobs dynamically typed languages and framework offer a lot to the developer.

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by deevus on Sunday July 30, 2017 @01:15AM (#14884536)
There's no concrete definition of strongly typed, either.

https://stackoverflow.com/questions/2690544/what-is-the-diff...

Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by jjeaff on Sunday July 30, 2017 @01:32AM (#14884564)
I still do my saas projects all in PHP. I mean, I'm not building NASA control software it anything, but I have incurred very few problems due to dynamic typing. Not to mention the fact that I can hire php devs for half of what a ruby dev wants these days.