
PHP 8.0.0 beta 2 - julien_c
https://www.php.net/index.php#id2020-08-21-1
======
svnpenn
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 similar to C in that the language itself
doesnt really do much to stop you from writing bad code. Also the function
naming is not consistent, and even function arguments are not consistent.
However PHP 8 will help with that somewhat, as you can now do named arguments.

Also PHP has the best language documentation I have ever seen. I would prefer
more examples, but its well above some other languages.

~~~
SwiftyBug
I can't believe named arguments aren't default in every language. TypeScript
could have implemented it.

~~~
ht85
[https://github.com/Microsoft/TypeScript/issues/467#issuecomm...](https://github.com/Microsoft/TypeScript/issues/467#issuecomment-354537675)

------
mrrsm
PHP, since version 7.0, has been a much improved language since when many
people started hating on it. They have been consistently moving the spec
forward and making improvements. It's not perfect, but no language really is
after all. It is really nice just seeing issues that have been around for a
long time being addressed and fixed.

~~~
rglullis
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 language has improved, but to me it feels like
even if the language gets rid of all its heaps of crap, it still is in a
evolutionary dead-end. Is there anything that PHP is developing or adopting
that can not be had at other established languages?

(Edit: I never had something downvoted so fast before. This is not concern
trolling. I seriously would like to know if it makes sense for a non-PHP
developer to look into it)

~~~
smt88
> _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 with PHP today. All of
its best features are things that have been available in other languages for
years. It's also not particularly popular outside of WordPress.

~~~
wyck
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.

~~~
NationalPark
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.

~~~
pests
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.

------
yagodragon
I think it is possible that PHP is still the best choice for web development
in 2020.

I'm coming from an academic background and i was looking to learn a new
backend language to create simple CRUD type, web applications. I already know
c/c++, java, js and some python but after research it seems that Rails,
Laravel and Django are the best options for this kind of projects as
javascript on the backend is still a mess. So i've made a little comparison
between them to choose what to learn.

Rails: It might be the best full stack web development framework from what i'm
gathering, but it's declining fast and Ruby has a small market share outside
the US.

Django: It's been always the 2nd or 3rd best option. Django 3.0 is going async
which looks great on paper but in reality it needs work. It doesn't have a
built-in asset pipeline for modern js development on the front-end. It needs
plugins for basic stuff like social, api auth etc. Python has libraries for
almost everything but the web is not always a first class citizen.

PHP: It is by far the most popular backend language. Libraries are tailored
for web development and are probably well maintained because they are used by
huge projects(wordpress, magento etc). For the same reason it won't disappear
any time soon because it handles most of the information on the web and also
billions of dollars in online commerce. Symfony has the most contributors than
any backend framework and Laravel is probably the easiest framework to create
an MVP with. Developers love Laravel and the community is huge. PHP is also
improving and adopting new language features with a more advanced type system.

So the real question is why shouldn't someone learn PHP in 2020 ?

~~~
_nothing
Honest question: If I'm an American programmer, is there any reason I need to
care about Ruby's market share outside the US?

------
tambourine_man
PHP is seeing a renascence and renewed interest similar to what happened with
JavaScript a few decades ago.

A language that's easy to make fun of but widely used is an attractive target
for improvement.

~~~
outime
Maybe I'm not in the right circles but I see absolutely no renewed interest
towards PHP. Is there any reason to believe that? Honest question - PHP was my
first language (or second if you want to consider mIRC scripting) and I have
not so bad memories but at least me and everybody I know moved away from it
years ago and don't see people going back to it anytime soon.

~~~
muglug
There's been one big change in the last 5 years – the adoption of type-
inferring PHP static analysis tools in CI.

As companies started adopting TypeScript/Flow into their Javascript pipeline,
PHP developers realised the need for something similar in their ecosystem.

I work at Vimeo (which has a lot of business logic in PHP) and I took it upon
myself to write a static analysis tool (which you can play with at
[https://psalm.dev](https://psalm.dev)). Other similar static analysis tools
were developed at other places that use PHP, and together they have helped
make modern-day PHP development a little more orderly.

~~~
no_wizard
Thats pretty rad.

I'm curious if you guys use PHP at all for any real time workloads. Thats
where I've always had struggles with PHP.

Also, have you found the event dispatch system of the modern PHP frameworks to
be slower over time?

~~~
muglug
I've used PHP in a realtime setting as part of Psalm's Language Server, but
it's clearly not built for such workloads – the lack of native async support
gets in the way.

If most of the stuff you're doing requires an event loop I'd consider other
options before PHP, but if it's mainly serving web requests PHP is my go-to.

------
toupeira
Article with an overview of the changes: [https://stitcher.io/blog/new-in-
php-8](https://stitcher.io/blog/new-in-php-8)

Some highlights are union types, a JIT compiler, named arguments, annotations,
and match expressions.

The approach to named arguments is interesting. It's nice that you don't have
to change the signature of existing functions, but the downside seems to be
that you can't enforce the usage of named arguments on callers, as in other
languages like Ruby and Python where keyword arguments need to be declared as
such.

    
    
        function foo(string $a, string $b, ?string $c = null, ?string $d = null) 
        { /* … */ }
    
        foo(
            b: 'value b', 
            a: 'value a', 
            d: 'value d',
        );

~~~
Denvercoder9
> Python where keyword arguments need to be declared as such.

In Python you don't need to explicitly declare keyword arguments either
(though it is possible). This is perfectly valid and working:

    
    
        def foo(a: str, b: int, c: bool=None, d: float=None):
            pass
    
        foo(b=5, a='something', d=3.0)
        # is equivalent to
        foo('something', 5, None, 3.0)

~~~
toupeira
Thanks, TIL!

------
no_wizard
If the JIT for PHP ever becomes good enough it solves the memory leak problems
PHP to this day is still plagued with, that might be enough to convince me to
use PHP again, possibly, for some workloads.

I can't help but feel that PHPs popularity is mostly tied to Wordpress, and to
a lesser extend Laravel (with Symfony coming in behind that).

Not really sure the rest of the ecosystem even matters, outside those core
pieces. I'd love to see it fix alot of landstanding issues, and I love that
the language has moved forward. I've worked with it professionally over the
last few years in various places, and I don't particularly dislike so called
"modern" PHP, but its only really good at very specified problem domains
(mostly, you have a website, need to display said website. I always had
scaling problems for anything other than using it in the context of a template
language or very straightfoward database access. Real time APIs? nope. Just
couldn't get it done, too much memory pressure)

~~~
webignition
What are the memory leak problems?

I was under the impression that PHP's stateless nature, with a whole new
instance of everything coming into being for each request, somewhat sidesteps
the capacity for problematic memory leaks that could otherwise exist for
processes that remain alive between requests.

~~~
smt88
> _I was under the impression that PHP 's stateless nature, with a whole new
> instance of everything coming into being for each request_

A couple issues here.

1\. Even if the PHP process exits after each request, memory leaks _during_
the request are still an issue. If I'm looping through 1,000 elements of an
array and leaking memory each time, I could end up with a peak memory usage of
100MB when 1MB would've sufficed. That forces me to scale vertically when I
might not otherwise need to.

2\. Most mature applications have worker processes that may be longer-lived
than serving an HTTP request. If PHP leaks memory, it's less suited to those
tasks. Maybe you write those in Go instead, but then you have to ask yourself
why you didn't just write the whole application in Go.

~~~
CaveTech
1\. This is likely user error due to a poor understanding of how PHP memory
management works. Unless you're using poorly written extensions then memory
management in PHP is quite straightforward.

2\. There's a large amount of PHP libraries built to do exactly what you're
describing. Long lived PHP processes are live in production across the world.

Straight up misinformation.

~~~
smt88
Note: I wrote PHP professionally for more than 10 years, and I still maintain
several PHP code bases.

> _This is likely user error due to a poor understanding of how PHP memory
> management works._

This is not what the comment I responding to was talking about. They were
talking about memory leaks that were _not_ in userspace. PHP's bug tracker has
943 bugs related to memory leaks[1]. That has nothing to do with understanding
"how PHP memory management works".

> _Unless you 're using poorly written extensions then memory management in
> PHP is quite straightforward._

How exactly do you know whether an extension is poorly written? In many cases,
it doesn't matter because there's exactly one extension that does what you
need.

You could also be using poorly-written libraries.

> _There 's a large amount of PHP libraries built to do exactly what you're
> describing. Long lived PHP processes are live in production across the
> world._

I know. I use some, and I have several long-lived PHP processes running right
now.

If a memory leak is in PHP itself, no library can fix it.

> _Straight up misinformation._

Disagreeing with someone (or not understanding them) doesn't mean they're
spreading misinformation.

My point was that memory leaks _in the PHP virtual machine_ are _still a
problem_ even if PHP usually runs statelessly. Do you disagree?

1\.
[https://bugs.php.net/search.php?search_for=leak&boolean=0&li...](https://bugs.php.net/search.php?search_for=leak&boolean=0&limit=30&order_by=&direction=DESC&cmd=display&status=All&bug_type=All&project=All&php_os=&phpver=&cve_id=&assign=&author_email=&bug_age=0&bug_updated=0&commented_by=)

~~~
muglug
Ok, but looking at that same bug tracker there are only a handful of memory
leaks in PHP core (i.e. not related to an extension), the most serious of
which is being actively worked on:
[https://bugs.php.net/bug.php?id=76982](https://bugs.php.net/bug.php?id=76982)

------
brian_herman__
Hopefully this will change Apple's mind.
[https://twitter.com/GrahamJCampbell/status/12951119829248614...](https://twitter.com/GrahamJCampbell/status/1295111982924861442)

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

------
mcdramamean
The best language is the one you can make money with or positively affect the
world. Please grow up out of this old debate. You all sound like 3 year
olds...

~~~
azangru
You can make money with COBOL. Does it make it the best language? Considering
that you can make money with any other language as well?

~~~
hu3
You're comparing COBOL with a language that has namespaces, traits, closures,
reflection and just gained a JIT compiler, named arguments, annotations and
match expressions.

Exhibit A of your parent's point.

------
ausjke
I heard about PHP is really just used by wordpress and drupal to keep its
popularity ranking these days, and new projects seldom adopt it based on
google trends, is this true?

The new PHP7/8 is certainly exciting, is it too late?

~~~
kugelblitz
I do contract development work, haven't touched Wordpress in 10 years, never
touched Drupal. I mostly work with the Symfony and Laravel frameworks.

