Live data from Hacker News

PHP 7.2.0 Released

php.net

41–50 of 80 posts

Re: PHP 7.2.0 Released

#41
post #5

It's weird for a bug fix I wrote to be top of the list of features. PHP 7.2 is not the most eventful release.

How comes a bug fix has an RFC?

It's a long-standing and documented issue; there wasn't the will to fix it. In that sense it's “not” a bug.

It's also, well, just complicated and potentially controversial enough (significant performance decrease!) to warrant one.

Re: PHP 7.2.0 Released

#42
post #39
post #34

Earlier quoted context omitted.

Sighs I say the following as someone who tripped over PHP around 2008 and, because it worked for most of the problem areas I threw at it, I didn't try and learn anything else. The following is an honest appraisal from about ~10 years of gently smashing my head against a soft wall. ("I don't have a headache, but I do wonder how much I've dislocated...") Here's the thing. PHP is fast . Really fast. I custom-built a min…

> I can has new REAL programming language... that's _faster_ than PHP? :D Have you tried node.js 8 or 9? There's also duktape but I don't know what APIs does it have. $ time nodejs test.js # second run hello world real 0m0.066s user 0m0.058s sys 0m0.009s $ time duk test.js # second run hello world real 0m0.002s user 0m0.002s sys 0m0.000s edit: duktape has a very limited API built in, and it seems one needs to add any…

The problem with super-minimal environments like Duktape, PicoC, Lua, mruby, TinyPy, etc is precisely what you describe: there's no batteries-included behavior.

I am seriously considering acquiescing to the performance impact of Go build times (yup, it's slow, who woulda thunk) because of the sane-batteries-included nature of the language.

Re: PHP 7.2.0 Released

#43
post #42
post #39

Earlier quoted context omitted.

> I can has new REAL programming language... that's _faster_ than PHP? :D Have you tried node.js 8 or 9? There's also duktape but I don't know what APIs does it have. $ time nodejs test.js # second run hello world real 0m0.066s user 0m0.058s sys 0m0.009s $ time duk test.js # second run hello world real 0m0.002s user 0m0.002s sys 0m0.000s edit: duktape has a very limited API built in, and it seems one needs to add any…

The problem with super-minimal environments like Duktape, PicoC, Lua, mruby, TinyPy, etc is precisely what you describe: there's no batteries-included behavior. I am seriously considering acquiescing to the performance impact of Go build times (yup, it's slow, who woulda thunk) because of the sane-batteries-included nature of the language.

How fast is a hello world in node.js to you?

I forgot to mention my formerly favorite language: Python. It's _much_ faster than Node.js in startup and relatively basic things. Node wins on almost everything I make, though.

    $ time python test.py  # second run
    hello world

    real    0m0.009s
    user    0m0.009s
    sys     0m0.000s

Re: PHP 7.2.0 Released

#44
post #10

What is PHP like nowadays? I know it has a bad reputation and a history of kitchen sink design but have they managed to tame it into something more sensible? Do the docs help steer developers away from legacy issues and common bad patterns? Would anyone recommend it for new projects?

For new projects only if you have an established php team / related projects. Modern OOP development in PHP 7 feels basically like an older version of Java (pre Generics), solid for engineering, but ugly for anyone who expects newer language features.

Agreed. We use PHP for automation scripts (this decision was made a long time ago). In terms of features it's a good language but it's not fun to work with.

Re: PHP 7.2.0 Released

#45
post #43
post #42

Earlier quoted context omitted.

The problem with super-minimal environments like Duktape, PicoC, Lua, mruby, TinyPy, etc is precisely what you describe: there's no batteries-included behavior. I am seriously considering acquiescing to the performance impact of Go build times (yup, it's slow, who woulda thunk) because of the sane-batteries-included nature of the language.

How fast is a hello world in node.js to you? I forgot to mention my formerly favorite language: Python. It's _much_ faster than Node.js in startup and relatively basic things. Node wins on almost everything I make, though. $ time python test.py # second run hello world real 0m0.009s user 0m0.009s sys 0m0.000s

Best times from a few "do nothing" runs of Node:

  $ time node -e ''
  real    0m0.098s
  user    0m0.084s
  sys     0m0.010s
Of course on my desktop it's a

  $ time node -e ''
  real    0m0.002s
  user    0m0.000s
  sys     0m0.000s
tiny bit different.

Python on my laptop is just slow enough that I really notice it:

  $ time python -c ''
  real    0m0.032s
  user    0m0.022s
  sys     0m0.009s
Of course PHP is all 0.014, 0.010, 0.012, etc.

