Live data from Hacker News

What's New in PHP 8.1

stitcher.io

61–70 of 112 posts

Re: What's New in PHP 8.1

#61
post #49

Earlier quoted context omitted.

PHP was the most competitive when ASP was around. After that, PHP entered a dark age where almost every other language ran circles around it in terms of performance, security, maintainability, tool support... and literally everything. Some of those problems got addressed but by the time that happened PHP's reputation was irreversibly trashed and now nobody wants to know about it. That is the world we live in. People…

It sounds like a sad story. PHP's specialization is in rendering dynamic web pages. It was its ONLY purpose (ignoring niche projects like GTK bindings, etc). And yet even against general purpose languages/VM's (where using it for backend web is a choice, not its only purpose), PHP could not remain competent in its own class. It's like building a car designed for just one thing, to go very fast on straight roads, then…

PHP = a programming language + templating engine.

Most general purpose languages do not have built in templating and do not have templating in their standard library.

As a programming language, many modern languages have a faster and more optimized runtime than PHP. If the Laravel authors ported their framework to Node, Python or Java it would certainly run faster.

As a templating language, it has to run on the server. That means you pay for the computing cost of templating not the end user. Unless you do your templating using a JS solution.

On top of that, you have to transfer a rendered page from your application server instead of just serving files from CDN at a fraction of the cost.

Overall, PHP is the wrong solution for the wrong problem. I used PHP in 2004 and then moved on. The industry at a large also moved on.

Re: What's New in PHP 8.1

#62
post #3

"New array_is_list function" I use PHP a fair amount, but this is one area that irks me. PHP arrays can be arrays, lists, and hash maps. PHP obviously copied some of Perl's features, and I never understood why hashmaps and arrays weren't different types, as they are in Perl.

It's simpel!

Name your vars $some_list for integer arrays and $some_hashmap (sometimes $some_coll (collection)).

I'm 1/2 joking. I maintain loads of legacy and recent PHP LOB apps. Var-name fixes can do a lot to help the case in any loosely typed langs (I learned the trick from VB4.0)

Re: What's New in PHP 8.1

#63
post #60

> array_is_list This is a stupid solution to a stupid problem. Defaulting to weak typing has enough problems, but changing the behavior of your data structure based on its contents is next-level pain. I used PHP for a few years at a student dev job and I can’t count how many times this conflation wasted my time and introduced various bugs. If PHP wants to become more respectable as a PL, it has got to break that out…

Dynamic typing is a trade off, one that requires some explicit type checking in some situations. It doesn't make it a stupid solution or a stupid problem. If you validate and conform your types at program edges it's rare you ever really need to do type checking. That is, a properly structured PHP application has all the benefits of dynamic typing and few of the problems that static type checking supposedly eliminates…

I like dynamic typing: most of my work is done in untyped Racket or Elixir. Weak typing is fun, but can be frustrating. My issue is that this single data structure functions like a list in some cases, and a map in others. Try piping the result of array_filter to array_map sometime. You can’t do it without an intermediate call to array_values first because the result of passing a list to array_filter does not behave like a list anymore: it operates strictly like a map and cannot have map called on it. (Oh the irony!)

Re: What's New in PHP 8.1

#64

> array_is_list This is a stupid solution to a stupid problem. Defaulting to weak typing has enough problems, but changing the behavior of your data structure based on its contents is next-level pain. I used PHP for a few years at a student dev job and I can’t count how many times this conflation wasted my time and introduced various bugs. If PHP wants to become more respectable as a PL, it has got to break that out…

> changing the behavior of your data structure based on its contents PHP does no such thing. There is one array type with one behaviour. There is no distinction between different kinds of arrays in the language.

Doch. Try piping the result of array_filter to array_map sometime. You can’t do it without an intermediate call to array_values first because the result of passing a list to array_filter does not behave like a list anymore: it operates strictly like a map and cannot have map called on it. (Oh the irony!)

Re: What's New in PHP 8.1

#65

One thing I still love about PHP is that it's so easy to deploy. No need for fancy Amazon Web Shmervices, no need for Jamstack jumping through the hoops. Just find any host that supports PHP, upload your file, and done.

Easy to get started.. nightmare to maintain aftewards.

Re: What's New in PHP 8.1

#66

One thing I still love about PHP is that it's so easy to deploy. No need for fancy Amazon Web Shmervices, no need for Jamstack jumping through the hoops. Just find any host that supports PHP, upload your file, and done.

> no need for Jamstack jumping through the hoops.

"Jamstack" sites, in their simple form, or even combined with a modest number of lambda functions, can be deployed to github pages / netlify / vercel and a number of other platforms for free. Push a commit to github, get an automatic deployment going, boom, done. I am not aware of any analogues in the php ecosystem.

Re: What's New in PHP 8.1

#67
post #33
post #3

"New array_is_list function" I use PHP a fair amount, but this is one area that irks me. PHP arrays can be arrays, lists, and hash maps. PHP obviously copied some of Perl's features, and I never understood why hashmaps and arrays weren't different types, as they are in Perl.

I love them. Lisp can use lists for everything, and PHP arrays ;) Thanks to their mixed nature they're very versatile. People even make small DSLs out of them. And they're order-preserving, so they won't inject non-determinism just to smugly teach you a lesson about real hash tables.

The problem is that lisp APIs tend to treat paired sequences as equal citizens, whereas PHP treats paired arrays as a special case and they're effectively a different data type. This is the same problem with how Erlang/BEAM languages treat strings as a list of character data. It's the same until it's not, and then it's decidedly not.

Re: What's New in PHP 8.1

#68
post #19

I recently killed all my PHP code in favor of Go. What finally convinced me is the Go package system. I like that Go has a builtin package manager, while I dont think PHP does. I know about Composer, I just wonder. After all these years, why hasnt PHP incorporated a builtin package manager?

I'm reflexively upvoting this because it's absurd to me it's grey even though I don't have a dog in the fight.

Re: What's New in PHP 8.1

#69
post #65

One thing I still love about PHP is that it's so easy to deploy. No need for fancy Amazon Web Shmervices, no need for Jamstack jumping through the hoops. Just find any host that supports PHP, upload your file, and done.

Easy to get started.. nightmare to maintain aftewards.

I don't use PHP anymore, but I used it for years in production. Was pretty easy to maintain (via Apache's mod_php).

Re: What's New in PHP 8.1

#70
post #33

Earlier quoted context omitted.

I love them. Lisp can use lists for everything, and PHP arrays ;) Thanks to their mixed nature they're very versatile. People even make small DSLs out of them. And they're order-preserving, so they won't inject non-determinism just to smugly teach you a lesson about real hash tables.

Almost anything can be simulated in any other data type, often with poor performance and easy bugs. If a programmer use lists in lisps where vectors or hash tables are more appropriate, he is doing something wrong. Likewise, simulating arrays in hash tables, which is what PHP expects one to do, is a very bad idea. Bash lacks multidimensional arrays, but it does have hash tables, so some programmers resort to simulati…

The reality of most of programming I've done is that in 98% of cases you deal with data structures that are sufficiently small for performance not to matter much on modern hardware.

If you do need to deal with data structures that are quite large (i.e., take GBs of memory), perhaps PHP is not the right language.

Post reply on HN