←back to thread

PHP 8.5

(stitcher.io)
201 points brentroose | 1 comments | | HN request time: 0s | source
Show context
calpaterson ◴[] No.45989855[source]
A lot of people are too proud to be associated with PHP. I am ready to admit that know nothing about the language except that a lot of people make cool things with it.

My favourite PHP product at the moment is BookStack (https://www.bookstackapp.com/), a really good wiki. I run an instance for my family and it's great.

But there are loads of things. And I notice that many of the sites I like using...are built on well maintained PHP stacks.

replies(7): >>45990114 #>>45990185 #>>45990866 #>>45991594 #>>45992053 #>>45992060 #>>45992901 #
nusl ◴[] No.45990185[source]
PHP is a very pleasant and straight-forward language to work with. I enjoyed my time working with it, though I did also see quite a lot of very poor code.

I think the danger with PHP is more its ability to easily cause *very bad things*.

This would partially be poor training (my University literally taught PHP with SQL-injectable examples), and I think the language itself making it very easy, such that less-experienced developers using it - most of them, early on - don't realise what's wrong until it's gone wrong.

With PHP being such an early tool online, and the above properties existing, it earned a reputation for being insecure and bad.

replies(3): >>45990227 #>>45990549 #>>45992539 #
ale42 ◴[] No.45990227[source]
> I think the danger with PHP is more its ability to easily cause very bad things.

Is there any language where you can't?

replies(2): >>45990242 #>>45990291 #
jojobas ◴[] No.45990242{3}[source]
Probably not, but not most languages are not inviting to do them.
replies(1): >>45990256 #
s1mplicissimus ◴[] No.45990256{4}[source]
Give me an example where PHP invites developers to do terrible things and I'll show you 2 other popular languages that invite equally bad or worse things :)

Or as Bjarne Stroustrup put it: There's two types of languages: The ones people complain about and the ones noone uses

replies(2): >>45990661 #>>45991053 #
greiskul ◴[] No.45991053{5}[source]
The @ operator of php. In languages like Java, to silently catch all exceptions and do nothing with them requires at least some boiler plate.

PHP has an operator for something you should never do in a sane codebase.

You know that python wants good good to look good?

PHP was written in a way that makes bad code look good. And if we want Software Engineering to be a serious field that evolves, we have to be able to be honest with ourselves. It is a bad tool. Good programmers can even write good programs with bad tools. Doesn't mean you shouldn't avoid bad tools given the option.

There probably is a "PHP the good parts". But Javascript actually had a pretty nice core, and an utility of being in all web browsers that no other language could replicate. What niche does PHP have where it brings more value there other nicer languages can't be used instead?

replies(3): >>45991256 #>>45991277 #>>45992095 #
onli ◴[] No.45991256{6}[source]
You absolutely can use @ in sane codebases. And you give the example yourself: In other languages you often enough see that boilerplate where thrown exception is discarded, because there is no sane reaction to some edge case and you just want the program to continue, because you know it will work anyway. And that's @.

Note though that @ was already neutered in some earlier recent PHP releases.

replies(1): >>45991505 #
1. djxfade ◴[] No.45991505{7}[source]
This.

One common use case for the @ operator, is when "destructuring" array members into variables. In some cases, you can't know if the member will be available, but it's not important if it's missing. In that case, you can silence the warning.

$array = ['apple', 'pear']; @list($mainFruit, $secondaryFruit, $tertiaryFruit);

Since I suppress the warning that would occur due to the third member not being present, the program will continue executing instead of halting.