News for hackers. Stuff that matters.
Re:My PHP Problems by viraptor on Monday February 19, 2024 @07:21AM (#39428971)
Huh? This article is talking about very similar issue to the fractal of bad design. Down to repeating specific ones like json_decode(null). Most of the fractal post still applies. The themes of surprises and consistency are strong in both.

I agree that the language evolved since then, but the main categories are still not solved in the language. Nice frameworks just hide those well.

Re:My PHP Problems by bemusedthrow75 on Monday February 19, 2024 @07:29AM (#39429037)
The thing that I think PHP developers hate most about the Fractal of Bad Design article is hearing it from full-stack JS developers. They really do not have the moral high ground.

PHP has improved since in a way that is rarely considered when reposting it, but JS has some deep language horrors of its own still, and many novel JS horrors like NPM have emerged largely since the Fractal article was published.

As the King sang, so eloquently: o/~ clean up your own backyard o/~

Re:My PHP Problems by crabmusket on Monday February 19, 2024 @05:56PM (#39435826)
As someone who writes PHP and JS professionally every day, I think they're leagues apart.* Sure, people love to look down on JS, but its fundamentals are much stronger than PHP's.

PHP is no longer a terrible language- recent editions have made leaps and bounds on language features, and the ecosystem around Symfony is great. But on a weekly or monthly basis I run into something that makes me want to head-desk.

JS's recent(ish) language improvements like `let` and ESM have been much more fundamentally significant than PHP's IMO, where we're still stuck with bad scoping and Java-brained class autoloading.

*Not leagues apart in terms of productivity. I can certainly get a lot done with PHP. I mean leagues apart at their foundation, the basic concepts at work in the language. Most of that can be ignored until it rears up to harass you. Here's a great example of something similar to an issue that bit me last month:

https://stackoverflow.com/q/3307409

Re:My PHP Problems by asddubs on Monday February 19, 2024 @06:33PM (#39436137)
I actually think the opposite is the case. let is nice, but javascript has no typing whatsoever. The PHP type system isn't perfect (with a lack of generics being the biggest pain point), but in javascript you just have to annotate and pray (or use typescript and compile it back to javascript, hoping people interface with your code correctly). And PHP has a dedicated string concatenation operator, which has helped it avoid horrors like '2' + 2 = 22 that javascript has to offer. Javascript will just straight up let you add properties to any object on purpose or by accident, which is useful for polyfills but also fucking horrible for bug avoidance and an invitation for less restrained individuals to make true abominations.
Re:My PHP Problems by crabmusket on Monday February 19, 2024 @07:16PM (#39436484)
All of those things I see as productivity issues, not language fundamentals. TypeScript solves types in JS for me the way Laravel solves superglobals in PHP.

Adding properties to an object is fine IMO. Arbitrary properties and prototypes are, to me, a much cleaner system than PHP's somewhat confused mix of array, object and class. The lower you go in JS the more unity of concepts there is, whereas the lower you go in PHP the more hacks you discover.

All of the above said, I would prefer a string concatenation operator to overloading +. JS template literals mostly solve that for me in practise. And what I really actually want is an equivalent of Haskell's <> or mconcat, which concatenates anything monoidal - strings, lists, etc.

Re:My PHP Problems by rafark on Sunday March 03, 2024 @02:30PM (#39583625)
> As someone who writes PHP and JS professionally every day, I think they're leagues apart.

As someone who’s written a lot of php and JavaScript, I think the same thing but in the opposite way. JavaScript just can’t compare when it comes to designing a complex OO system.

Re:My PHP Problems by otabdeveloper4 on Monday February 19, 2024 @08:01AM (#39429288)
Nitpicking on trivialities is pointless.

Rather, point out the fact that Symfony is a framework that relies entirely on all sorts of magic behavior, and at the same time it is entirely undocumented.

One of the most horrible programming experiences I've ever experienced.

PHP is a nice language, but the community is insane.

Re:My PHP Problems by kingofthehill98 on Monday February 19, 2024 @08:09AM (#39429353)
Just out of curiosity, when was the last time you worked with Symfony?

The framework has changed massively after the earliest versions (1~3). These days it's very similar to Java's SpringBoot. After scaffolding all you get is a thin layer with the HTTP abstraction, configuration support, reflection-based Dependency Injection and a testing framework (PHPUnit).

Since the framework is component-based you pull dependencies as you need them. I find the documentation really good and honestly I don't see much magic in it, it's an event-based web framework. Laravel and it's facades on the other hand is very magical.

Re:My PHP Problems by withinboredom on Monday February 19, 2024 @09:30AM (#39430083)
Symfony is not great, but most people utterly misuse it so you end up with spaghetti and ground mud. That being said, Symfony is the most popular framework I know of that liberally uses goto statements.
Re:My PHP Problems by alecsm on Tuesday February 20, 2024 @12:58PM (#39444468)
I haven't worked very much with Symfony but I've never seen a goto. In fact, the last time I've seen a goto statement was maybe 15 years ago in a mIRC script.

Where are those goto statements? I'm asking out of curiosity to check them.

Re:My PHP Problems by withinboredom on Tuesday February 20, 2024 @02:15PM (#39445561)
The nice thing with GitHub, is that it’s literally a search away:

https://github.com/search?q=repo%3Asymfony%2Fsymfony+goto&ty...

I highly recommend learning how to use it.

Re:My PHP Problems by lmm on Monday February 19, 2024 @07:32PM (#39436604)
> These days it's very similar to Java's SpringBoot.

That's not a positive. Spring Boot is impossible to use for anything except an unmaintainable abomination, since the whole thing runs on undocumented magic.

Re:My PHP Problems by conradfr on Monday February 19, 2024 @09:37AM (#39430171)
It is actually documented, surely you must be confused?

You have the docs with extensive examples, you have a free book, and the whole framework is typed and all configuration options and the individual components referenced: https://symfony.com/doc/current/index.html

And if you use PhpStorm with the Symfony plugin almost everything gets intellisense.

Re:My PHP Problems by otabdeveloper4 on Monday February 19, 2024 @10:37AM (#39430908)
I don't use PhpStorm.

Also, random code snippets that may or may not work is not documentation, much less is it a reference.

Re:My PHP Problems by conradfr on Monday February 19, 2024 @12:54PM (#39432635)
I don't get it, what more from the docs do you need?
Re:My PHP Problems by gamblor956 on Monday February 19, 2024 @06:52PM (#39436301)
I think his complaint is that a lot of the Symfony docs don't simply say what things are/do, they instead inform via examples. Which means you have to parse the examples first to understand what's going on.
Re:My PHP Problems by otabdeveloper4 on Tuesday February 20, 2024 @03:26AM (#39439118)
Yes, "documentation" implies a curated and complete reference, not a collection of code snippets that may or may not apply to your current problem and version of Symfony.

(No, random posts oт Stackoverflow and generative AI responses aren't a replacement for documentation either.)

Re:My PHP Problems by conradfr on Tuesday February 20, 2024 @07:17AM (#39440361)
But ... there is all that, right there on the documentation page, just ... scroll?

https://symfony.com/doc/current/index.html

Re:My PHP Problems by kingofthehill98 on Monday February 19, 2024 @07:44AM (#39429139)
Honestly I don't see it that way.

The blog author makes solid points that I agree. Meanwhile AFOBD just make fun of stdlib inconsistencies and of language quirks, most of which were fixed throughout the years.

AFOBD is so incredibly outdated that this paragraph is still there: "PHP is naturally tied to Apache. Running it separately, or with any other webserver, requires just as much mucking around (possibly more) as deploying any other language.".

Re:My PHP Problems by zanellato19 on Monday February 19, 2024 @08:09AM (#39429351)
Some of the points are outdated, but the soul of the article, that those stdlib inconsistencies and language quirks as you called it, lead to terrible design and a lot of surprising footguns, is still quite true. Laravel is a good framework and it is because it hides a lot of PHP from the user.
Re:My PHP Problems by yurishimo on Monday February 19, 2024 @08:37AM (#39429577)
In php 8.3, there is a new json_validate function! Stuff changes, it just takes a bit of time. Luckily, the core maintainers have been putting out steady releases every year and old versions are being deprecated on a rolling 3 year cycle. It doesn't solve the historical problem, but hopefully it enforces better habits for the ecosystem moving forward.