Live data from Hacker News

Go with PHP

gowithphp.com

271–280 of 532 posts

Re: Go with PHP

#271
post #232

Earlier quoted context omitted.

PHP has matured and has been a nice language for a decade now. But PHP developers havent. Cargo culting “good practice” and lack of creativity plagues the community. Frameworks have become so heavy that you spend more time configuring them than actually adding value. Oh and some still argue over setters and getters.

> Oh and some still argue over setters and getters. Serious question, what does that argument consist of ?

Whether to use them or not. Petty endless debates over their benefits and drawbacks. Literarily for as long as i worked with php devs in all teams there was someone debating this pattern. As php is not strongly typed these can help with data type validation, can perform some logic when setting values, while others say it’s inefficient as thats an unnecessary method call, or that no logic should be performed in them. Some prefer to use magic functions instead of setters and getters others are against it because it makes the code difficult to maintain, some say they should only be used for data entities, others want to use them for every property, some prefer them because you can rename properties while maintaining external accessors, others against then because of consistency, some argue over what naming convention is best, some want to persist data in some type of storage when making updates, some attach observers to them and so on.

Bottom line is that the language being so flexible, unassuming, and swamped by needless features almost everything can be debated the point of exhaustion.

Python, being more straight to the point and not overkilling oop allows for more focus on doing what matters: business logic.

Re: Go with PHP

#272

> It can handle more than 500,000 orders per month How many seconds in a month? 60 * 60 * 24 * 28 = 2,419,200. So basically, its performance is at least 0.2 requests a second...

I help with an open studio event. We maxed out last weekend at about 350 visitors per minute (about 30%Wordpress and 70%custom php symfony pages) on shared hosting. We have a cdn helping with images and such.

Re: Go with PHP

#273
post #178

Earlier quoted context omitted.

Unit testing

Unit testing is a poor mans compiler. Our medium size rails app has 40,000 unit tests and constantly we have issues where an updated library changed the name or parameters of a method without warning causing breakages.

Yikes. Is there a static analysis tool for Ruby (along the lines of MyPy or PHP Stan) that could have caught this?

Also, out of curiosity, are all of those tests hand written, or is there some generation in there?

Re: Go with PHP

#274
post #93

Earlier quoted context omitted.

Don't you dare to tell me that my isomorphic Node trpc graphql with redux and sagas on top of next.js with SSG and SSR and parts in server components with my home grown validation and ORM framework and still no translations because they don't work together with everything else and deployed on serverless docker lambdas to a kubernetes cluster is over engineering a landing page with a contact form. So fast! That's a st…

You described the marketing website of my previous employer.

And the marketing website of many others. It’s not a joke. Pure real life.

Re: Go with PHP

#275
post #219
post #132

Earlier quoted context omitted.

> It's actually a bit of a red flag to me these days if a developer turns up their nose at PHP. Depends on the reasons. One good reason for preferring another language is .NET/Java business app developers can earn a lot more here than PHP developers ;)

Oppositely: not being able to articulate the problems with PHP/Laravel compared to a stack of say Kotlin/Ktor or C#/MVC or Java/SpringBoot is a red flag too in my book.

Have worked at a few places where PHP was dumped on because “it doesn’t have threads”. The dumper-folks were also noted to be for spending most of their time trying to fix threading issues (Java, usually). Saw this in person twice, have heard similarly from other colleagues over the years.

Re: Go with PHP

#276

For me the best platform is one that's easy to debug and the debugging story for php is one of the worst. Otherwise it would still be quite hard to read. But at least it's cheap to host.

xdebug is pretty okay. PHP is single threaded, the entry point well defined, var_dump/die/echo works wonders, debugable by curl and simple php -S nowadays.

it has orders of magnitude less complexity than the JVM, or even the various Python server runtimes (gunicorn, uwsgi, etc)

at least in my experience. can you elaborate on what you see as the debug support deficiencies of PHP?

Re: Go with PHP

#277
post #215

Earlier quoted context omitted.

But that’s kinda their point… you spend time configuring the framework instead of reimplementing from scratch and doing the plumbing yourself.

The issue is that there is so much configuration that it’s basically coding. PHP frameworks are all bloat. It would have been much better to abstract things in a way that you actually spend time on features not thousands of configs.

Then use lumen, it comes with laravel.

Re: Go with PHP

#278

> Read the following code as if it were a documentation page: If I read this as a documentation page, this makes me scared: `Order::create($validated + ['status' => 'pending']);` What does it mean to add an array to something?

Exactly the same as the spread operator in JavaScript or even the exact same syntax in Python, but we don't hear you complaining about those, do we?

> the exact same syntax in Python

No, because the example is showing concatenation of associative arrays. In Python, you'd use a dict, and you can't do `validated + {'status': 'pending'}`:

``` >>> validated = {} >>> validated + {'status': 'pending'} Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'dict' and 'dict' ```

You can do `validated | {'status': 'pending'}` since 3.9, though. I think using union or the * operator (e.g. `{*validated, 'status': 'pending'}`) looks less weird, but if you're a PHP programmer, you already know what + does here. In the end, it becomes bikeshedding.

Re: Go with PHP

#279

For me the best platform is one that's easy to debug and the debugging story for php is one of the worst. Otherwise it would still be quite hard to read. But at least it's cheap to host.

Not sure what exactly you refer to with "debugging", but I'm personally much happier with XDebug in VSCode, spamming my breakpoints and stepping through the code inside of the editor where I edit the code.

I can set breakpoints in my react app too, but it feels weird to inspect code in the browser console. And since modern frameworks get compiled for the browser, it is all even less familiar at a glance.

Re: Go with PHP

#280

Earlier quoted context omitted.

Gotta love engineers. 45 minutes of reading 12 years of someone’s work and the first thing they say is “yeah I’d rewrite it”. Every. Dang. Engineer. It’s crazy. I try to work in a codebase for 3-6 months before coming to any wild conclusions. Usually you find that there’s some warts but it does the job and there’s complexity that was solved that you hadn’t originally noticed, and it’s not worth rewriting it just need…

A clean rewrite is almost always going to produce better code than what already exists in a project that has grown organically. The current project has had numerous iterations on requirements over the years, changes in project leadership, paradigm fads come and go, and all that time accumulating cruft and layers. Looking at it at a single moment in time, you have a fixed set of current requirements where all the disc…

a rewrite from scratch is a pipe dream for almost everything bigger than "hello world".

just ask WordPerfect.

any kind of home grown business app will have corner cases and requirements spaghetti that would take much more time to figure out than to write actual code.

and if the person asking you to do a rewrite just shrugs when you ask "where is the test suite?" walk away asap.

Post reply on HN