« first day (4172 days earlier)      last day (776 days later) » 

Wes
3:55 AM
python is overrated
 
 
2 hours later…
6:09 AM
posted on March 19, 2022

Two on time comics in a row? What is happening to me?!? I'm as surprised as you are. Speaking of surprises, I hope you like the continuation of the child-based format from last week. I think that's what everyone's been clamoring for all these years: more children. I mean, no one's said anything to that effect, but I'm pretty good at reading between the lines in the comment section. Thank

 
 
2 hours later…
7:56 AM
o/
 
@SaifEddinGmati Moin! Would recording tomorrow morning at 10:30 GMT/11:30 CET work perhaps?
 
@Derick Yes! send me a PM on twitter, or an email with the rest of details :D ( currently heading out )
 
OK
Twitter account?
 
@azjezz
 
 
5 hours later…
1:23 PM
is match faster than switch ?
 
1:38 PM
@Mwthreex Most likely negligible.
 
2:09 PM
Guys, maybe someone can help me with this annoying problem

How could i delete any outputs before and after an array/var_dump/json etc??

Basically i'm just annoyed by the fact that when i print something for debugging i constantly have to scroll to where the rendering happened...
 
@drpzz ob_end_clean(); var_dump(...); die;
 
I'm on wordpress and it still displays me the header etc. I want my chrome extensions to kick in for better coloring etc of the printed arrays
thats the output i'm getting
I forgot to mention that i already tried output buffering
 
@drpzz Yeah you'd also need to start the buffer with ob_start();, but you might be better off just using a proper debugger.
(starting the buffer before you actually write anything to it)
 
Uhmm, okay, any recommendations for a debugger i could use?
 
2:15 PM
Thank you, i'll look into it. Have a great day!
 
@drpzz You're welcome, you too
 
Another thing to note is setting up a dev environment to test changes, so that they're not tested in production
 
2:36 PM
Yeah, i'm on a dev env but it's on a shared hosting platform, i think i'm unable to install xdebug there. It's on a shared hosting because my local env isn't really that good and the performance is lacking
Are there any other options?
 
2:49 PM
@drpzz you should set up a local dev environment
Whether it's docker, a VM, baremetal, xampp
Docker or a VM are preferred because it's easier to recreate what your production environment is like locally, there's less "but it works on my machine"
And no restrictions on using a debugger
But if local absolutely isn't possible, there's stuff like Digital Ocean droplet that gives you a VPS that you can install whatever. Relatively similar to shared hosting, except you have control over what's installed on it, because you've set it up, and you have root access.
 
3:38 PM
github.com/cronlabspl Can somebody block this guy from the php GItHub group? He's the one who suggested to remove NIkitas contributions from PHP to "stop the Russian invasion" (yes, that's gonna help). And now he keeps commenting on random commits.
 
Wait, the bit about removing Russian contributions wasn't an attempt at a humorous joke?
 
It needs to be done by an owner, so @Derick @cmb @JoeWatkins @Sara could do it
https://docs.github.com/en/communities/maintaining-your-safety-on-github/blocking-a-user-from-your-organization
 
@MarkR No, sadly not. I don't think they realize that Nikita and Dmitry are the two people with the most contributions to PHP. Not that much would be left after removing that.
Not to mention that it's absurd and disrespectful.
 
3:56 PM
Guys, a opinionated question for you.

In terms of performance, which is better:
Having a one big query to get all the data and then filter the results with array filter

Multiple queries to get specific requests, no need for array_filter.

I know this is question needs more details but overall, which is better, more queries or more filters/loops?
 
You answered your own question, it needs more details
 
So there is no "better route" right?

Let's say you have a loop that outputs containers, inside that, there are specific sub-containers related to the parent container.

Now would it be more efficient to get all parent and sub containers seperately and then filter the data
or
Getting first only parent containers, looping through them and then querying sub containers based on the parent and then again looping through sub containers to display the output
let's say i have 100 parent containers which each have 100 related child containers
 
@drpzz Why can't you filter on the SQL server?
 
It depends on the size of the dataset, I often loop the parents twice, the first time to collect all of their IDs, then I query the children of all of those IDs and put them in an associative array by that ID, and then I loop again over the parent, and can lookup their children without the need for an individual query for each. Alternatively you can do a sub-query sql side so you don't need to do the first loop
It all depends on how much data you have
 
