Live data from Hacker News

PHP 8.0.0 beta 2

php.net

91–100 of 102 posts

Re: PHP 8.0.0 beta 2

#91
post #59

Earlier quoted context omitted.

As a statically typed language, I feel like it doesn't even take much to explain why it's actually the worst, except for C. But at least C is necessary in some domains. The type system is weaker than Java, which is a low bar. It has no generics, which means no real containers, no generic functions without dropping all typing, no type-hinted arrays. Arrays are also not objects, so they don't conform to any interfaces,…

> It has no generics, which means no real containers, no generic functions without dropping all typing, no type-hinted arrays. These things are a little advanced for the likes of me. Any chance you'd be so kind as to give me an example of something I can't easily do because of not having this? > It's definitely fast for a scripting language! So, that's fair. But it's still way slower than many other good backend lang…

> These things are a little advanced for the likes of me. Any chance you'd be so kind as to give me an example of something I can't easily do because of not having this?

Well, you can do whatever you want in a dynamically typed language. I was discussing the shortcomings if you choose to use PHP's type system.

If I'm using my static types and see `function foo(): Bar` I take comfort that I will receive a `Bar`. If I see `function foo(): array` I have absolutely no idea what that array is. Is it a list of `Bar`? Is it a dictionary of some kind? Is it a heterogeneous list of bools, ints, and Maseratis?

Also, real containers are useful. A true array is a contiguous slab of memory. PHP's array is not. The performance characteristics will be very different. If you had a `Set` type, you could guarantee that there are no duplicates in the set. That is sometimes very useful. No such thing in PHP. PHP arrays can't even be used as a real `Map` because if you do `$arr["1"] = new T()`, it wont actually have "1" as a key! It'll transform the "1" into 1 and store it in the 1th slot, like an array!!! Totally flipping useless.

> But those languages require compilation and deploy cycles that are way longer than just getting files on disk, so the total cycle time of development may end up being longer in many cases.

Are you suggesting that you write PHP code and then plop in on a production server without running tests? Because running your tests is comparable to the compile cycle of Java et al. Except in those cases I don't have to write entire classes of tests, whereas you should be writing type-checking-style tests on your PHP code. You just have to be the compiler to make sure your inputs are validated correctly.

> PHP probably shouldn't be used for performance-critical things, sure, but then neither should any other dynamic language.

Then what was the point in comparing PHP's speed to Python? They're both slow and shouldn't be used for performance-critical things. That's fine, but then find me a selling point.

Re: PHP 8.0.0 beta 2

#92

Earlier quoted context omitted.

> IMO, no. The language is still near the bottom for both dynamic and "static" typed languages. Why do you say that? It's faster than Python and Ruby for most cases, still extremely simple to deploy, the package manager (Composer) is very predictable and easy to deal with compared to Pip or Rubygems, the documentation is good, etc. It has clean lambda functions that you can pass around easily and has for more than a…

> still extremely simple to deploy Hardly. PHP-FPM is a confusing mess to set up, and you're still stuck working around the massive mistake of binding routing to the file system. And I hope you don't try to just rsync up your changes afterwards without some form of blue/green deployments. > the documentation is good There is.. a lot of it, for better or worse. Let's compare the functions for concatenating lists betwe…

> you're still stuck working around the massive mistake of binding routing to the file system

fastcgi_param SCRIPT_FILENAME /var/www/index.php;

Re: PHP 8.0.0 beta 2

#93
post #33

Earlier quoted context omitted.

Parameter order was somewhat resolved with the introduction of named parameters in the upcoming php 8 release from this year.

True, but I doubt I want to use that on a simple string function. I'd actually much prefer to see the introduction of methods on strings ala Ruby and most other natively-OOP languages rather than calling the C-style functions with the strings as a parameter, but hey, it is what it is.

Not gonna happen, but you can always use Symfony's String component that has API like that.

Sure, it's not built-in, but I think this is the best solution for now given the size of PHP's language team.

Re: PHP 8.0.0 beta 2

#94
post #13

Earlier quoted context omitted.

