Live data from Hacker News

PHP 8

php.net

91–100 of 273 posts

Re: PHP 8

#91

0 == 'foobar' // false > When comparing to a numeric string, PHP 8 uses a number comparison. Otherwise, it converts the number to a string and uses a string comparison. Why do the conversion at all? Why couldn't this just be an error? I realise there is also `===` the strict comparison that typechecks arguments, but why not make that the default?

> Why couldn't this just be an error?

you mean crash your program? So your user finds a way to send you an int instead of a string, or vice versa, and now they can crash your webserver.

Re: PHP 8

#92
post #78
post #68

Earlier quoted context omitted.

Yes, each request is handled by its own process. This might sound weird if you're used to other languages, but it's how every language used to work in the good ol' CGI days. PHP doesn't break backward compatibility easily, and I don't think it will ever break this one. Besides, once you get the hang of it, PHP's execution model is highly intuitive and beginner-friendly. You simply don't have to worry about a whole cl…

The PHP doc advices you that the built-in server from PHP should be used only for development: https://www.php.net/manual/en/features.commandline.webserver... . But PHP-FPM is the most used nowadays, for sure.

I find the built-in web server very useful for running tests. Instead of setting up Apache or nginx on every CI build, you just fire up the built-in web server and point your tests at it.

Re: PHP 8

#93

I got spoiled by PHP as my first language. It was so easy to get going. I was surprised to learn that other languages didn't work the same way, when integrating into a web server. Also it has always been rock solid. A bug in my code brought down only that request for that user, totally did not affect or even slow down responses to other users. People have attacked its syntax forever. I avoided the worst of it by lear…

REMOTE_USER as in HTTP Basic auth? the ugly login prompt you can not logout of again?

That is one way, and I agree it's ugly, but Apache came out with form-based authentication in version 2.4, https://httpd.apache.org/docs/2.4/mod/mod_auth_form.html

Re: PHP 8

#94
post #41
post #37

Out of curiosity, why match expressions became popular for non functional languages? Without pattern matching on datatypes via cons expression (x::xs matching) it is just another kind of switch or if/else. Why do people promote this? here a nice comment on this topic: https://ocaml.org/learn/tutorials/data_types_and_matching.ht... "So one Really Cool Feature of functional languages is the ability to break apart data…

It simplifies the expression of if/then/elsif/elsif/else, even if it's not total. Why not steal it?

One reason to not add it might be that it makes the language larger and more complex.

Also, the semantics of match are a bit different than the similar switch, since match does strict type checking and switch doesn't. While this isn't bad as such, it's kinda confusing that the language doesn't behave consistently.

Re: PHP 8

#95

Earlier quoted context omitted.

REMOTE_USER as in HTTP Basic auth? the ugly login prompt you can not logout of again?

That is one way, and I agree it's ugly, but Apache came out with form-based authentication in version 2.4, https://httpd.apache.org/docs/2.4/mod/mod_auth_form.html

Oh thanks! That's nice.

Re: PHP 8

#96
post #87

How should one start learning with PHP these days? My experience: hacked together a few PHP scripts over the years to notify me of a website change (5 minute cron job). Before that, I was a very good beginner with VB6 back in highschool. There are a couple of ambitious database-driven website projects I would like to create, but I don't know where to start. I like the KISS philosophy, and I think PHP and MySQL would…

>w3schools PHP tutorial I think a better approach is to think of a (very basic) project you want to create, and then claw and bite your way through it, until you have something that works. Then think of a way to enhance it, and go though the process again. Slogging through a tutorial is boring, and you have nothing to show for it when you're done. PS: Don't listen to sneaky JavaScript evangelists. Wicked! Tricksy! Fa…

Lol, I appreciate everyone's advice, and I'll have to do research on it all to see what will work best for me.

I'm just reminded of Derek Siver's experience where he started CD Baby with PHP, and then tried rewriting it in order to use something other than PHP just because, but ended up sticking with PHP. Though he is a musician and not a professional programmer. However I'm not a professional programmer either, and I don't really want to become a sys admin to maintain the servers etc.

Re: PHP 8

#97
post #88
post #46

Earlier quoted context omitted.

Curious if that's a general aversion to dynamic typing, or specifically PHP.

The problems with PHP aren't really with the concept of dynamic typing as such, but rather with the somewhat curious semantics and really awkward standard library. These are relics from the past that are, unfortunately, very hard to fix without a "Python 3000 moment", and all the problems that brings. Although PHP 8 does fix a bit of it (various comparisons and operators are a bit better now) there's still a lot of i…

That's what I was trying to make sure I understood. There are people that just don't like dynamically typed languages.

Re: PHP 8

#98

I wonder what makes the Symfony Demo App not being faster with the JIT compiler (as shown on https://www.php.net/releases/8.0/en.php and https://susi.dev/php8-benchmark-jit-symfony ). Maybe because Symfony already caches things very efficiently/cleverly with OPCache?

The article you link to already explains it... ?

> The point is, if you look in the announcements and comments about what the JIT does you can pretty much guess why this is kind of the expected result. The JIT compiler improves performance for CPU-intensive work (for example calculating Mandelbrots) but not so much for the "default" kind of applications. We usually don't do all that many calculations.

Re: PHP 8

#99
post #46

Earlier quoted context omitted.

I must be very picky, because to this day I still don't like it at all. It sucks less than it used to maybe, but if I compare it to other languages, I still would rather use anything else.

Curious if that's a general aversion to dynamic typing, or specifically PHP.

Nothing in their comment suggests anything about typing. They might love JavaScript or Python for all we know.

Re: PHP 8

#100
There have been 5 major threads about PHP 8 in the last few months:

https://news.ycombinator.com/item?id=24866190

https://news.ycombinator.com/item?id=24235440

https://news.ycombinator.com/item?id=24320024

https://news.ycombinator.com/item?id=24150731

https://news.ycombinator.com/item?id=23955197

A couple of those are more technically specific (to JITs and named arguments) but the vast majority are just the usual comments about PHP in general. Nothing wrong with that, of course, except that there gets to be too much of it.

This is a harder problem than it seems, because popular projects always get generic discussion (btw if you hate something that's still a kind of popularity!) and the alpha and beta releases always get posted and frequently get upvoted for the same (popularity) reason. There's a longer explanation about this here if anyone cares: https://news.ycombinator.com/item?id=23071428.

We downweight generic subthreads when they get stuck at the top of the page, but only sporadically, since it requires manual monitoring. (Btw, emailing hn@ycombinator.com when you notice a generic top subthread in any discussion is always super appreciated! Downweighting those is probably the biggest single thing we can do to improve thread quality.) As for why generic discussion is worse: it's repetitive and contains less information. More on that:

https://hn.algolia.com/?dateRange=all&page=0&prefix=true&sor...

https://hn.algolia.com/?dateRange=all&page=0&prefix=false&so...

Post reply on HN