@drpzz where are you displaying 10,000 items at once? Because that sounds like a 'fun' user interface.
 
4:07 PM
That was an example :D I'm just trynna sort this question out to make my applications perform better
 
> That was an example
 
Honestly this looks like something i'm not equiped to look at haha
 
Profile and optimize. Each case may be different. You may spend more of your own time micro-optimizing than you ever save
 
ok. so. It's a hypothetical question about a made up example, with no details of the actual requirements. That's kind a waste of everyone's time. I realise this is harsh, but there is a room rule against that type of question due to someone's previous behaviour.
Come back with a specific question, and you'll maybe get useful answer.
(and I still think, you should be designing the UI first, not the backend implementation details)
 
@mark
I thnk you're right
@Danack easy now, it was suppose to be an oppinionated question
 
4:13 PM
Morning
 
The thing is, no-one with the knowledge level required is going to have an opinion, because it's not a matter of opinion, it's a matter of measurement and facts.
 
5:11 PM
Is there any purpose in adding (int) if I'm removing all non-numerical chars anyway with regex? $order_id = (int) preg_replace('/[^0-9,.]+/', '', $x);
 
If you're using strict types and you pass it to something expecting an int it'll TypeError
 
hmm... I see.
 
5:33 PM
@StatikStasis Leaving commas is not going to give you the results you want: 3v4l.org/8dLeZ
 
You're right- need to exclude those too
Alright- fixed
 
cmb
@StatikStasis also, preg_replace() might return null
 
I'm checking for that afterward- just trying to sanitize initial $_GET variable.
 
cmb
@IluTov Did he post more "bad" comments? I'm a bit reluctant to block, because that has pretty serious side effects, and the only bad comment I'm aware was the one immediately removed by @Girgias.
 
5:49 PM
The most recent spam comment from him I got is github.com/php/php-src/commit/…
Though I can't say I understand what he's trying to convey with that comment.
 
I don't even know what he means by that, unless just generally harassing.
 
cmb
I've blocked them for 1 day.
 
@NikiC He's subjecting you to misspelling. =P
@MarkR I've been coding a lot lately to music on this channel youtube.com/watch?v=HVIRxqaScB0
 
@IluTov Don't think that's going to fly, as it makes array operations asymptotically more expensive
What should be an O(1) operation becomes O(n) due to separation
 
Oh hi Nikita, are you ready for round two of variance brain frying hell? :D
 
6:01 PM
@StatikStasis youtu.be/gKkzdVW0E3o?t=1687 body heat radio from cyberpunk. Delicate weapon at 29m is <3
 
@Girgias I barely survived the first round :P
Unless maybe ... the generalization has made things simpler?
Or am I just trying to delude myself?
 
I do think it has made it easier, the PR isn't too bad, but I need to get the iterable alising to array|Traversable thing landed
 
@MarkR That is sweet. CyberPunk has a good soundtrack.
 
6:19 PM
@MarkR Another banger in Cyberpunk and streamer NoahJ being funny youtube.com/watch?v=OY_eCg7qTUQ&t=11936s
 
@NikiC But is it fair to compare it to properties or should they be compared to getter/setter functions?
Optionally we could just not allow accessors for array, but yeah... that's obviously not so cool.
 
6:47 PM
@IluTov If you did getter / setter functions for arrays, you'd do something like addXYZ that does the array operation on the property
 
7:06 PM
@NikiC I guess. Although there's multiple ways to modify an array. You'd still have the option to make the property public get; private set, use a generated setter that doesn't need to go through the hoops, and modify it through some adder function. If an adder function is called instead (like Bob suggested) somehow replaying the change onto the array in userland code also won't be free.
Of course, that wouldn't be O(n) at least.
 
7:45 PM
I'm thinking that one can do a bit of opline hopping. Like as in … we mark the variable containing the new array as special. If that variable is accessed (sort of like $this decays to EX(This)), we execute the original oplines

So given something like:
public array $prop { set ($new) { if (somecondition) { do($new); } $this->backingProp = $new; } }
$obj->prop["a"]["b"] = "value";

