PHP Doesn't Suck Anymore? | Prime Reacts
الملخص
TLDRThe video discusses the evolution of PHP since 2012, showcasing various enhancements that make it a more modern and efficient programming language. The presenter shares personal experiences with PHP, reflecting on the frustrations and newfound excitement associated with its newer features such as traits, array destructuring, null coalescing operators, and type safety. A humorous narrative engages viewers while emphasizing that PHP is far from 'dead' and is indeed a powerful tool in today's programming landscape.
الوجبات الجاهزة
- 🚀 PHP has evolved significantly since 2012!
- 🎉 Introduction of traits for code reuse.
- 📉 PHP's performance has improved by 400%!
- 🔮 New features include arrow functions and named arguments.
- ✍️ Null coalescing simplifies variable assignment.
- 🔃 Enums offer a structured way to handle constants.
- 🔍 Type safety reduces coding errors.
- 📏 PHP introduces trailing commas for cleaner syntax.
- 💡 Generators allow memory-efficient operations.
- 🤔 PHP is far from dead; it's thriving!
الجدول الزمني
- 00:00:00 - 00:05:00
The speaker discusses his long-term relationship with PHP, expressing frustration at comments claiming it is 'dead.' He reflects on his early experiences with PHP in 2013, highlighting the technological stagnation he felt at that time.
- 00:05:00 - 00:10:00
Acknowledging the need for type safety in PHP, the speaker anticipates discussing language improvements since 2012, specifically PHP 5.4, where features like traits were introduced to enhance code organization and composition.
- 00:10:00 - 00:15:00
As PHP evolved, the speaker appreciates the introduction of conveniences like array destructuring and variadic functions, noting the changes that allow developers to write cleaner and more efficient code. He expresses mixed feelings about these features but acknowledges their usefulness.
- 00:15:00 - 00:20:00
He discusses the null coalescing operator and naming arguments, highlighting how these advancements improve code readability and quality. The speaker shows excitement at PHP's shift towards modern programming practices with recent language updates.
- 00:20:00 - 00:25:42
Finally, the speaker emphasizes PHP's performance improvements, dispelling the myth of its slowness with statistical evidence. He encourages viewers to see the current state of PHP as a robust option for many applications, distinguishing it from outdated perceptions of the language.
الخريطة الذهنية
فيديو أسئلة وأجوبة
Has PHP changed since 2012?
Yes, PHP has undergone significant improvements since 2012, including new features such as traits, array destructuring, and type hinting.
What are traits in PHP?
Traits allow for code reuse in classes, promoting composition over inheritance.
Is PHP still relevant in modern programming?
Absolutely, PHP continues to evolve and includes many modern programming features.
What is the purpose of null coalescing in PHP?
It allows developers to simplify assignments by providing a default value if the initial value is null.
Has the performance of PHP improved?
Yes, PHP has experienced significant performance increases, with much faster execution times in recent versions.
What new syntax features have been added to PHP?
New features include trailing commas, arrow functions, and named arguments.
What languages was PHP compared to in the video?
The presenter compared PHP to JavaScript and Go, discussing PHP's advancements over time.
What are enums in PHP?
Enums allow for defining a set of named constants, improving the organization of code.
What is type safety in PHP?
Type safety ensures that variables are of a specific type, reducing errors in code.
What is the overall message about PHP?
The video encourages viewers to reconsider their negative perceptions of PHP, highlighting its growth and capabilities.
عرض المزيد من ملخصات الفيديو
I've read 613 business books - these 16 will make you RICH
The Sadistic Trash-Bag Serial Killer Preying on Innocent Women | New Detectives | Real Responders
Can narcissists change?
The Flu May Cause Alzheimer's
There's No Such Thing As 'Reverse Racism' - Sho Baraka
How To Approach ANY GIRL in Public And Hold A Conversation!!(INFIELD)
- 00:00:00let's do this every time I make a video
- 00:00:01on PHP which is basically all the videos
- 00:00:03I make I get the exact same
- 00:00:07comment dead PHP sucks all the time
- 00:00:10every time and most of the people that
- 00:00:13think PHP is dead haven't looked at PHP
- 00:00:16since like 2012 which is okay so maybe
- 00:00:19he is saying exactly my experience which
- 00:00:22is I haven't looked at PHP since 2012
- 00:00:242013 I think the last time I kid you not
- 00:00:27I was such a PHP dork that in 20 13
- 00:00:30there's get there's Go I mean node was
- 00:00:34technically taking off I started a new
- 00:00:39project I this was back when I was
- 00:00:41trying to do startups I was always
- 00:00:42trying to do little tool startups and
- 00:00:43all that and uh I started a new project
- 00:00:46using tortois SVN and PHP okay 2013 I
- 00:00:51did that in 2013 I want you to know that
- 00:00:53right now because if you don't know that
- 00:00:55you just don't understand how painful my
- 00:00:56life was I didn't know about all these
- 00:00:58cool things you know this is back in
- 00:01:00back in that day when I wasn't I
- 00:01:02wasn't in my exploratory phase but
- 00:01:05nonetheless tortois SVN in the day of
- 00:01:07get 45.4 came out and listen things were
- 00:01:11a lot different in 2012 I had just
- 00:01:13graduated college a degree in accounting
- 00:01:16for some reason this guy was still the
- 00:01:19president over here this mov many and
- 00:01:22honestly pretty good movie our music
- 00:01:25okay first off can we just agree that
- 00:01:27Looper was actually a pretty good show
- 00:01:29okay whatever that guy's name is Joseph
- 00:01:31Gordon Wyatt levit something like that I
- 00:01:34like him okay I loved him on Third Rock
- 00:01:36From the Sun okay I loved him there
- 00:01:39Tommy I believe was his name and I I
- 00:01:41love it now okay yeah I like it Bruce
- 00:01:44Willis okay actor but Joseph Gordon
- 00:01:47Wyatt levit whatever his name is loved
- 00:01:50him went through this real weird hey ho
- 00:01:53phase where we were always shouting hey
- 00:01:55ho in the
- 00:01:58songs hey
- 00:02:00I think it's safe to say that a lot of
- 00:02:03I'm no longer an accountant and PHP no
- 00:02:06longer sucks I'm going to run you
- 00:02:07through a bunch of the language changes
- 00:02:09that have happened since around 2012
- 00:02:11when PHP 5.4 came out and stick around
- 00:02:14to the very end because we're going to
- 00:02:16talk about types we got to talk about
- 00:02:17type safety every time I talk about PHP
- 00:02:20people just say yeah I just need types
- 00:02:21we got to have types what about types do
- 00:02:23you guys have tipes like yes this is me
- 00:02:25I'm this person I'm literally that
- 00:02:27person are you winning son
- 00:02:31are you winning son no I am not winning
- 00:02:34son I must have types it's the same
- 00:02:36reason why I didn't choose Elixir as my
- 00:02:38first functional language but instead o
- 00:02:39camel because o camel is a very strict
- 00:02:42beautiful static typing language and so
- 00:02:45this is like this I've always had this
- 00:02:47problem uh I do want to follow up on one
- 00:02:49more thing he said that I was such a PHP
- 00:02:51Fanboy and that was during the height of
- 00:02:54my like maximum hours I worked per week
- 00:02:56I was doing like 80 hours a week of PHP
- 00:02:595.4 or whatever it was I was into PHP so
- 00:03:02I'm actually excited to see the new
- 00:03:04things that have happened to PHP since
- 00:03:05then and can I like feel that it's a
- 00:03:08good language I don't know I don't know
- 00:03:09I'm willing to have my mind remain open
- 00:03:11for this can't leave my types we've got
- 00:03:15types so I'm going to show you all the
- 00:03:17different types you can do at the end
- 00:03:19let's take PHP beat JavaScript to
- 00:03:24types you should feel bad about yourself
- 00:03:27if the language in which the original
- 00:03:30author said it should have never been a
- 00:03:32language was able to beat you to
- 00:03:37types you should feel bad about yourself
- 00:03:39okay you came
- 00:03:41out like this just feel bad take a look
- 00:03:44at these changes going all the way back
- 00:03:46to 2012 for this one PHP 5.4 included
- 00:03:49traits so instead of writing the same
- 00:03:52method body over and over and over or
- 00:03:54instead of abusing inheritance we now
- 00:03:56have composition so you can have traits
- 00:03:59and include those in every
- 00:04:02class
- 00:04:07what oh sh I think I like PHP oh my
- 00:04:13goodness
- 00:04:15what favoring composition over
- 00:04:18inheritance PHP is actually better than
- 00:04:24JavaScript I can't even believe it it's
- 00:04:28real
- 00:04:30it's real look I even put my name in
- 00:04:31there what a nice guy short array syntax
- 00:04:34imagine writing out the word array like
- 00:04:38a caveman when you can just use square
- 00:04:40brackets short array syntax allows you
- 00:04:42to use square brackets thank you very
- 00:04:44much let's go thank you we now have
- 00:04:46array destructuring it used to be that
- 00:04:48you have to assign an array to a
- 00:04:50temporary variable and then reference
- 00:04:52those Elements by index if you wanted to
- 00:04:55assign them to other variables now you
- 00:04:57can just use array destructuring and
- 00:05:03D PHP actually is it's going to is it
- 00:05:06really going to be a good language this
- 00:05:07trait thing just blew me away and now
- 00:05:10they're just doing basic conveniences
- 00:05:11for every developer this is good this is
- 00:05:14good like PHP welcome welcome to Modern
- 00:05:17programming I like what I'm seeing
- 00:05:18directly assign the variables from the
- 00:05:21array we have first class vartic
- 00:05:23functions so you can pass as many
- 00:05:25arguments to a function as you want
- 00:05:27using this I don't know how I feel about
- 00:05:29vartic arguments I keep going back and
- 00:05:31forth on them like if they're a good
- 00:05:32idea or a bad idea I never know do you
- 00:05:35know what I mean
- 00:05:36like do I like them or do I not like
- 00:05:39them because ultimately whenever I get
- 00:05:42to vartic arguments I almost always want
- 00:05:45to use a function with an array as AO or
- 00:05:48a list as opposed to actually spelling
- 00:05:50out the arguments one by one I almost
- 00:05:52never actually
- 00:05:54want vartic arguments like almost never
- 00:05:58Almost Never there because any anytime
- 00:06:00you're doing something programmatically
- 00:06:02you almost always this right here right
- 00:06:05you almost already have the nums array
- 00:06:07and now you have to dot dot dot yeah
- 00:06:08print f is a good example where it's
- 00:06:10really really good but print f is
- 00:06:12unusual you don't really use like
- 00:06:14formatting functions I'm on for vartic
- 00:06:17stuff I can completely concede that
- 00:06:20ground and things like formatting or
- 00:06:22string uh uh like rope string generation
- 00:06:25anything like that totally on board with
- 00:06:27that dot dot syntax
- 00:06:30speaking of dot dott dot syntax you can
- 00:06:31use that same syntax to spread or Splat
- 00:06:35an array into an argument list for a
- 00:06:37function ddy you use that same syntax to
- 00:06:41spread or Splat an array into another
- 00:06:44array so if you want to take all the
- 00:06:45items from one array and put it into a
- 00:06:48second array you can do that again this
- 00:06:50is very very good also very very
- 00:06:52interesting uh because this is a great
- 00:06:55way to create a lot of memory on
- 00:06:56accident that with this spread operator
- 00:06:59we now have generators if you want to do
- 00:07:02something memory intensive but in a
- 00:07:04memory efficient way you can use a
- 00:07:06generator so if you need to read a huge
- 00:07:08file you don't have to load that whole
- 00:07:10file into memory you can use a generator
- 00:07:12to yield it line by line by line if you
- 00:07:15ever need a new class but can't be
- 00:07:17bothered to make a new file who has the
- 00:07:19time you can create an anonymous class
- 00:07:21an
- 00:07:23an let's go I love that I love this idea
- 00:07:30that that classes are just as much first
- 00:07:33class citizens as functions this is
- 00:07:35great this is great because there are
- 00:07:37times where you just don't want to do
- 00:07:39that and you really just need this right
- 00:07:41here this is great this is actually
- 00:07:43great wow PHP has aous class can
- 00:07:46Implement an interface okay I you know
- 00:07:48we're pausing this for a quick second
- 00:07:50I'm hopping over to Twitter and maybe
- 00:07:53PHP isn't all that bad
- 00:07:58anymore
- 00:08:00I am I'm we're shook okay we're shook
- 00:08:04right now we're shook Oh
- 00:08:08no just like every other class so this
- 00:08:11is a great use case for when you need
- 00:08:13one stupid little implementation but you
- 00:08:15don't want to make a full class for it
- 00:08:17yeah this is a big one I need you to pay
- 00:08:20very very close attention we now have
- 00:08:21trailing commas in function calls so
- 00:08:25look very closely at email look at the
- 00:08:27very end of the word email and watch
- 00:08:29what's about to
- 00:08:38happen
- 00:08:39oh oh my
- 00:08:42goodness oh boy I actually just added a
- 00:08:44brand new emote just last night there
- 00:08:46you go thank you can we get some WS in
- 00:08:48there we need some wets that this is
- 00:08:50just what I want this is what I want can
- 00:08:52we get some WS I I need I need it I feel
- 00:08:55it this is wet ass programming going on
- 00:08:57right now oh my my goodness oh my
- 00:09:00goodness
- 00:09:02what oh love it I love it I love it
- 00:09:08amazing we now have trailing commas in
- 00:09:11method calls PHP rules this one's for
- 00:09:14all okay well okay trailing commas ain't
- 00:09:17making PHP rule but I okay I'm on your
- 00:09:20team though it's pretty nice okay my
- 00:09:23JavaScript friends I know you love your
- 00:09:25arrow functions well look out friends
- 00:09:28we've got Arrow function to RS honestly
- 00:09:31are well they're they're a little bit
- 00:09:33worse I don't like the FN at the
- 00:09:34beginning to denote that it's a function
- 00:09:36but hey we were I actually like the FN
- 00:09:39at the beginning real talk I like that I
- 00:09:41actually
- 00:09:42I I've never really loved the Aros
- 00:09:46syntax I like the idea of it being very
- 00:09:50consistent I like this this is perfectly
- 00:09:52fine with
- 00:09:53me this is
- 00:09:55beautiful work with what we've got we
- 00:09:58have short short closures or Arrow
- 00:10:01functions php7 brought us the null
- 00:10:04coalescing operator so we can say the
- 00:10:07username is equal to the username unless
- 00:10:10the username is null in which case we'll
- 00:10:12go with guest so we have this nice neat
- 00:10:14null coalescing operator but we also
- 00:10:17have the null coalescing assignment
- 00:10:19operator which can shorthand all of that
- 00:10:21and say if the username is set leave it
- 00:10:23alone otherwise set it to
- 00:10:26guest I understand what a PHP gasm is I
- 00:10:29think I just had multiple PHP gasms in a
- 00:10:32in a matter of minutes okay I don't know
- 00:10:34what's going on
- 00:10:36here but we're gming okay whatever it is
- 00:10:39it's happening right now it's happening
- 00:10:43speaking of nulls we used to have to do
- 00:10:45something like this we would pull the
- 00:10:47birthday off of the user and then before
- 00:10:49we were allowed to call a method on
- 00:10:51birthday we would check to see if
- 00:10:53birthday existed yep you don't want to
- 00:10:55call a method on null but now we have
- 00:10:58the null chaining operator and we can
- 00:11:00just say if birthday is not null call
- 00:11:03the format function on it if it is null
- 00:11:05just stop the chain right there we have
- 00:11:08named arguments now it used to be that
- 00:11:10if you wanted to skip over an optional
- 00:11:12argument you had to leave a null in the
- 00:11:14position of that argument but now we can
- 00:11:16just name our arguments and pass them in
- 00:11:18any order that we want PHP has
- 00:11:21attributes now which in other languages
- 00:11:22are probably called annotations but you
- 00:11:24can add an
- 00:11:27annotation
- 00:11:31I actually like this okay I like that I
- 00:11:34don't care what you have to say okay you
- 00:11:36come in here with your oh PHP is
- 00:11:38becoming C okay first off PHP doesn't
- 00:11:42have a history of Triple E actions slash
- 00:11:45they didn't give us the world they
- 00:11:47didn't give us vs code I mean they did
- 00:11:49give us WordPress which one could argue
- 00:11:51is worse than vs code but nonetheless
- 00:11:54look this looks great okay I love this
- 00:11:56kind of stuff this kind of stuff to me
- 00:11:58is fantastic I've never had a huge
- 00:12:00problem with this uh because you know at
- 00:12:03the end of the day you you have this you
- 00:12:05have this whole problem with like go you
- 00:12:08have to like specify everything and it
- 00:12:09can kind of look a little you know I'm
- 00:12:11over here maybe my go is not that great
- 00:12:13yet I you know I but you know this kind
- 00:12:15of stuff where you're just like doing
- 00:12:16this you know I I don't know how I feel
- 00:12:18about that either you know what I mean
- 00:12:21to a class or meage or an argument or
- 00:12:23property you can add an annotation to
- 00:12:25almost anything and control a little bit
- 00:12:27of behavior that way
- 00:12:29keep this in mind we're going to look at
- 00:12:31this again in a second this one is just
- 00:12:33a huge massive Improvement it used to be
- 00:12:36when you were catching an exception you
- 00:12:38had to have a variable for that
- 00:12:39exception even if you weren't going to
- 00:12:41use it even if you were just simply
- 00:12:42going to return false you had to have
- 00:12:44that little e in there now look at this
- 00:12:47watch this watch that e amazing no
- 00:12:49longer needed if that's not reason
- 00:12:51enough to switch to PHP I don't know
- 00:12:53what to tell you remember those
- 00:12:55attributes that I told you about
- 00:12:56literally two seconds ago there's an
- 00:12:58attribute that will will mark an
- 00:12:59argument as sensitive and redact it from
- 00:13:02all stack traces so you don't
- 00:13:03accidentally end up logging something
- 00:13:05you shouldn't at a language level very
- 00:13:09okay that is genuinely awesome this is
- 00:13:11genuinely awesome this is actually okay
- 00:13:13so this is one of those things that I I
- 00:13:15I I would say is is super cool that is
- 00:13:18super cool can we all agree that that is
- 00:13:20out of out of this world this
- 00:13:23is this is great weird and probably very
- 00:13:26slow maybe uh maybe it's only slow on
- 00:13:29the exception case one could imagine
- 00:13:31that it's slow purely on the exception
- 00:13:33case right uh and it has no real world
- 00:13:37imp implications on uh on performance in
- 00:13:40any sense cool look at this switch
- 00:13:43statement it's hideous it's huge we hate
- 00:13:45it what we're doing is we're switching
- 00:13:47on a status code and then in the body of
- 00:13:49every status we're setting a message
- 00:13:51variable there's got to be a better way
- 00:13:54there is a better way we can use the
- 00:13:56match statement now and assign the
- 00:13:58message message variable to the result
- 00:14:00of the match statement and look at 200
- 00:14:02300 we can have multiple matches return
- 00:14:05the same thing this is a much more
- 00:14:07compact much more readable way to write
- 00:14:10a switch statement that assigns a
- 00:14:12variable we've got weak Maps now did you
- 00:14:14know that PHP has weak maps you can set
- 00:14:16an object as a key in a weak map where
- 00:14:18you can't you can't do that in an array
- 00:14:21and also weak maps are way better for
- 00:14:23memory because they'll get garbage
- 00:14:25collected when there's no references to
- 00:14:27that object anymore PHP now has enums so
- 00:14:29you can have an enum class where you
- 00:14:31delineate the cases inside the body of
- 00:14:33that class and those enums can also have
- 00:14:36a value so if you want to use the words
- 00:14:38draft published and archived in I mean
- 00:14:42this is this ain't that that impressive
- 00:14:44okay you know like you've been like I've
- 00:14:46been having nothing but i' I've had
- 00:14:48however many section gasms that are
- 00:14:50available and then you just hit me with
- 00:14:51a basic enum this this ain't it okay
- 00:14:54this this this a this ain't impressing
- 00:14:56me right now your codebase but you want
- 00:14:57to use the value use 1 2 and three in
- 00:14:59your database you can do that with a
- 00:15:02backed enum that's not all that enums
- 00:15:04can do you can add methods to your enum
- 00:15:06classes in this case We'll add a method
- 00:15:08that gives a userfriendly display to
- 00:15:10each of the using the match statement
- 00:15:13again and we're just matching against
- 00:15:15this and all of our cases are our enum
- 00:15:18cases one of the great things about
- 00:15:21having I mean it's still better than
- 00:15:22typescript enums can we all agree that
- 00:15:23somehow typescript enums are actually
- 00:15:26worse you know like at the the end of
- 00:15:29the day as much you want to talk
- 00:15:30about that enum that we just saw somehow
- 00:15:34it's still wors okay Beast stop with
- 00:15:37your C it's not C it's PHP I love today
- 00:15:41okay birthday boy bisco by the way
- 00:15:42YouTube you better wish bisco happy
- 00:15:45birthday in the comments okay I expect
- 00:15:47to see it I expect at least a hundred
- 00:15:50happy birthdays when this video goes out
- 00:15:53first class enums is you can now use
- 00:15:55them as typ hints so if a method is
- 00:15:58expected an enum you can hint that enum
- 00:16:01class and that way PHP will validate
- 00:16:04that the incoming argument is that enum
- 00:16:07all right here we go we're going to run
- 00:16:08through a bunch what does that mean
- 00:16:10validate uh I'm curious what that means
- 00:16:12if you just pass in any old in will it
- 00:16:14say hey I can't validate it or will it
- 00:16:16throw an exception if it doesn't match
- 00:16:18does it have runtime implications a
- 00:16:20little bit more curious about that last
- 00:16:21one okay so this is the big one this is
- 00:16:23the big one types types and more types
- 00:16:24ways you can add types to PHP first you
- 00:16:27can have typed arguments in this we say
- 00:16:29A and B must both be integers this is a
- 00:16:32scalar type hint You could also type
- 00:16:33hint classes or enums like we showed
- 00:16:35earlier you can have return types in
- 00:16:37this case we're saying it must also
- 00:16:39return an integer that makes enough
- 00:16:41sense if you're adding two integers
- 00:16:43together it should return an integer but
- 00:16:46not all numbers are integers some
- 00:16:48numbers are floats so you can also have
- 00:16:50Union types you can say int or float
- 00:16:53rock on rock on on that one I'm liking
- 00:16:57that I'm liking that a lot
- 00:16:59and it can return an INT or a float if
- 00:17:01you wanted to add more than two numbers
- 00:17:03together and you have a Vari adic
- 00:17:04function you can also use types for that
- 00:17:06no problem let's move on to a class here
- 00:17:08we're saying that the argument input
- 00:17:10must be of type Fu or bar this is the
- 00:17:12union type that we just talked about but
- 00:17:14you can also by the way I'm much more I
- 00:17:17like Types on this side as opposed to
- 00:17:19the other side call me crazy but I like
- 00:17:22to read the type before I read the
- 00:17:23variable name as opposed to reading the
- 00:17:25variable name followed by the type okay
- 00:17:27so you know like rust go and typescript
- 00:17:29all have variables on that side whereas
- 00:17:31like C you know that's kind of what I
- 00:17:33grew up on was like C and Java you know
- 00:17:36it's it's on the other side for me I've
- 00:17:38just always liked it i' there's some
- 00:17:39argument for it right that's all yeah
- 00:17:42yeah you're not crazy it CPP shill maybe
- 00:17:46uh type left uh stick in my brain yeah
- 00:17:48it does are you crazy called it come on
- 00:17:50pick you know it's just just just feels
- 00:17:54right you know what I mean uh you know
- 00:17:56and I also think that int array is
- 00:17:58better than an array of int you know I I
- 00:18:01I just don't I you know that's one thing
- 00:18:03about go that always kind of irks me a
- 00:18:04little bit but you know the fact that go
- 00:18:06compil super super fast I don't give a I
- 00:18:08don't give a damn you know what I mean
- 00:18:10if you can if you can compile an entire
- 00:18:12project in zero seconds you you know
- 00:18:14what tell me how you define your ins I
- 00:18:16I'm just fine with that you tell me and
- 00:18:19I don't care like right like I have
- 00:18:21various levels of what I care about and
- 00:18:22that ain't it uh Hey thank you King I'll
- 00:18:24say thank you in a second we're kind of
- 00:18:25you know we're we're like in the middle
- 00:18:27of something okay you know what I mean
- 00:18:28you know what I mean dog okay it's
- 00:18:30BEAST's birthday so I want you to say
- 00:18:31happy birthday to him have an
- 00:18:33intersection type where you say that the
- 00:18:35argument input must be of type Fu and
- 00:18:38bar which is really helpful when you're
- 00:18:40trying to ensure that an argument
- 00:18:41adheres to more than one interface but
- 00:18:44you don't care what the type of object
- 00:18:46is as long as it aderes to food and bar
- 00:18:49you can do whatever you need to do you
- 00:18:51want to get even crazier if you want to
- 00:18:53ensure that input is Fu and bar or it's
- 00:18:56nullable you can have a dis Jun normal
- 00:18:59form type and I had
- 00:19:01to he's about to say I had to go look up
- 00:19:04that but a disjunctive normal form type
- 00:19:06that literally sounds like a disease you
- 00:19:08would be classified with with your
- 00:19:10doctor
- 00:19:12um it looks like you have disjunctive
- 00:19:14normal form type learn those words for
- 00:19:17this specific video you can have Fu and
- 00:19:20bar or allow it to be null let's by the
- 00:19:22way pick right now is like actually it
- 00:19:25has pick I Can Feel It Coming pick I
- 00:19:28know what you look at this uh that's
- 00:19:30something that will make your uh your
- 00:19:32balls
- 00:19:33fall I thought you going to give me some
- 00:19:35insightful comment pick I actually
- 00:19:37thought I was going to get an insightful
- 00:19:39comment instead I got this is g to make
- 00:19:43your balls
- 00:19:47fall so why you know this the benefit of
- 00:19:50doing things live you know what I
- 00:19:53mean look at another example we've been
- 00:19:55typing arguments but you can also have
- 00:19:57typed properties so if you look at this
- 00:19:59class see that the public title property
- 00:20:02is of type string and the public date
- 00:20:04property is of type date time now this
- 00:20:07is a little repetitive isn't it we've
- 00:20:09got the two proper we've got the two
- 00:20:11arguments in the Constructor and then in
- 00:20:13the Constructor we have to set the class
- 00:20:15level properties I totally forgot that
- 00:20:17you have to do two underlines for
- 00:20:19construct is that was that always
- 00:20:21true was this always true I just I I
- 00:20:25honestly can't remember it it's shocking
- 00:20:27that I could do something for 80 hours a
- 00:20:28week for multiple years and forget
- 00:20:30it this is a little verbose this is how
- 00:20:33we used to have to do it until the PHP
- 00:20:35Gods introduced Constructor property
- 00:20:37promotion and now you can put the
- 00:20:39visibility in your Constructor signature
- 00:20:42you can say public string title and it
- 00:20:44will end up as a public property on your
- 00:20:46class this I actually do like that that
- 00:20:48t typescript also has this I'm not sure
- 00:20:51if that's a JavaScript thing or just a
- 00:20:52typescript thing but I've always liked
- 00:20:54I've always liked this I think this is
- 00:20:55very very good I don't want to have to
- 00:20:56specify things twice always been been a
- 00:20:58big fan uh C the C is called Constructor
- 00:21:02promotion I don't love that you end up
- 00:21:04with an empty Constructor body but I do
- 00:21:06love that it reduces all of that boiler
- 00:21:08plate if you want to Mark a property as
- 00:21:10read only meaning that it can only be
- 00:21:12initialized once and then never changed
- 00:21:15there's a keyword for that you can say
- 00:21:16that a property is read only and you can
- 00:21:19do that in the Constructor as well if
- 00:21:21your entire class is read only you can
- 00:21:23mark the class as readon instead of
- 00:21:25marking each individual property as only
- 00:21:29a lot of stuff has changed if you have
- 00:21:30by the way that actually is like these
- 00:21:32type of changes also allow the just in
- 00:21:35time compilation stuff to be much better
- 00:21:37right you can do a lot more with a
- 00:21:40language when you have more hints the
- 00:21:42more things you have the faster you can
- 00:21:44make it right the less you know about a
- 00:21:46language the less you can really do you
- 00:21:47have to like that's why in JavaScript if
- 00:21:50you ever look at the memory of any uh
- 00:21:52piece of JavaScript what you'll see is
- 00:21:54that there's all these hidden pieces of
- 00:21:56memory and they're like 30k 50k 10K
- 00:21:59Associated effectively with every single
- 00:22:02function because every single function
- 00:22:04has a huge amount of assumptions being
- 00:22:07calculated and kept track of such that
- 00:22:09it can optimize it at some point right
- 00:22:12and optimization is a function of length
- 00:22:14of your of your function which is also
- 00:22:16bizarre right so as your function gets
- 00:22:19longer the more runs it has to take the
- 00:22:21more memory it takes to actually
- 00:22:23optimize it the more things it has to
- 00:22:24keep track of it's very very uh it's
- 00:22:27very interesting and so
- 00:22:28PHP with inside like typing and all that
- 00:22:31I think that you can do a lot more cool
- 00:22:33stuff with how fast it runs by simply
- 00:22:35knowing this information I love it
- 00:22:37paying attention you might think PHP is
- 00:22:39dead but alas it is not dead talk about
- 00:22:41speed every time I make a video people
- 00:22:43are like yeah PHP is so slow PHP between
- 00:22:47like 5.6 and seven experienced a
- 00:22:51400% performance increase and then I
- 00:22:53think another 20% between seven and
- 00:22:55eight I heard you're supposed to talk to
- 00:22:57a doctor
- 00:22:58if you exceed 400% is that still
- 00:23:03true or or is that different
- 00:23:06now or you can go longer than
- 00:23:10400% giggity giggity long as you say
- 00:23:13that is not as slow as you remember so
- 00:23:16if you need something like 50,000
- 00:23:18requests per second you should probably
- 00:23:21still you should probably still not use
- 00:23:23PHP for that but look at me listen to me
- 00:23:25when have you personally needed 50,000
- 00:23:28requests a
- 00:23:29second how many users do you have
- 00:23:33so that was so based that was like the
- 00:23:37most base take of all time right there
- 00:23:40that was so good that was so good dude
- 00:23:43just just get
- 00:23:46wrecked just get wrecked HP is fast
- 00:23:51enough it is fast enough for most of
- 00:23:53your use cases and if you need a
- 00:23:55specialized use case use a specialized
- 00:23:57language but the PHP of your is not the
- 00:24:00same as the PHP of today it is much much
- 00:24:03faster it is much much better and it is
- 00:24:06not dead see you I really liked some of
- 00:24:12the way the ways he said things I really
- 00:24:13like that he called it the PHP of your
- 00:24:15that was beautiful by the way go
- 00:24:17subscribe to Aaron Francis what a great
- 00:24:19guy not only is he a great guy great guy
- 00:24:23when I met him in in IRL but also nice
- 00:24:26guy on Twitter always super positive
- 00:24:29sometimes I think he thinks that I'm a
- 00:24:30little bit of a goober very nice guy go
- 00:24:32give him a follow good guy I like him um
- 00:24:36PHP plus HTM X stream I'm gonna be doing
- 00:24:38golang because I'm cool uh you
- 00:24:42know I'm I'm actually cool but I could
- 00:24:46imagine that if I wasn't cool I would
- 00:24:47consider PHP sorry Aaron for that that
- 00:24:51last part uh
- 00:24:53but
- 00:24:56but Melky I get to do go to okay you
- 00:24:59can't go back to rust I don't want to go
- 00:25:00back to rust right now okay okay I did
- 00:25:02two and a half years of rust and I use
- 00:25:04rust like fulltime now or part-time and
- 00:25:06sometimes you need a break from what
- 00:25:07you're doing okay I don't want to be in
- 00:25:09the rust world anymore I want off that
- 00:25:11wild ride of rust okay o camel then but
- 00:25:15the problem with o camel is nobody knows
- 00:25:17what's happening when you show somebody
- 00:25:19o camel no matter how many times you
- 00:25:21hear in chat it's actually more
- 00:25:22intuitive nobody thinks that okay nobody
- 00:25:26thinks functional programming more
- 00:25:28intuitive and all these people that tell
- 00:25:30you that just have just drank so much
- 00:25:33Kool-Aid they cannot see the forest for
- 00:25:35the trees at all the
- 00:25:38name is I could actually like PHP a j
- PHP
- programming
- development
- traits
- type safety
- null coalescing
- enums
- performance
- modern PHP
- coding