« first day (3898 days earlier)      last day (1276 days later) » 
02:00 - 22:0022:00 - 00:00

22:00
I don't know how we would make it smaller without undermining one of the documented main use cases.
Intl can do that too
yes, and?
you said they didn't understand strftime(); they seem to be using it exactly as designed to me
Ok, fair enough.
I don't know how much those use cases overlap
Then I don't understand that function
22:03
it's just like date(), only it's not hard-coded to English
I know that other languages do the simple thing, fill from left to right, one place holder, easy to understand
and uses a different set of formatting codes
and then IntlDateFormatter uses a different set again
just to make life interesting
@JoeWatkins But they also designed the functions they are calling with this in mind...
if we're going to accomodate variadics, and named placeholders, it complicates matters, necessarily so ... it's harder to understand and more complex to implement ...
22:04
@JoeWatkins Strictly functional languages, yeah. But... what Levi said.
@NikiC They're discussing the same thing we are, then?
s/placeholders/args/
The bit in the RFC I found particularly funny is the proud proclamation that PHP is going to be the first mainstream language with proper PFA support. You gotta wonder just why that is ;)
Languages that do a lot of partial application tend, like Levi said, to have been built with that in mind, I figure.
That lets it be simpler.
@JoeWatkins Yeah, I don't think it can really be materially simplified. The previous semantics were kind of simpler on a technical level, but less intuitive
@NikiC This says |> is being deprecated in Julia. I wasn't aware of this. Hmm. Going to dig around to see if that's right or if it's just outdated (several years old).
22:08
Retrofitting it onto a language with inconsistent parameter order, optional args, named args, and variadics is... well, there's a lot of moving parts.
@NikiC I'm very glad to hear agreement about that ...
@IMSoP Out of curiosity, if you were to answer a question like that prior to this discussion, what would you use?
> We've been discussing a currying/partial-application shorthand for literally years now, and all of the discussions seem to have been converging towards underscore syntax, which has a long track record in Scala.
@Crell Right. And I just don't see the benefit.
@Dharman strftime(); as I say, I'd never heard of IntlDateFormatter, and am currently trying to understand how it works
22:10
And if I replied that I am on Windows and it doesn't work cross-platform
I try to write more functional style code, so I do see the benefit.
@Dharman I'd say "that's a nuisance, I've never used PHP on Windows, so can't help you"
don't get me wrong, I'm not saying "strftime() is wonderful and must live forever"; I'm just saying it's perfectly good at what it does for a lot of people
It mutates global state
strftime should be available on windows
strptime isn't
but I can't set the locale, can I?
22:12
setlocale?
It works on windows, though the names are different
IMO, we need something in this space. Extension methods would also work for many uses of the |> operator. Is that any less fraught with issues?
@NikiC for me, I'm willing to accept that my inability to see the benefits is a failure of my imagination, I don't write functional code and can't see how many people are doing that, because php ... but I like the idea of it, I like to see what people might do with it, maybe that's functional programming, or something horrible, I don't know ...
Extension methods only work when the LHS is an object, and you know to extend that object, specifically. And the introduce all kinds of autoload related questions.

They're also a cool feature, but much less simple than pipe.
I do think it's disproportionately complicated, even if I accept that it has much more benefit than I can immediately see ...
@JoeWatkins That's a reasonable perspective to have. My own is more on the other side, where this feels like it's forcing a paradigm on PHP that does not really fit well.
22:16
$directory = new RecursiveDirectoryIterator('.');
$line_count = new RecursiveIteratorIterator($directory)
  |> filter(fn ($file) => $file->getExtension() == $ext, ?)
  |> flat_map($yield_non_empty_lines, ?)
  |> iter\count(?)