> after having to work with it at the time of PHP3 and 4 PHP 5 was released 16 years ago and was a massive evolution of the language. The same is true for PHP 5.2, 5.3, and 7. It's safe to say that your conclusions about the language are no longer accurate. > Is there anything that PHP is developing or adopting that can not be had at other established languages? No. I can't think of any reason to start a new project…

Wikipedia? Facebook?

They said today. Those sites were not started today. Furthermore, Facebook literally invented a new language because PHP wasn't good enough. PHP has since adopted some of the features of that language.

Re: PHP 8.0.0 beta 2

#95
post #18

Earlier quoted context omitted.

> Is there anything that PHP is developing or adopting that can not be had at other established languages? Good documentation and reasonable backwards compatibility.

You can have both at other languages and platforms.

Can you name a few that already do it?

Re: PHP 8.0.0 beta 2

#96
post #13
post #7

Earlier quoted context omitted.

I have to confess that I have a lot of prejudice against PHP after having to work with it at the time of PHP3 and 4. It seemed like even worse than Perl in the sense of how many things were just bolted on it as a way that the developers could claim "yeah, you can do that with PHP". After having a blog running wordpress hacked twice by mere virtue of being online, I dismissed it for good. I keep hearing about how the…

> after having to work with it at the time of PHP3 and 4 PHP 5 was released 16 years ago and was a massive evolution of the language. The same is true for PHP 5.2, 5.3, and 7. It's safe to say that your conclusions about the language are no longer accurate. > Is there anything that PHP is developing or adopting that can not be had at other established languages? No. I can't think of any reason to start a new project…

Laravel is decently popular, has the most *s on github for a backend framework I believe (or it did at one point in time) and in a number of Fortune 100 companies.

May not be as popular as React/Flask backends, but it ain't nothing.

Re: PHP 8.0.0 beta 2

#97
post #9

PHP is damn good in certain areas. It is one of the best choices (if not the best choice) for rapid prototyping of a program. Its damn fast to similar alternatives (Python, Ruby, Dart, JavaScript), and the standard library is huge. It does have footguns. I am not a fan of the loose typing, but you can take some steps to mitigate. You can do "===", "strict_types" and type hinting for function input and output. It is s…

I'm with you on everything but the docs. More than once I've had to dive into the source when the docs tell me one thing but the behaviour in some edge case is different. PHP's docs are extensive, but not nearly as reliable as they should be. And don't get me started on the comments.

Re: PHP 8.0.0 beta 2

#98
post #40

Earlier quoted context omitted.

WordPress accounts for approximately 60% of all websites, PHP accounts for approximately 79% (knows server side sites). So I would say it is particularity popular.

I'd like to know more about that 79% number. I would guess it's actually the case that PHP backends identify themselves as PHP far more than backends in other language x identify themselves.

That doesn't make sense. If you test 100 sites and 79 come back as PHP you can't just claim that the 21 responses that came back blank somehow is a bigger number than 79.

Re: PHP 8.0.0 beta 2

#99

Hopefully this will change Apple's mind. https://twitter.com/GrahamJCampbell/status/12951119829248614...

I think this is irrelevant, apple just moved scripting language support out of their OS bundle. They blew it with that warning message though.

Re: PHP 8.0.0 beta 2

#100
post #62

Earlier quoted context omitted.

By the way you phrase that question, you're dismissing that single key feature that PHP _already has_ that cannot be had at other established languages. I know of no other language that lets you deploy a web app by dragging some files from the left to the right in FileZilla. No setup, No vendor lock in, no nothing. It just works. Cross-cloud serverless frameworks that wrap AWS lambda + competitors get you somewhat cl…

You cannot deploy a PHP app by just plopping a file on an unconfigured server. Deployment is not that simple. Or, if it is, then you have to allow me the same grace of just being able to plop my Go or Rust binary on that server and have it magically work. It might even work BETTER because I don't need to check if my php.ini matches my dev machine.

There are tens of thousands of hosting providers around the world that offer exactly this service.
Post reply on HN