3 ms·
The problem is this page advertises Laravel, not PHP. Ruby on Rails has many similar "demo worthy" snippets that make complex tasks seem readable and intuitive
by BulgarianIdiot 3y ago
The problem is this page advertises Laravel, not PHP. Ruby on Rails has many similar "demo worthy" snippets that make complex tasks seem readable and intuitive to the layman. Laravel and Ruby on Rails have something else in common: due to the focus on these "natural" interfaces, they compromise in every other way. Architecture, performance, testability and so on and so on.
For those who know PHP, this code is full of singletons masquerading as static classes (which Laravel incorrectly calls "Facades") which mean no isolation and clear flow of dependencies in your code. In a nutshell, every line of code you write this way comes loaded with a pound of irreducible, unfixable tech debt. Enjoy.
- simonhamp 3y agoMaking "complex tasks seem readable and intuitive to the layman" is no bad thing - besides other engineers, future you could become a 'layman' easily. Readable, expressive code is something I've come to value highly after almost 20 years And from first-hand experience, while the specific code sample shown on this page shouldn't be treated as a practical example of how to architect a larger application, there's nothing compromised here in terms of performance or testability. All tech is tech debt at some level or at some time - what has happened to pragmatism? Laravel has actually helped me write the most performant, tested and least-refactored code I've ever written. Like any tool, used properly it will do its job well; simply grumbling and shooing it away does not stop it being a perfectly fine tool in the right hands.
- BulgarianIdiot 3y agoI guess I wasn't clear enough? I said "it makes complex tasks SEEM". My point being, they SEEM SIMPLE in a DEMO. But in real application it quickly turns into a quagmire, due to the problems I already listed. Oh look, you even say so in your own comment: "the specific code sample shown on this page shouldn't be treated as a practical example". So... you're saying the page makes it SEEM simpler than IT IS, hmm? Is this what you were asking me about "why is it bad"? You don't think parlor tricks in demo code is a bad thing? So what are you even objecting to here? I said something bad about Laravel, and you use Laravel, so you have to go on the offensive out of loyalty? I don't know why people need to identify so religiously with their tools. If we start picking apart this demo code, you'll probably admit that every line contains an anti-pattern you'd avoid in a real project of more than a modest size. So what is this demo demoing then? It's essentially misleading people about what it takes to write a good app. If we'll go by simple demos alone, PHP needs no framework at all for a good demo: <?php echo "5 + 5 is: " . (5 + 5); Boom, everyone understands this, now you can write your own Google! This is why RoR declined and it's why PHP with Laravel and WordPress as their poster boys is declining. PHP itself is no longer as terrible as it used to be, although all the good people seem to have left the internals. But the frameworks people use on it are terrible, incompetent and aggressively misleading people into bad practices for the sole purpose of marketing to newcomers.
- minusf 3y ago5 + 5 = <?= 5 + 5 ?> why use echo? php _is_ html :D
- psihius 3y agoI have one name for you: Symfony More or less directly opposite of what Laravel is preaching. It's the popular choice for anything that is being build long term. It is very popular in Europe and we have a far bigger community around it than Laravel does.
- BulgarianIdiot 3y agoSymfony made many architectural mistakes early on, including with the way they used to do injection and so on, but to their credit, the community seems curious and strives for quality, so over time it has become a very interesting project. I stay away from frameworks, in general, but the Symfony components are excellent.
- lostdesign 3y ago> , they compromise in every other way. Architecture, performance, testability and so on and so on. Architecture: The default structure of the app is good to start out and can be changed at any time. You are not locked into that. If you apply your fancy patterns, you can do whatever you want. It's rather a devs fault than the frameworks fault. Performance: Guess depends on what you compare it to. Surely a rust service will be more performant, however you can scale laravel just fine if you are not writing shit code. There is enough apps built in laravel that handle more load than the average pro reddit coder will ever see. Testability: Not sure what you mean, you can test in different ways and anything you need to test. It's fairly simply too. Yes, there are sometimes issues where you can run into memory leaks but those can be fixable after some digging. You can but don't need to use facades, you can go full DI, you can swap the IC. The Irreducible, unfixable tech debt is created by the developer that wrote it and does not know php or laravel. Yes, laravel makes it easy for newcomers to get right into the traps you mentioned, but then again - we are talking about junior that would not know any better and probably would fail without it.
- BulgarianIdiot 3y agoIf you use facades there's no fixing that unless you reconstruct and reweave every component in your application to pass relevant context in and out, instead of lazily reaching into globals for it. What you call "full DI" in Laravel is still globals in disguise, because there's a single global container. Most defense of Laravel comes from people who have no idea how to write a good app. And unfortunately, due to bad frameworks, the number of those people is multiplying. I blame Spring and RoR. So much pain came from them. Laravel is just a pale copy.
- sjamaan 3y ago> In a nutshell, every line of code you write this way comes loaded with a pound of irreducible, unfixable tech debt. And worst of all, you are stuck with a shitload of churn every time a new Laravel version comes out. But this is true for Rails and CakePHP and probably many others as well. At least Django seems to be moving a bit slower and not deprecating loads of features on every release.
- BafS 3y agoAbsolutely, having worked with Laravel I can only recommend not to use it, Symfony does a much better job.