Advent of Functional PHP: Review
Over the last few weeks, I’ve been following Advent of Code 2021, using Functional PHP as an approach. It’s been a fun and educational process, at least for me and apparently for a few other people, at least given how popular the articles have been.
For reference, the full list of articles in this series is here:
29 December 2021 – 7:10pm
Advent of Functional PHP: Day 10
For the 10th Day of Advent of Code, we’re asked to solve a matching braces problem. This is a common parser exercise, but it’s made a bit more complex in this case by using multiple types of braces. Specifically, we’re handling a series of lines that contain
), but also
The story jazzes it up as being the code of our submarine's navigational computer, which consists entirely of braces in a sort of eldritch horror version of brainfuck, but that's mostly just a distraction.
24 December 2021 - 7:14pm
Just days after its official release, we are thrilled to announce the immediate availability of PHP 8.1 for all Grid plans projects. The new PHP foundation releases a new main version every year at the very end of November, and It’s some kind of early Christmas for us developers and application makers.
Sparks and acceleration PHP 8.1 comes with many new and long-expected features such as Enums, Readonly properties, First-class callable syntax, and new in initializers.
Advent of Functional PHP: Day 8
Advent of Code Day 8 was, to put it mildly, a pain in the ass. There’s a couple of reasons for that. It’s a naturally tricky problem, it’s hard to genericize, and it’s explained fairly badly. It took a while but with some help from others I was finally able to figure out (and refactor to) a good, functional solution to it. So let’s dive in.
The problem boils down to one of encryption. Our input is several lines that all look like this:
acedgfb cdfbe gcdfa fbcad dab cefabd cdfgeb eafb cagedb ab | cdfeb fcadb cdfeb cdbaf
Where each letter corresponds to one segment in an LED display for a number. Each number appears once on the left side, which is enough for you to figure out what letter corresponds to what segment. Then we need to use that knowledge to decode the numbers on the right and figure out what the number is.
20 December 2021 – 10:06am
PHP 8.1 is the first minor release in the PHP 8 series, and comes with its own new features and deprecations. Let’s see what’s in store for you early adopters
Listen as hosts Cal Evans and Khayrattee Wasseem talk with Sara Golemon, Joe Watkins, and Sebastian Bergmann about the newly formed PHP Foundation.
The post Ep#366 – Interview with The PHP Foundation appeared first on Voices of the ElePHPant.
Listen and hosts Cal Evans and Khayrattee Wasseem talk with Sara Golemon, Joe Watkins, and Sebastian Bergmann about the newly formed PHP Foundation.
The post Interview with The PHP Foundation appeared first on Voices of the ElePHPant.
PHP Internals News: Episode 96: User Defined Operator Overloads
Thursday, December 16th 2021, 09:24 GMT
In this episode of “PHP Internals News” I chat with Jordan LeDoux (GitHub) about the “User Defined Operator Overloads” RFC.
The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode’s MP3 file, and it’s available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news
- Derick Rethans 0:14
Hi, I’m Derick. Welcome to PHP internals news, a podcast dedicated to explaining the latest developments in the PHP language. This is episode 96. Today I’m talking with Jordan, about a user defined operator overloads RFC that he’s proposing. Jordan, would you please introduce yourself?
- Jordan LeDoux 0:33
My name is Jordan LeDoux. I’ve been working in PHP for quite a while now. This is the second time I have ventured to propose an RFC.
- Derick Rethans 0:44
What was the first one?
- Jordan LeDoux 0:45
The first one was the “never for parameter types”, which was much more exploratory. And we talked about it a little bit. And it generated a lot of good discussion that contributed to kind of the idea formation, which was what I hope to get out of it.
- Derick Rethans 1:01
Okay, but that didn’t end up making it into a PHP release. As far as I understand, right?
- Jordan LeDoux 1:07
No, I withdrew it actually, it was clear that the better way to approach the problem it was trying to solve was with a much more comprehensive solution. That particular solution was something that only required a seven line change to the engine. So I wanted to see if it was something people were okay with, or thought was a decent idea for that particular problem, much more comprehensive, like template classes, or something like that is probably the better route to go.
- Derick Rethans 1:35
Well, I think the RFC that we’re talking about today, is going to require quite a bit more than seven lines of code?
- Jordan LeDoux 1:41
Quite a bit more. Yeah.
- Derick Rethans 1:42
So what is this RFC that we’re talking about today?
- Jordan LeDoux 1:45
Well, user defined operator overloads is a way for PHP developers to define the ways in which objects interact with specific operators. So for instance, the plus operator, the plus sign. It’s a way for those objects to kind of define their own logic as far as how that’s handled, which right now, as of PHP 8.0, those were all switched to type errors. So it’s not possible currently to write any code that doesn’t result in a fatal error, where objects are used with operators.
- Derick Rethans 2:25
Usually, I ask about every RFC, what problem are you trying to solve this? So what problem are you trying to solve this RFC?
- Jordan LeDoux 2:31
The biggest problem that this solves is that objects contain, so objects in most programs represent a value or multiple values that have a program context. That’s the most powerful thing about objects is they’re contextual, and they understand the state, they understand what state the object is in, and sometimes even what state the whole program is in. And that’s necessary for a lot of things. Like for instance, if you’re tracking a distance, you know, you might measure that meters, and that would have a number you might have 30 meters of distance, but it also has a unit of meters. You could just represent that as an int. And
Truncated by Planet PHP, read more at the original (another 32660 bytes)
PHP 8.1 is out and the hip new feature for non-blocking and asynchronous programming in PHP are fibers. In this post
we’re going to explore them and see how we at ReactPHP will start with them at the edge.
Photo by Dids from Pexels