we evaluate this to in callee (unchanged to todays behaviour):
FETCH_OBJ_W $obj "prop" -> V1
FETCH_DIM_W V1 "a" -> V2
this is, obviously, quite non-trivial. …
but that way round the ASSIGN_DIM would operate on an RC=1 array in the ideal case… and just in the cases where we determine that both (old and new) must co-exist we materialize…
However … with assigns on complex by-value structures like we have here - from an user perspective, how interested is an user in what changes?
Does the user want to see "here, new array" or does he want "hey, we change dimension "a" of the array to value "value""?
 
8:08 PM
Ugh... I'm getting lost in my logic and permissions. hits head on wall
 
@StatikStasis What happened?
 
LOL- nothing really. Just thinking through this code and getting lost in my head with the permissions, thinking through all states, and access allowed depending on states. This is normal for me... =P
Need to get out for a bit.
 
does it make sense for ReflectionClass::getModifiersNames() to return sealed when a class is sealed, but using the class Foo permits Bar {} syntax ( without sealed keyword )?
 
@StatikStasis Good advice.
 
@SaifEddinGmati not really, using "sealed" would be confusing there and I'd then also not document this as sealing… but maybe as "implementator-restricted" or such
 
8:18 PM
so no new bit for ReflectionClass::getModifiers() either? 🤔
 
It's funny that most people who voted no also voted for "permits" only
 
yes 🙃
 
@Tpojka Five stages of coding: Step 1 Denial "This is going to be easy I cannot wait to get started." Step 2 Anger "Ugh... what is wrong?!?" Step 3 Bargaining "I'll do anything if you'll just work... even if it's a different error... please..." Step 4 Depression "I'm the worst coder in the world. I'm not even a developer... I'm an impostor." Step 5 Acceptance "Let's just get it to work... I'll refactor it later."
"I'll refactor it later..." <-- More denial
 
@bwoebi this probably doesn't matter now, but for the future, doesn't it make sense that only people voting "Yes" on the entire RFC, should be able to vote on details? ( in this example, the syntax )
 
@SaifEddinGmati so, you want to encourage dropping the no votes on the last day if it's obvious that "no" will lose?
 
8:24 PM
lol

https://i.imgur.com/tgkZDBW.png
 
haha yeah, basically.
 
how so?

example:

RFC for feature A, provides syntax option C, B, D.

6 people vote Yes, 4 vote No -> Accepted
3 of Yes voters, voted for syntax C, the other 3 voted for B, and the 4 No voters vote for D -> D ends up being the winner.
 
@SaifEddinGmati Just because someone doesn't want something, doesn't mean they don't want input on execution if it passes.
"I don't want to eat burgers tonight... but if we are going to no matter what, can we at least go to [insert burger place.]"
 
@StatikStasis Yes, that's a valid point, but give the example i provided, the 6 people that actually think it would be useful, get the feature, but with syntax they don't think is right.
 
@SaifEddinGmati … yes?
 
8:28 PM
Heading out- later all.
 
So, on the last day of vote period so that people who want to have an opinion swap their vote from no to yes to have their opinions on the secondary vote matter
 
@bwoebi Ah, yea, that makes sense too.
 
@bwoebi I agree that for arrays they'd probably be more interested in what changes than the entire array. I'm just wondering how this could be achieved in a neat API. Something like update(Stack<string|int> $path, mixed $new, bool $unset) (where $new would be null if $unset === true) seems clunky. And also, then applying the changes seems non-trivial for userland code. A return true/false; could probably solve that (apply only if return true;).
 
9:04 PM
@SaifEddinGmati Could you not have done a hierarchical preference? 1st choice, 2nd choice, 3rd choice? So that the preference is weighted?
 
@StatikStasis ah, that would work, but too late now i suppose ^^"
 
There have been RFCs that have had the implementation voted on again if there is some issue with the winner... I think.
 
@StatikStasis <<__Attributes__>>? :p
 
Yep- that was it
@@ and << and some others
 
I haven't voted on the main one yet either, I'd say my response to the RFC is "meh", but if it were to pass, I'd rather use just the permits rather than the sealed + permits
So I voted on the secondary vote while pondering the first
 
9:09 PM
@MarkR why so? and do you think getModifiers()should return a sealed class bit for classes with permits?
 
I couldn't think of a situation that wasn't explicitly badly designed, where a union wouldn't be a better solution.
 
how would union solve this: https://github.com/azjezz/psl/blob/2.0.x/src/Psl/IO/ReadHandleConvenienceMethodsTrait.php#L15

