5 ms·
It's becoming kind of an Enterprise language [1]. Don't get me wrong I think PHP is getting cooler, hopefully everybody catches up and the fact that You can hav
by sdfhbdf 6y ago
It's becoming kind of an Enterprise language [1]. Don't get me wrong I think PHP is getting cooler, hopefully everybody catches up and the fact that You can have a shared hosting for pennies run Your PHP code really puts it at an advantage compared to others.
[1]: https://github.com/joaomilho/Enterprise https://github.com/joaomilho/Enterprise
- dragosmocrii 6y agoLately I see myself abusing (???) types more often than ever. Before, I'd feel comfortable returning an array of structured data from a function. Now, I'm creating Value Objects to ensure my data is both valid and correctly used elsewhere. Kinda feels nice to get intellisense working too and knowing that the things that I'm trying to do with that VO are valid
- porker 6y ago> Before, I'd feel comfortable returning an array of structured data from a function. Now, I'm creating Value Objects to ensure my data is both valid and correctly used elsewhere. Same. I've written some complicated ETL/data transform processes in PHP, and used arrays because the array_* functions are so useful for manipulation. But keeping track of what keys were available was a nightmare - especially coming back to maintain the system. Like you I've switched to Value Objects. In many ways it's a pain (the intermediate representation that I'd stick into a new array key and pass to the next transformation - it doesn't belong on any of the objects; and PHP needs the equivalent of the array_* functions for objects) but knowing I can't use the wrong key somewhere makes it worthwhile.
- dkarlovi 6y agoPHPStan and Psalm support what they call "array shapes", basically you can treat the array keys as a type, similar to how TypeScript does it.
- thdrdt 6y agoBut your IDE could understand your code for years with: /* @return MyObject */ Returning an array with unknown items has always been bad practice imho.
- zaarn 6y agoYour IDE but not the PHP Interpreter, that's the advantage of making a typed return.
- philjohn 6y agothat's why I like the "shape" type in Hack - the ease of returning an assoc array, but with field and type checks enforced.
- throw_m239339 6y ago> It's becoming kind of an Enterprise language It tried for decades to be one with Doctrine, Symonfy and co, trying to copy the worst of Java EE with every single possible design pattern implemented in these frameworks, XML configuration files and co... The problem is no generics, no private packages makes PHP OO a horrible mess compared to Java (or C#).
- agumonkey 6y agoIt's a different culture. They go around the problems differently. Also the way the write programs seems simpler and leaner (composer in mind)... probably not ultra safe but a good enough ratio I guess.
- throw_m239339 6y ago> It's a different culture. They go around the problems differently. Also the way the write programs seems simpler and leaner (composer in mind)... probably not ultra safe but a good enough ratio I guess. No it's not a different culture, they(enterprise Java and enterprise PHP) both try to force some IoC container everywhere, except PHP is an interpreted language, it doesn't need a IoC container with with XML/YAML configuration files cause there is no long and costly compilation step to begin with...
- agumonkey 6y agoThat's unrelated, you can tell very rapidly how nicer a tool like composer is from most java things of this era; this is entirely cultural IMO.. you can use xml or yaml in fine or absurd ways.
- withinboredom 6y agoI’ve seen some self-balancing backed priority queues implementations, using some quirks of PHP, that are faster than the C implemented ones and faster than a “standard” implementation. Wall clock time, it’s still O(log n).
- cannedslime 6y ago
- agumonkey 6y agoPHP started to enterprise the moment they add PSRs IMO. It was no more a scripting language first. It was also at the clean OO push. Very Java like in a way.
- im3w1l 6y agoI really like the idea of different types of comments for usage with external tools.