PHP is never going to be Haskell, and trying to make it one is not necessarily beneficial.
Is this really forcing a paradigm onto the language? Functional at all costs? I don't think so. Looks quite practical...
Sure. But it has a LONG way to go in terms of being more functional before we approach haskell.
Like, PHP is never going to do lazy evaluation top to bottom. :-)
But IMO, functional "fits" PHP's main use case, web requests, far better than most of the OOP code out there.
@NikiC So If I write portable application I need to write two ways of handling the same logic
PFA + pipes is the largest bang for the buck in terms of functional logic we could implement, as far as I can see.
22:18
@NikiC obviously I agree with that also ...
@Crell The thing is, PHP programmers are absolutely and pathologically allergic to the use of free-standing functions.
but nor will it be node, and we added fibers, which nobody even understands
@NikiC Because we don't autoload them. I'm pretty convinced this is the sole reason.
This all sounds intriguing on paper, but it seems quite far removed from the current reality I see everywhere.
@NikiC Yet they also write static methods by the millions, which are exactly the same but namespace and autoload.
FP doesn't have to be free-standing functions, either. Hell, I've argued we need to use __invoke() more. :-)
22:19
Ok, nvm. I see you can have fallback
@LeviMorrison It's definitely a big part. The other part is overly dogmatic adherence to object orientation -- or some bastardization thereof.
Like, everyone know thats using functions is bad procedural code, you gotta use those classes
@NikiC Yes. And that overly dogmatic adherence developed in large part because only classes could autoload, so functions became uncool. And because there was, at the time, no facility for doing FP style with functions, only procedural.
I remember when classes were still considered uncool. I spent 8 years convincing a major project that it was wrong to think so. :-)
Well, PFA and pipes aren't solving the autoloading question :)
The language features will always lead the language culture, because the culture is formed by the available tools.
@NikiC Sure, but I'm not allergic to using functions.
22:22
@NikiC True. But composer, universal opcache, and preloading more or less do.
@Crell Nope, or at least that hasn't been my perception :) If I use a free function included in a bootstrap file, I can already smell the incoming PR to improve this into a class.
Then the only issue left is that they're not dependency injectable... but PFA gives you something very close to DI for functions, if you use it that way.
@Crell I think that's somewhat true, people can only (easily) go through doors we open ... or smash through the wall next to the door with horrible hacks ...
I forget who said it originally, but "A programming language teaches you to not want features it doesn't offer."
And to be clear, I don't think PHP should ever go 100% all in strict FP. That would be a poor fit. But I do want to see PHP as a very strong multi-paradigm language, so we can mix and match as appropriate.
I changed my vote to "yes" and I may change it back to "no". I'm on the fence. Obviously I want this feature, I'm co-authoring it!
22:25
I was literally reviewing a patch for TYPO3 yesterday and ran into a spot that was perfectly tailored for PFA and pipes.
I just considered something radical like declare(experimental_syntax_features=[partial_function_application, piping]). If it ends up being used in the file without the declare then it fails to compile. This allows us to ship it, but to have a degree of freedom in changing it because it's experimental.
Isn't that the whole edition concept all over again?
@LeviMorrison W3C tried that, and we ended up with 3 versions of every feature in CSS for each of the different browsers. :-)
No, that would be unstable features ^^
Right, also I suppose Editions are no where near to be seen in the foreseable future?
22:27
@NikiC Sure, but however you spell it I would like to be able to ship it this year and be able to improve it next year without it being considered a BC break. I mean, think about how much Rust iterates on things before they stabilize, and I think it's pretty great...
Side question: how are Parse Errors generated?
@LeviMorrison Agree
I wonder what problems PFA/pipes are trying to solve. My guess is 90% string/array functions and referencing a function 1:1. There are other approaches to solve those problems.
Also, I wrote Rust all week. It's great. I love this language.
@LeviMorrison did you get anywhere near writing PHP extensions in Rust?
22:28
I like partials. But they are significantly more complex than they look at a first glance.
@IluTov Probably scalar objects for array/string would solve most of the use cases in a more "PHP way" :)
@Girgias Yes, as long as you only need the opaque types from the engine ^_^
@NikiC Only if you are OK with whatever set of methods are included out of the box. :-)
@LeviMorrison Opaque types?
And the pipe RFC's main example is not an array, so that's not helpful there.
22:30
@Girgias yeah, stuff like working with zend_extension * but you never have it's definition, only that it exists. You can pass it around because the compiler knows the size and alignment of a pointer, regardless of what kind of type it points to.
@Crell I would, if we get them right that is :D
@LeviMorrison I think I baguely understand what you mean
@Crell Honestly, reading that example causes a lot of cognitive overhead for me. wiki.php.net/rfc/pipe-operator-v2#proposal
For the profiler I'm working on I expect it will be a C and Rust hybrid, basically forever. It's much easier to work with the highly integrated Zend Engine bits in C, and then you ship the data into Rust and keep it there. Seems to be working well.
@Crell Just looked at that example, and once again I'm not seeing people writing that in PHP
Btw, it's not just the function autoloading thing, it's general code organization
When I write PHP code, I usually put a lot of different functions and classes in a file, and this kind of style could be applicable there
22:33
IMO it should be a more practical example, like this thing I keep referencing.
I don't think the fact that it uses Nikita's iter library is an issue.
But this is not how other people write PHP code. People don't write PHP code as "file per module"
@LeviMorrison I did include that, modulo iter. It's further down the page.
@Crell The word flat isn't on the page anywhere, so I don't find it ^_^
@NikiC And the used to write it as "functions.php with everything in it", before autoloading became common. :-) Fashion evolves as the language does.
I don't really see PHP programmers moving away from the rigid "file per class" structure
22:36
And I don't really see why that's relevant one way or another. Nothing prevents you from using methods in a partial or a pipe.
It tends to be less relevant with methods
Perhaps. Hard to say when people can't use either one yet. :-)
There's a reason pipe examples tend to be based around stuff like filter, map, etc :)
@IluTov How so? I actually find the HTTP pipe example to have about 100x less mental overhead than PSR-15 does. :-)
$result = array_filter(
    array_map('strtoupper',
        str_split(htmlentities("Hello World"))
        ), fn($v) => $v != 'O'
    );