using sealed classes, that trait would be sealed to only `ReadHandleInterface`, so anyone using it, would be forced to implement `ReadHandleInterface`, since the trait itself expect it to be implemented.

nowadays, if one would use that trait without implementing the interface, the error doesn't show up in inheritance, but when calling the method.
 
I'd make the required functions an abstract method on the trait.
Not exactly the same I understand as they wouldn't be tied into the interface name
 
@MarkR sealing can be tied to either classes or interfaces.
sealed interface Option permits Some, None {}
interface Some extends Option {}
interface None extends Option {}
 
What is that meant to achieve that type Option = Some | None would not? (Without breaking basic class design principles)
 
9:23 PM
1. we obviously don't have type aliases
2. shared functionality in case `Option`/`Some`/`None` were classes, not interfaces ( see: https://www.reddit.com/r/PHP/comments/t513pu/comment/hz713yb/?utm_source=share&utm_medium=web2x&context=3 ), this could also be solved by https://wiki.php.net/rfc/tagged_unions, but that is also not a thing )
3. in case those where classes `A` permits `B` & `C`, `A` itself could be used as a type, aside from `B` & `C`, while using type aliases, `A` would not be a type, but an alias for `B|C`.
4. sealing allows for inheritance enforcement, that could also be solved using inheritance requirement feature, but that is also not a thing ( yet? ): docs.hhvm.com/hack/traits-and-interfaces/…
so you have 3 different problems, each could be solved by a different feature ( none of them are implemented yet in PHP ), and another problem that can only be solved by sealing ( that is point number 3 ).
 
As we don't have sealed classes yet either, I'd encourage focusing on the way it would solve these things better than the alternatives if they were made.
 
as sealed classes is the closest to being implemented out of those, i think the other features are to focus on solving the problems mentioned in a way better than sealing, otherwise, there's no need for them.

for example, if tagged enums RFC goes to voting while sealing is a thing, it should focus on why it's better to use tagged enums when sealing offers the same functionality, and more.
by more i mean that tagged enums only solve problem number 2, but not 1, 3, or 4.
 
I wasn't thinking of tagged enums specifically, I was thinking of general purpose type aliases e.g. type Option = Some | None;
 
It's the same thing, type aliases RFC should focus on why it's better than sealing ( i think it has its use cases, and should be a thing, since it would support scalar types as well ), as sealing is only related to objects.

yes, `type Option = Some | None` might be a way to implement Option, but that doesn't cover shared functionality. and none of the other problems mentioned, so i don't think sealed classes RFC has to focus on it ( there's already a section on the RFC about this )
 
Shared functionality?
 
9:36 PM
point 2 :p
any method that can be implemented exactly the same in Some/None, can be part of Option if it's a sealed abstract class.
 
Sure, I get that, but I don't follow how that would not still be possible with Some | None, assuming both extended it?
 
A potential use-case for sealed classes came up in a PR on amphp/socket: https://github.com/amphp/socket/pull/90/files
`SocketAddress` should be sealed to `InternetAddress` and `UnixAddress`. The getType method returns an enum to offer an indication of the address type other than the class name.
 
@Trowski yep, same in PSL ( TCP / Unix ).
 
Though this example would be solved nicely with type SocketAddress = InternetAddress | UnixAddress;
 
in that case you would have:

abstract class AbstractOption { /* shared functionality */ }
class Some extends AbstractOption {}
class None extends AbstractOption {}
type Option = Some | None;

now `AbstractOption` is part of your API, sealing will basically merge the type aliasing with the abstract class.
sealed abstract class Option permits Some, None { ... }
class Some extends Option { ... }
class None extends Option { ... }
 
9:43 PM
AbstractOption would be a hidden implementation detail wouldn't it?
 
Package visibility would help out here.
 
package visibility would be added to the same bag as type aliases, tagged enums, and inheritance requirement.

they are useful, sealing offers a solution to them, might not be perfect to said specific problem ( e.g: sealing doesn't allow you to create an alias for 2 scalars, type aliases do! ).
 
I'll keep pondering, I've not made my mind up yet one way or another.
 
@MarkR hidden using @internal? people ignore comments. i would rather this is enforced by a language feature.
 

« first day (4172 days earlier)      last day (776 days later) »