Live data from Hacker News

What's New in PHP 8.1

stitcher.io

81–90 of 112 posts

Re: What's New in PHP 8.1

#81
post #9
post #8

Earlier quoted context omitted.

Funny. I almost dislike all of PHP but think that their choice of basic data structure is the one good thing. Computers are getting faster and faster and simplifying programming could be done to a whole new level. Clojure for example has a similar approach. Okay, PHP lacks contracts, but maybe PHP adds them in 20 years when the mainstream understands that they are great.

Clojure's persistent collection types include List, Vector, Map, Set and you have namespaced keywords. In general, I don't see how you can compare the approach of Rich Hickey and Clojure to PHP to be honest...

Also, those collection types are backed by a number of concrete implementations.

Re: What's New in PHP 8.1

#82
post #15

Earlier quoted context omitted.

Dev recruitment is hard to find php developers? wtf are you smoking? I think a lot of this is highly dependent on where you are. My guess is you mostly deal with non php languages?

> dev recruitment is hard. No way. It is pretty easy. To be fair it is harder in the Bay Area than let's say Europe, but it is still a non-issue. Also, the language is extremely easy to pick up, everyone is able to understand the code. This week for example I 've had an ios dev that is using Obj-C/Swift just dig into the code themselves to get clarity on an endpoint's execution. > dev retention is hard. Never really…

I had PHP listed among my Linkedin skills and never once in over 10 years a recruiter contacted me on Linkedin asking me to apply for a PHP job.

I have been contacted for every single of my other skills, even F# which is one of the most rarely used languages ever.

Re: What's New in PHP 8.1

#83
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.

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.

  This is the TXR Lisp interactive listener of TXR 249.
  Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
  Poke a few holes in TXR with a fork before heating in the microwave.
  1> [mapcar succ "abc"]
  "bcd"
  2> (car "abc")
  #\a
  3> (cdr "abc")
  "bc"
  4> (cadr "abc")
  #\b
  5> (cddr "abc")
  "c"
  6> (cdddr "abc")
  nil
  7> (rplaca (copy "abc") #\x)
  "xbc"
  8> (rplacd (copy "abc") "yz")
  "ayz"
  9> (ldiff "abcd" "cd")
  "ab"

Re: What's New in PHP 8.1

#84

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.

I agree with your core point, but the comparison to JAMStack is misguided. Push to GitHub, sign in to Netlify (or one of countless similar services), pick the repo to deploy, and you’re done.

Re: What's New in PHP 8.1

#85

Earlier quoted context omitted.

I too dislike PHP, but this is one of the things I hate the most: this is like conflating addition and multiplication of types. Arrays and maps have separate use cases and very different trade-offs and PHP gives you no choice in the matter.

In fairness, it does give choices -- https://www.php.net/manual/en/spl.datastructures.php

The SPL data structures are widely considered a mistake. They're awkwardly designed, cannot be type-hinted, and often perform worse than pure-PHP alternatives.

Re: What's New in PHP 8.1

#86
post #54

Earlier quoted context omitted.

I'm kinda used to PHP "arrays", but I really wish it had proper lists. This array_is_list function doesn't change things much: I already have the same implemented in many of my projects. The point is that I shouldn't do that: I just should use a typehint the same way as I'd do it with array or MyCustomClass. Of course there is Ds\Sequence, but having it as a part of some relatively obscure library isn't the same as h…

What `array_is_list()` changes is that it makes this check fast . Previously, the fastest method of checking for a list-like array was `$arr == array_values($arr)`, which was slow on large lists and could fail entirely on some unusual structures containing circular references. (I was involved in the development of this function: https://github.com/php/php-src/pull/4886 )

Is array_is_map(), etc, planned? Or is the pure php equivalent fast enough for those?

Re: What's New in PHP 8.1

#88
post #65

Earlier quoted context omitted.

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).

It is a problem to maintain. Simple example: how do you remove sessions in a multi server environment? Well, you can set a config to do that at random which imposes a cost for that particular request. Or you can run a corn job. This is not a decision in most other scripting languages.

Don’t get me started on concurrency either...

Re: What's New in PHP 8.1

#89
post #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)

When a type system is lacking, Hungarian notation will have to do.

Re: What's New in PHP 8.1

#90

Earlier quoted context omitted.

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

It is a problem to maintain. Simple example: how do you remove sessions in a multi server environment? Well, you can set a config to do that at random which imposes a cost for that particular request. Or you can run a corn job. This is not a decision in most other scripting languages. Don’t get me started on concurrency either...

Why is this not an issue in other scripting languages? You either delete at runtime or delete in a separate process. What other options are there?
Post reply on HN