Live data from Hacker News

PHP's Oddities

flowtwo.io

81–90 of 186 posts

Re: PHP's Oddities

#81
post #9

After over two decades of working in PHP, I'm now working in Java. PHP is basically Java-lite. I am absolutely loving the compile-time safety of Java, but I dearly miss PHP's maps and arrays. In Java, the amount of verbosity for defining a map/list and operating on it is overwhelming. Modern PHP is great. Many powerful language features, excellent performance, great community and package ecosystem, and decent enough…

Php has compile time safety too but compile time occurs at roughly the same time as runtime lol

I'm not familiar with PHP, can you elaborate on what you mean here? What is it compiling? Or are you referring to type safety?

Re: PHP's Oddities

#83
post #9

After over two decades of working in PHP, I'm now working in Java. PHP is basically Java-lite. I am absolutely loving the compile-time safety of Java, but I dearly miss PHP's maps and arrays. In Java, the amount of verbosity for defining a map/list and operating on it is overwhelming. Modern PHP is great. Many powerful language features, excellent performance, great community and package ecosystem, and decent enough…

All PHP needs is python's flexible and convenient manipulation of lists/dicts/objects. Plus dropping the end semi colon and it would riiiiiiiiiiiiiiiip the fabric of spacetime.

The semi colon allows you to have lots of flexibility in how you present your code, that is if you still read code, I seem to be an oddity now.

Re: PHP's Oddities

#84
post #9

After over two decades of working in PHP, I'm now working in Java. PHP is basically Java-lite. I am absolutely loving the compile-time safety of Java, but I dearly miss PHP's maps and arrays. In Java, the amount of verbosity for defining a map/list and operating on it is overwhelming. Modern PHP is great. Many powerful language features, excellent performance, great community and package ecosystem, and decent enough…

yes I say this now very often, that PHP has morphed into runtime Java. Quite nice in some ways. In PHP though the STDlib is not very well thought out, it may be fun(needle,haystack) or fun(haystack,needle) and you just have to remember empty() will do weird stuff like a string with the value "0" is also empty, so not great for parsing things. A lot of footguns and the best way to avoid that is with a decent linter th…

I have worked with countless programming languages and they all have little oddities.

Re: PHP's Oddities

#85
post #9

After over two decades of working in PHP, I'm now working in Java. PHP is basically Java-lite. I am absolutely loving the compile-time safety of Java, but I dearly miss PHP's maps and arrays. In Java, the amount of verbosity for defining a map/list and operating on it is overwhelming. Modern PHP is great. Many powerful language features, excellent performance, great community and package ecosystem, and decent enough…

yes I say this now very often, that PHP has morphed into runtime Java. Quite nice in some ways. In PHP though the STDlib is not very well thought out, it may be fun(needle,haystack) or fun(haystack,needle) and you just have to remember empty() will do weird stuff like a string with the value "0" is also empty, so not great for parsing things. A lot of footguns and the best way to avoid that is with a decent linter th…

Why not just use a proper code editor with inlay hints, inline documentation, and autocompletion instead? These things are a non-issue, unless you’re working with Notepad++ or something.

Re: PHP's Oddities

#86
post #37

Earlier quoted context omitted.

> People seem to shy away from criticism. What actual criticism of PHP is anyone shying away from? PHP got bashed for such a long time, while simply nothing steps up to do what it does better . Something that, for example, is available on every webhost you can just throw files at, where all (meaningful) config and state can be in those files.

I used to really love the dead-simple ease PHP brought to server-side dynamic web stuff too. But when shared cpanel type hosting was orders of magnitude cheaper than anything else, that was a way bigger deal. Today you can deploy a node.js app (all the same “just a script” advantages of PHP) to a half dozen places for free, and for the next step up, a smallish instance at Hetzner, DigitalOcean or whatever, where you…

> Today you can deploy a node.js app (all the same “just a script” advantages of PHP)

You still need to build a router and a web server in said nodejs script. And manage everything, including taking care that requests don't accidentally mutate global state.

PHP in contrast is stateless. Way less bs to take care about.

Re: PHP's Oddities

#87
I have not seen "PHP" listed as a language used in any Hacker News job posting in a very long time. Everything is Javascript/Typescript now, with the occasional Rust, C/C++, Golang, Python, Ruby. I never see PHP ever.

Re: PHP's Oddities

#89
post #9

After over two decades of working in PHP, I'm now working in Java. PHP is basically Java-lite. I am absolutely loving the compile-time safety of Java, but I dearly miss PHP's maps and arrays. In Java, the amount of verbosity for defining a map/list and operating on it is overwhelming. Modern PHP is great. Many powerful language features, excellent performance, great community and package ecosystem, and decent enough…

If I have an “array” and can do array[0] to get first item, but when I filter this array and array[0] throws an error, that’s super weird. What is the meaning of [] or what is an array even? The language forces me to understand how it is implemented under the hood. That’s exactly what the author says: leaky abstraction.

That also often shoots you as when json_encoding it only becomes an array when ordered "correctly" (numeric 0-based keys without gaps), otherwise an object. So to be safe you generally need to array_values after filtering. If in your testdata you only remove elements from the end you don't catch that before production data hits.

To get the first element there also is reset().

I love PHP though.

Re: PHP's Oddities

#90

I have not seen "PHP" listed as a language used in any Hacker News job posting in a very long time. Everything is Javascript/Typescript now, with the occasional Rust, C/C++, Golang, Python, Ruby. I never see PHP ever.

You must not be looking very hard because there's literally six PHP jobs on May's "Who's Hiring" list: https://hnhiring.com/technologies/php
Post reply on HN