News for hackers. Stuff that matters.
Re:My PHP Development Setup by tylerjwilk00 on Thursday January 17, 2019 @10:09AM (#18931269)
Glad to see modern PHP getting more coverage on HN. For anyone interested in how the latest version performance compares to similar languages checkout vs Python [1] and the vs Ruby [2] pages from the benchmarks game team.

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

[2] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:My PHP Development Setup by tyingq on Thursday January 17, 2019 @11:22AM (#18932008)
The sequence of Hack/HHVM trouncing PHP performance, then the PHP team responding with a release that took the air out of Hack/HHVM for most people other than FB was interesting to watch.
Re:My PHP Development Setup by Zak on Thursday January 17, 2019 @11:41AM (#18932209)
Aside from doing well on synthetic benchmarks, what case would you make for starting a new project in PHP in 2019? What are its strengths?
Re:My PHP Development Setup by ramijames on Thursday January 17, 2019 @01:33PM (#18933211)
I think that you can count Laravel as one if PHPs strengths. It is a modern, beautiful framework that took a lot of the best stuff from Ruby on Rails and ran with it. Seriously good stuff.

If I need to build an API, or want an app with backend/frontend separation, it is my go to.

Re:My PHP Development Setup by pasta on Thursday January 17, 2019 @02:55PM (#18933990)
Some weeks ago I had to choose a PHP framework and ended up with Laravel vs Symfony.

I started the project twice in both frameworks.

And while Laravel might be the most popular one I would say you should go with Symfony 4.

Laravel just has too much magic. When your IDE doesn't know what is going on, how will you?

But whatever the choice, skip 'annotations'! It's a bad trick that will mess up your project at one point (for example if your IDE cleans up unused usages).

Re:My PHP Development Setup by furicane on Thursday January 17, 2019 @03:39PM (#18934403)
Laravel does have a lot of magic, however you can be aware of what's going on. https://github.com/barryvdh/laravel-ide-helper

Framework continues to evolve, for the better of course. With the introduction of PHP 7, I believe Laravel will get rid of magic eventually. Meanwhile, we've got tools to help ourselves.

Re:My PHP Development Setup by furicane on Thursday January 17, 2019 @11:57AM (#18932362)
PHP recently received an extension that exposes an asynchronous programming framework, called swoole. It's extremely promising (but not perfect). Here's the link https://www.swoole.co.uk/ and it produces some very, very, very interesting results - both in synthetic benchmarks AND real world. Link: https://www.techempower.com/benchmarks/#section=data-r17

In certain use cases, it literally annihilates Golang for example and leaves node.js way, way, way behind.

Now, ignoring the numbers, there are many things you can do using PHP:

- web applications

- background services

- queue systems

Imagination is the limit (but that applies to any language these days)

There's plenty options to choose from, from web-related frameworks to community provided libraries, even the command line interface received a ton of cool libraries to play with. I can't state that you can do X in PHP but can't do the same in Y, Y being another language. However, frameworks such as Laravel make it trivial to bootstrap a project, create an API, create a nice UI using Vue (Laravel comes with excellent Vue tooling) and deploy the whole thing in a few easy steps to popular hosting providers.

Granted, it's not language specific, there was a huge community effort behind everything PHP related: from standards, to package manager, to tooling, utilities and so on so the ecosystem is quite healthy and progressing.

The nice thing about it, ultimately, is that it's really fast enough and keeps getting faster, with new (useful) language features.

If you're after a tldr version and don't care about the wall of text above:

Strenghts:

- excellent ecosystem http://www.packagist.org, http://www.getcomposer.org

- excellent *nix support, easy installation: https://launchpad.net/~ondrej/+archive/ubuntu/php

- great object oriented model that supports strong typing: http://php.net/oop

- excellent choice of web-app frameworks: https://laravel.com/, https://lumen.laravel.com/, https://symfony.com/

- big choice of extensions that expose additional functionality, such as swoole: https://www.swoole.co.uk/ or zeromq: https://github.com/mkoppanen/php-zmq

- great performance for an interpreted language

- easy scaling due to php-fpm http://php.net/manual/en/install.fpm.php (this has been available for a decade)

Re:My PHP Development Setup by aasasd on Thursday January 17, 2019 @02:40PM (#18933859)
Async programming was there for a long time in the form of ReactPHP. With the caveat, of course, that comparatively few people know of it because of peculiarities of PHP's target audience. It's hard for something non-standard to gain traction in PHP.
Re:My PHP Development Setup by omnimus on Thursday January 17, 2019 @06:09PM (#18935542)
Swoole looks exactly like some node.js code. The problem is that node has promises and async await while swoole/php has only callbacks right? No other mechanism..

That makes node a lot nicer to do async.

Re:My PHP Development Setup by PopeDotNinja on Friday January 18, 2019 @10:58AM (#18940144)
I love how they embrace toy apps for benchmarking. [1] I've found that I learn a lot about writing fast code by writing a toy app, measuring how long it takes to run N times, making a small change and benchmarking the change.

I was recently playing with generating v4 UUIDs in Elixir, and it was fun to try writing code that was nominally faster than the most popular UUID library out there. It was also interesting to see how the code gets less maintainable, more repetitive, are harder to read when I started trying to shave nanoseconds off the average run time. It's also fun to start realizing that the program can't get much faster because your approaching the physical limits of the hardware.

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:My PHP Development Setup by ksec on Friday January 18, 2019 @06:54AM (#18938672)
Interesting they decide to run with Ruby JIT. Which may not be the fastest way run Ruby Script (yet). And measurement includes Startup time, which means JIT and TruffleRuby aren't really real world measurements.

But Seriously PHP has come a long way. May be there should be something that compiles to PHP? Coz Php still looks very ugly.