Hacker News new | ask | show | jobs
by svnpenn 2128 days ago
PHP is damn good in certain areas.

It is one of the best choices (if not the best choice) for rapid prototyping of a program. Its damn fast to similar alternatives (Python, Ruby, Dart, JavaScript), and the standard library is huge.

It does have footguns. I am not a fan of the loose typing, but you can take some steps to mitigate. You can do "===", "strict_types" and type hinting for function input and output. It is similar to C in that the language itself doesnt really do much to stop you from writing bad code. Also the function naming is not consistent, and even function arguments are not consistent. However PHP 8 will help with that somewhat, as you can now do named arguments.

Also PHP has the best language documentation I have ever seen. I would prefer more examples, but its well above some other languages.

5 comments

The creator of PHP addressed the "function arguments not consistent" issue in a YouTube video called 25 years of php.

PHP is basically a wrapper of C modules.

String functions are ($haystack,$needle)

Array functions are ($needle, $haystack)

Because that's the way the underlying modules worked. I had used PHP for a long time without realizing this.

a few of the footguns are also getting removed in PHP 8 by stricter and more consistent number to string comparisons:

https://wiki.php.net/rfc/string_to_number_comparison https://wiki.php.net/rfc/saner-numeric-strings

In addition more internal functions throw exceptions instead of notice+return false on completly invalid arguments:

https://wiki.php.net/rfc/consistent_type_errors

I can't believe named arguments aren't default in every language. TypeScript could have implemented it.
I'm with you on everything but the docs. More than once I've had to dive into the source when the docs tell me one thing but the behaviour in some edge case is different. PHP's docs are extensive, but not nearly as reliable as they should be. And don't get me started on the comments.
Regarding "best language documentation", wait until you meet Elixir. Used to do PHP before transitioning to Elixir. Elixir & community have basically taken documentation to a new level.

Other than that, PHP is rock solid when it comes to web stuff.

Do you know of any better Erlang servers? I want to get into Elixir, but the download speed is just awful:

https://github.com/erlang/eep/issues/12

Because of 5 minutes you don't go into another language?

You must be a fast learner then, when 5 minutes is too much.