22:39
@NikiC Of course, but partial application could also used in all callbacks :)
this is PSR something ?
@JoeWatkins No.
@NikiC Your own iter library has a decent number of installs. It's not mind-blowing, but there are obviously people willing to use functions.
I certainly didn't install it 1.4 million times!
Even if it only gets used with arrays, which I don't believe for a second, it still gives us a nice comprehension syntax to boot.
@NikiC This is also why I said extension methods could also solve it for one of the big use cases -- we extend the Iterator interface :)
22:41
tbh I find pipes hard to read also, but probably because I'm not used too it ... but I know that if anyone ever tried to get that code past me, I'd slap them so hard, they might cry ...
but that makes it hard for me to see the benefit, it looks like a nice way to write horrible code, but at bottom, it's still horrible code that I wouldn't allow right now ...
:)
You can write horrible code in any syntactic style. I'm a former Drupal dev turned TYPO3 dev. I've seen things...
I just feel like scalar methods would be a more natural fit. People are already used to that syntax and $a->b() already is sugar for A::b($a) in pretty much all languages.
Only if you could add them to any class arbitrarily, which runs into collision questions.
The Julia feature seems held up because people use _ in their own macros, and it breaks code. Oof.
22:46
Fortunately no one has a PHP variable named ? :-)
I don't think you can substitute any character and avoid this; if I were to drop in and propose using ? it would have the same issue, just a different scope.
So basically they have to get consensus that it's worth breaking code for the feature.
I really wish we could use _ but yeah, not happening. Thanks gettext.
@Crell well sure, but that doesn't mean we should seek to legitimize it ... you just said a few minutes ago that habits evolve with the features we provide, and providing a feature that legitimizes thinking like that ... I'm not a huge fan of ...
@JoeWatkins Do you think this is terrible? Compare it to this imperative style:
$directory = new RecursiveDirectoryIterator('.');
$files = iter\filter(fn ($file) => $file->getExtension() == $ext, new RecursiveIteratorIterator($directory));
$lines = iter\flatMap($yield_non_empty_lines, $files);
$line_count = iter\count($lines);
I think the piping version is easier to read, because you can see the flow at a glance much easier. In the imperative style, you have to check if the calls in the middle actually hook up as parameters as expected.
With |> you can tell it goes top to bottom, no "sideways" edges or whatever (not sure on terminology).
you can, I still struggle to read it
I prefer the one I understand at a glance, and that every junior will understand at a glance
Real code out of a Symfony app that TYPO3 uses:

public function prepareRequirements(Collection $collection): array
{
    $result = $this->formatVersions($collection);
    $result = $this->groupByCategory($result);
    $result = $this->sortByTitle($result);
    return $result;
}
What PFA and pipes would allow instead:

public function prepareRequirements(Collection $collection): array
{
    return $collection
      |> $this->formatVersions(?)
      |> $this->groupByCategory(?)
      |> $this->sortByTitle(?);
}
(No free standing functions were harmed in the copying of this example.)
22:56
(well you missed a semi-colon)
(Thanks.)
You should put that in the main RFC section, not that terrible thing with htmlentities.
I find that much clearer, as it makes explicitly, syntactically clear that each step is forwarded into the next.
Porque no los dos? :-) (I only saw this code yesterday.)
wut, how is the first one not syntactically clear ?
@Crell I would not start mixing methods with pipes. As mentioned, $a->b() is already sugar for A::b($a) which makes $a |> $b->c(?) sugar for B::c($b, $a). To me that's not at all better than the version above.
22:58
why is it obvious what is going on there at all ?
@JoeWatkins He didn't say the imperative style was bad, only that the pipe is clearer; I agree.
this may be unfamiliarity, of course I can read it ... but at some point, a junior is going to work on this, and I know what is going to take longer to explain ...
You have very little faith in juniors. :-) Again, people learn what they're exposed to.
I still deal with people who whine that anything with objects is too complicated and advanced and requires a CS degree and is too hard for "normal developers." Those people are wrong.
I wouldn't expect a junior to be familiar with this kind of feature, I don't expect them to be familiar with most of everything, because junior ... that means I have to spend time explaining it ...
IMO, the key is that the dataflow becomes trivial, so you can focus your attention on what's happening to the data.
That's why once you understand |> and ? it's actually easier to read code that uses it than equivalent imperative code.
23:09
@LeviMorrison Does it though? The dataflow is practically the same ($result -> $result, or |> to ?). Nothing really changes, the result value is just unnamed.
you find it easier, it's not objectively easier, I understand both ...
@IluTov It's easier to tell at a glance what the dataflow is with pipes. With variables you have to infer the dataflow from reading the variables.
What you reduce it to mentally is actually what the pipe and partial is!
Basically it becomes a form of point-free style.
I think Crell earns a commission every time he mentions TYPO3 :p
I wish. :-)
23:15
Good evening all o/
@MarkR \o
you know people read code in different ways ... what I reduce it too mentally is not likely to be the same as what you reduce it to, what I reduce it too is almost certainly not going to be what a junior reduces it too ...
some people smell colours ...
In any case, we're well far afield right now. :-)
The question at the moment is if there's anything we can do with partials to get people more confident that the benefits outweigh the complexity. I think they do, and I don't see how the complexity can be reduced without basically not doing it at all.
I don't know
and what if they don't
Partials will be 80% "..." and 80% of what's left will get eliminated if PHP gets scalar methods :-)
23:26
I think the benefits are mostly to be discovered ... sure it might benefit pipes, and we might have some use cases in mind, but for me I don't know what the real benefits are yet ... but do know how complicated it is and I can't weigh an unknown quantity against that ...
I disagree, but we're predicting the future there.
$foo->toLowerCase()->split(' ')->map(str_reverse(...))->join(' ') vs
$foo |> strtolower(?) |> split(' ', ?) |> array_map(str_reverse(...), ?) |> implode(' ', ?)
essentially, you'd have to prove nikita wrong ... that is not possible, nothing he has said is incorrect ... it is as he describes it, and he understands the complexity like I do ...
@MarkR Doesn't help you with Traversables.
Pipe is more general.
In JS it would just be a case of using Array.from(), not exactly the same I understand
23:34
You lose the memory benefits by using an array at every transform, instead of doing it lazily through the generator.
I'm willing to ignore that complexity, because I think people will do cool things, and it opens a door, and expands horizons, which I like ... but we can't say other than the use cases we've given, anything more to justify that complexity ...
Is anyone skilled with Nikita's top-1000 auditor? I've never used it.
@MarkR I'm getting more and more unconvinced by scalar methods by the day
Just for the sake of knowing... if partials fails, as it looks like it might based on voting so far, there's nothing to stop Nikita from immediately invoking a vote on "..." only, yesum? The overlap won't cause any problems
The only point in them would be to make the sort functions for arrays not be in palce
Named arguments solve the order issue
23:39
@MarkR he can open while voting is still going on
The point is readability and chaining, JS's object based approach is vastly more readable than PHP's procedural approach in this regard IMO, the style in general is favoured by every modern major language... except PHP
and it would finally make people shut up about PHPs argument orders, because it would eliminate most of them :D
So would pipes and a few utilities. :-)
Pipes + partials still requires the argument orders, unless you planned on shipping something alongside to unify them all
I already have it on my todo list to build a small library, described in the RFC, that returns single-argument callables for piping.
I think you remember the orders before you have enough experience to be convinced that the orders are a problem ...
23:44
@Crell i posted to the list with my reasons to vote no. I believe we shouldn't make the language more complex around calling functions. Take the "four" example and how to call it 5 different ways using partials, it is a fun academic excercise to have, but it will confuse the hell out of beginners.
@beberlei There's technically nothing partials do that you can't already do with short lambdas. They're just more verbose and harder to read than partials are.
@JoeWatkins I've been working with PHP for 15 years and I still rely on the IDE for them a fair chunk of the time.
yes, i know, but with a short lambda, its much easier to understand whats going on
and there was the time I wiped out a production database by using PHP-ordered values in a string replace SQL query instead of the mysql order, heh
You can be an HBO Intern!
23:46
@MarkR Agree to disagree, I find reading JS insuffrable
@beberlei I disagree. By the same token, short lambdas are unnecessary because long-closures can do everything and make it more obvious what's going on.
@MarkR well, don't get me wrong, if I haven't used something for a while, I might look at the doc - but I know to look at the doc, so I don't see the problem ... and if your ide is doing it for you, same result - you don't actually expend any effort on the order of arguments either way ...
@Crell there is a trade off to every "short" syntax, and i believe PFA just steps over the line of where there are more benefits than downsides.
The whole of it, or just aspects of it?
Without wanting to be "that guy" .... JS, or specifically TS, is now a more expressive language to write than PHP in practically every way. But it has 2 major drawbacks, one is no runtime type checking, and the other is 'number' vs int / float.
PHP's remaining advantages are it's vast server-side ecosystem, shared nothing architecture and, dare I say it, some of it's magic.
23:52
@Crell the use of ... and delayed exeution did add more to the proposal than I was expecting, but even just with ? it would have been on the fence. I think you don't really need partials that often in code, so when you come across a use-case then a short lambda is fine enough for me. whlie its different for short lambdas in general, you find a lot of cases were they make sense to use over a closure
@MarkR I don't javascript, I just refuse ...
I wouldn't touch native JS anymore, but TS... yeah, that's the good stuff
@Crell you received the integration test email too?
@Tiffany No, I just watch Twitter.
@beberlei fwiw, totally reasonable, and I don't need more explanation than that ...
23:56
Honestly, made me giggle and think "well, they know it's working now..."
this is one of the 10 nights every year where the heat prevents me from sleeping
still 24 degrees C outside, and must be more inside, because of humans being in the rooms the whole day
Cold wash cloths? Quick cold shower?
and 2021 is not the year anymore to go all "lets buy an AC" :p
i already showered 3 times today ^^
plus my wife is fortunate to be able to sleep and me showering would wake her
02:00 - 22:0022:00 - 00:00

« first day (3898 days earlier)      last day (1276 days later) »