Incidentally, this T43 is a backup machine I'm using while my desktop is on indefinite loan to a family member after their laptop broke. This will be fixed eventually; I'm not sure how.

But I've discovered that this old machine is a remarkably good performance catalyst; something that runs blindingly fast on this machine will run really, really well on a faster box - and the thing is, if I write stupid or inefficient code on this older laptop, I'll notice I'm doing it wrong sooner, because it takes less to make this machine fall over from inefficiency.

If only I could tell the above to the Chromium team, though... sooo many Chrome issues... (and Firefox is unfortunately slower on old hardware than ever before! >.<)

Re: PHP 7.2.0 Released

#46

Earlier quoted context omitted.

> What is PHP like nowadays? Would anyone recommend it for new projects? It is not bad at all but since there are so many good/better alternatives I would never start a fresh project with PHP nowadays. The only reason would be if you have a team with PHP experts - then PHP would be the obvious choice.

Unsexy yes, but stable and works a charm for most of the scale people here will deal with. What alternative would you suggest for newer projects?

Agreed 100%, someone should give names and strength compared to PHP instead of just saying alternatives are better.

Re: PHP 7.2.0 Released

#47
post #16
post #10

What is PHP like nowadays? I know it has a bad reputation and a history of kitchen sink design but have they managed to tame it into something more sensible? Do the docs help steer developers away from legacy issues and common bad patterns? Would anyone recommend it for new projects?

Four words : composer, symfony, laravel and php-fig. The php ecosystem is not what it was 4 years ago. Although due to backward compatibility the languages still has a lot of cruft. But this means old code often works directly with the last version and benefits from its performance improvement. If your new project is about receiving an http request and send a response like a REST API I think it is a good tool for the…

I don't get the love for Laravel. Things like validation, specifying validators in strings like it's 2003 grate with me. Symfony's a pain in the butt for over-engineering things (DataTransformers are a good place to start) but at least it's well thought through.

What are the reasons to love Laravel?

Re: PHP 7.2.0 Released

#48
post #47
post #16

Earlier quoted context omitted.

Four words : composer, symfony, laravel and php-fig. The php ecosystem is not what it was 4 years ago. Although due to backward compatibility the languages still has a lot of cruft. But this means old code often works directly with the last version and benefits from its performance improvement. If your new project is about receiving an http request and send a response like a REST API I think it is a good tool for the…

I don't get the love for Laravel. Things like validation, specifying validators in strings like it's 2003 grate with me. Symfony's a pain in the butt for over-engineering things (DataTransformers are a good place to start) but at least it's well thought through. What are the reasons to love Laravel?

Apparently the creater modeled it after Ruby on Rails, so I guess it's easier to use if you are used to that platform.

Re: PHP 7.2.0 Released

#49

One of the biggest improvements is that Libsodium is now built-in. https://dev.to/paragonie/php-72-the-first-programming-langua... No more Mcrypt, less cases of having to use OpenSSL and using it wrong. This is a huge security step towards the future.

The other thing is that they have partially fixed the most "wat" bug in PHP: for some arrays that aren't even all that hard to come by when interacting with JS, the following code could change `count($arr)`:

    foreach ($arr as $key => $val) {
        $arr[$key] = f($key, $val);
    }
The issue is that `$key` could be a string describing an integer, but `$arr[$key]` will automatically see that you're using a string-int and convert it to an int-int, setting a different key than the internal one.

It's only a partial fix but it hits the most common case: you have a JSON payload that happens to have an index of objects which happens to have been given numeric keys:

    {
      "abcdef": {"prop1": "hello", "prop2": 123}, 
      "987132": {"prop1": "world", "prop2": 456}
    }
If your framework hands JSON to you as a StdClass object then you would typically convert this to an associative array since that's semantically what it is: as opposed to the internal entities, which in this case appear to be full-fledged objects. (The difference is that the keys of a full-fledged object should be known in advance at a data-schema level and have a control structure of getting/setting `->prop_name`; the keys of a dictionary should be user-settable and have a control structure of `foreach ($dict as $key => $val) {}`.)

So the bug still maybe exists in some fringe cases as the underlying cause is not treated, but it is now autofixed by the common idiom of casting `$dict = (array) $params->dict`.

Re: PHP 7.2.0 Released

#50
One of the most significant changes in PHP 7.2 is actually the list of features that it deprecates. Among other things, this includes:

- Unquoted strings

- The __autoload() method

- The track_errors ini setting and $php_errormsg variable

- create_function()

- each()

- The $errcontext argument

Numerous internal optimizations and language improvements will become possible in PHP 8 when these features are removed.

http://php.net/manual/en/migration72.deprecated.php

Post reply on HN