Earlier quoted context omitted.
Correct? I'd probably say predictable.
Eh. If MyPy complains that I'm passing an `Optional[Entity]` into a method where only an `Entity` can go, it's just helped me avoid a runtime error when I try to get `entity.name`. Not sure what the exact PHP equivalent is, but there's all sorts of bugs you can easily introduce if you're not careful with types.
Everything you need (and don't need) to know about PHP's type system
51–60 of 67 posts
Re: Everything you need (and don't need) to know about PHP's type system
#52Is there a good reason to still use php when you can use hacklang ( https://hacklang.org/ ) which has much stronger type system. Some would even call it php++.
A lot of what Hack introduced to the PHP community has become available in suitably forward-thinking ways to allow for a sensible amount of backwards compatibility and are opt-in. For example, you can set strict typing on a per-file basis. `declare(strict_types=1);` I believe that the performance difference between the two is negligible now too. So it really just comes down to personal preference/platform legacy. But…
Re: Everything you need (and don't need) to know about PHP's type system
#53Earlier quoted context omitted.
Eh. If MyPy complains that I'm passing an `Optional[Entity]` into a method where only an `Entity` can go, it's just helped me avoid a runtime error when I try to get `entity.name`. Not sure what the exact PHP equivalent is, but there's all sorts of bugs you can easily introduce if you're not careful with types.
PHP doesn't compile so all errors become runtime errors.
Re: Everything you need (and don't need) to know about PHP's type system
#54> Important to notice that casting an array with numeric keys into an object is valid, but one can't dereference its value because property names may not start with numbers. Not true, actually. The (admittedly obscure) syntax to access a property beginning with a numeral is `$obj->{0}`. Usually when this happens it's because someone was trying to be clever with JSON.
There's another way to get a variable starting with a numeral - abusing extract(), I think.
Re: Everything you need (and don't need) to know about PHP's type system
#55Earlier quoted context omitted.
Eh. If MyPy complains that I'm passing an `Optional[Entity]` into a method where only an `Entity` can go, it's just helped me avoid a runtime error when I try to get `entity.name`. Not sure what the exact PHP equivalent is, but there's all sorts of bugs you can easily introduce if you're not careful with types.
PHP doesn't compile so all errors become runtime errors.
So better typing can definitely help to catch those before pushing and running your code.
Re: Everything you need (and don't need) to know about PHP's type system
#56Earlier quoted context omitted.
It's gotten a lot better since I started using it ~2009 and now. 7.4 added typed properties. 8 is adding better caching, a jit and my favourite feature match() https://php.watch/versions/8.0#match-expression for all the enterprise heavy stuff I write a nicer cleaner and safer (by default) alternative to switch is going to make some code much cleaner to write and read and really that is what I care about more than alm…
Match looks exactly how Rust’s match works and it’s one of my favourite parts of the language. Happy to see it elsewhere too.
Re: Everything you need (and don't need) to know about PHP's type system
#57It actually makes me really happy to see more positive comments on a thread about PHP. It is an incredible workhorse, and doesn't get the credit it deserves. I'm often amused by developers that revile PHP, while going on to use another language, which suffers from a similar set of problems to PHP, oftentimes with poorer performance and more complex toolchains. PHP deserves a little more love, imo.
I'm happy that the language is evolving and there is a strong ecosystem with quality libraries and developers unlike what it used to be 5 years ago.
I've been doing several languages (Scala, and Typescript. also Go recently) in last few years. But, I still follow PHP ecosystem closely and I'd definitely choose it for my next web startup. It's just 10x faster and ultimately cheaper to build web with PHP. That's why there are so many big success stories that started with PHP even in areas that you wouldn't believe. Surprisingly enough, not only web! One of Cloudflare's founders said on an interview that their back-end was written in PHP and it was used for a long time. That's one of the things that you think no one would do.
Re: Everything you need (and don't need) to know about PHP's type system
#58It actually makes me really happy to see more positive comments on a thread about PHP. It is an incredible workhorse, and doesn't get the credit it deserves. I'm often amused by developers that revile PHP, while going on to use another language, which suffers from a similar set of problems to PHP, oftentimes with poorer performance and more complex toolchains. PHP deserves a little more love, imo.
PHP has its special place for every developer that works on web. And it got all recent improvements thanks to all those criticisms. I think every popular language receives criticism and that's just fine. I'm happy that the language is evolving and there is a strong ecosystem with quality libraries and developers unlike what it used to be 5 years ago. I've been doing several languages (Scala, and Typescript. also Go r…
Re: Everything you need (and don't need) to know about PHP's type system
#59Earlier quoted context omitted.
PHP has its special place for every developer that works on web. And it got all recent improvements thanks to all those criticisms. I think every popular language receives criticism and that's just fine. I'm happy that the language is evolving and there is a strong ecosystem with quality libraries and developers unlike what it used to be 5 years ago. I've been doing several languages (Scala, and Typescript. also Go r…
A static (serverless) website hosted on something like github pages or S3 paired with some API calls to an nodejs application running on a single core vm instance, both behind cloudflare, is also extremely cheap and should be able to easily beat php in terms of performance/costs ratio.
JS ecosystem still lacks good reliable vendors and that holds some companies away from it. Surprisingly it's holding up really well even though must of the packages are maintained by individual contributors.
Re: Everything you need (and don't need) to know about PHP's type system
#60PHP rocks in 2020. Couple it with laravel or something and you get a solid platform to build a monolith-type web app with really fast performance.
Isn’t Laravel the worst performing framework out there right now, like even Rails looks like a viable option in terms of speed?