« first day (2412 days earlier)      last day (2761 days later) » 

19:00
@ircmaxell well, it's also an art to maintain a nice architecture where asm level coding is needed. [typically obscure embedded targets and very low-level system programming]
what do you guys think of HHVM?
@OtávioBarreto I'm disappointed that they didn't just contribute to php core. It seems Hack was really the end-game though.
@LeviMorrison it was an experiment though, worth of being done at the end.
I'm just not persuaded that it's worth continuing dev on it…
what frameworks did you start out with, @Ocramius?
@bwoebi I also think in this day in age it takes a special person to even do ASM in the first place
@ircmaxell To clarify you mean writing ASM by hand or reading it? Assembly is not difficult to read but writing or generating it can be a pain.
@Tiffany played and beaten ;)
@LeviMorrison writing in a production context (not in a generator or compiler context)
@ircmaxell It's on my wishlist. Looks like it's gone down in price, I should grab it. I already own it apparently.
@ircmaxell It's not that hard to do asm. The hard thing about asm is everything else … specialized ops, making it fast, …
(as long as you maintain a bit of structure, calling conventions and such when jumping around, document what which register and code part does etc.)
When I was younger, I had aspirations of learning assembly so I could write a virus to infect a layer below the OS. I was delusional.
I could write malware that's just an infinite loop
@Tiffany for that you need in the first place to find a bug in the code …
Also, it's more about finding things like ROP chains enabling you to execute arbitrary code and such than actually writing asm… where the code can be simple cross-compiled C code…
@PeeHaa so what does asyncRequest do?
@Tiffany magic.
Fires a request
and waits for the response.
19:14
@Tiffany make the code harder to reason about
@Tiffany yes.
@Tiffany afaik the stabbing is unnecessary, it's not like the adrenaline shot in the heart, you just need to hold it firmly against the skin. However I've never had to use one personally and the ones you get there might be different to the ones we get so I could be wrong.
After that, all user names here will be automatically embedded with ".loser" by the system.
@DaveRandom I've tried just pushing into the skin and it doesn't work. There has to be a certain amount of force to make the injection pop out.
19:16
All that is wrapped in a loop @Tiffany which ELI5 just manages what gets run and when
I see
@DaveRandom But but but pulp fiction
I thought you first had to have a 10 minute discussion and then stab in the heart
It's JS, but it explains the concept really well imo
while (haveIoToWatchOrPendingTimers()) {
    timeout = getTimeUntilNextTimer();

    if (haveIoToWatch()) {
        watchForIo(timeout);
    } else {
        sleep(timeout);
    }

    processPendingIo();
    processReadyTimers();
}
that's your basic event loop
I like that snippet. Gonna steal that like a pro
@DaveRandom sleep(timeout);
but yeah
19:22
@bwoebi true, fixed
Async programming seems useful but it is a different style of coding and takes a bit to wrap my head around
I like the idea of being able to perform multiple requests, sometimes in parallel
My personal view is that it's worth grasping async/await in a language that actually has those constructs (even if only theoretically) before attempting to write async PHP
@Tiffany This why imo amp is nice
@Tiffany meh, it's pretty similar to sync coding as long as you don't leave objects accessible by multiple things in unstable states within tasks
@bwoebi yeh async in C# with it's managed thread pool and no guarantee that continuations are executed on the source thread can be... fun.
19:31
@DaveRandom so you need proper locking primitives? (instead of just simple boolean guards around yielding boundaries)
Sometimes. Not very often in practice though.
@DaveRandom in practice, most objects are only manipulated by a single async context
@bwoebi The looping example on the amphp's website was what threw me off a bit. I get how it's doing it, but I'm so used to writing for/while loops that it's enough of a change to make me rethink how I write the code.
@Tiffany yeah, it's a bad example
it should be:
@bwoebi yeh I'm just trying to find an example of where I've had to do it so I can clarify why it was necessary in my own head
19:35
Amp\run(function() {
    Amp\asyncCall(function() { while (true) { tick(); yield new Pause(1000); } });
    yield new Pause(5000);
    \Amp\stop();
});
@DaveRandom I'm just pointing out that the risk of running into it is much inferior with a single-threaded event-loop vs c#
sure, it's never going to happen in PHP
@DaveRandom well, you still have to guard around your yielding points
you'll just not have explicit concurrent manipulation
user1804599
I wouldn't want to do async programming without <*> and >>=.
@rightfold what does <*> do? … >>= is right bitshift assign, right?
user1804599
When you have two async computations a and b, where a resolves to a callable, a <*> b returns a new async computation that applies the result of b to the result of a.
user1804599
19:41
When you have an async computations a and a function k returning an async computation, a >>= k returns a new async computation that applies the result of a to k and returns the result of k.
user1804599
If Hack had operator overloading, these would be the types:
function <*><A, B>(Async<(callable(A): B)> a, Async<A> b): Async<B>;
function >>=<A, B>(Async<A> a, Async<callable(A): Async<B>> k): Async<B>;
user1804599
These make it very easy to create async computations from simpler once using parallelism (<*>) or sequencing (>>=).
user1804599
These operators come from interfaces known as "applicative functor" and "monad".
I'm not getting why you are returning the callback in an async way…
oh.
hm
no.
I don't get that.
user1804599
The callback may be a closure that uses results from an async operation.
user1804599
19:48
Async libraries often have a function named map or select, with a signature like this:
user1804599
function map<A, B>((function(A): B) $f, Async<A> $a): Async<B>;
user1804599
Here, if B is, for example, (function(C): D), then you get an Async<(function(C): D)> back.
user1804599
This can then be used with <*> to apply more arguments, performing the Asyncs for each argument in parallel.
user1804599
function f($a) { return fn($b) => fn($c) => $a + $b + $c; }
$getSum = map('f', $getA) <*> $getB <*> $getC;
user1804599
MiNd BlOwN
19:53
ah, got it.
user1804599
/me has no clue about Amp though, should check it out
so, basically asnyc functional programming
user1804599
Composition of async computations using functional programming techniques.
yeah
user1804599
You can use applicative functors for most tasks that involve computations that don't depend directly on each other's results.
user1804599
19:55
Therefore they are a great fit for parallelism.
@rightfold well, otherwise you'd need $getSum = (fn() => map('f', await $getA)(await $getB)(await $getC));
user1804599
That will be sequential; it will not perform $getB until it has performed $getA.
user1804599
Oh, you're doing the thing where $getA points to an already-running computation.
user1804599
Yeah then that works.
@rightfold uhm, these are variables, I assume you've launched the tasks before
yeah
<*> is not making it that much simpler
user1804599
20:01
Yeah that's more imperative; you're not building up computations from other ones.
user1804599
You're building them up from running code.
well, that makes sense for Haskell, not so sure about the classical imperative languages
@rightfold I'd rather say <*> introduces extra magic, where it really is just sugar for $a(await $b)
user1804599
No, it's a different way of doing it.
user1804599
<*> takes two not-running computations and returns a new one. await waits for a task that is already running.
@rightfold I mean, in a different context, yes.
@rightfold there's no such thing like not-running in imperative languages, fundamentally
if there is, then there's extra magic in form of an explicit start() method being called at a given point
it makes sense in a language like haskell, where everything is deferred until the last moment possible, but it goes pretty much against the whole point of an imperative language :-)
20:11
@DaveRandom amphp/postgres supports both ext-pgsql and pecl-pq.
@Trowski yeah, we figured
@Trowski yeh I saw, happy to nuke the other repo
pq includes support for unbuffered queries, and both support transactions and notifications.
@DaveRandom Sure, the other repo doesn't serve a lot of purpose now.
oh right yeh that was the other thing you couldn't do with ext/pgsql, unbuffered results
@DaveRandom What was the other thing again?
20:14
non-blocking connects
I think
@DaveRandom I thought it was non-blocking… but maybe not. For database connections… meh.
I'm not even sure now
I know there was something, I have a note of it somewhere
user1804599
Sep 9 '16 at 15:50, by DaveRandom
Also if you get more than one warning message in a result set, ext/pgsql only handles the last one
@rightfold right, that perform() thing I'm talking about
20:23
@bwoebi that's a much more straightforward example.
@Tiffany yeah…
20:47
guys, can anyone help me with naming shit (I am hopeless) =[
@tereško yeah?
so ... I need to name services
the .. emmm ... problem domain is: authorization
what I have are roles (well a graph of roles) and resource
variable name, class name?
posted on May 24, 2017 by bwoebi

amphp/mysql v0.1.5

the separate responsibilities, that I could identify as as follows:
- creation, alteration and verification of "resource" (those are classes, files and simply "identifiers" on which access permissions are granted)
- creation or roles and assignment of them to 1 or more "parent roles"
- association of resources to roles
- association of account ids to roles
- retrieval of all direct and inherited resources for a role
- retrieval of all the roles, that have access to a given resource
- retrieval of all the inherited resources for a given user id
I need to separate this into services (at the moment I have one big Guardian service, which does it all)
so ... any ideas how do I split this up and what do I call each of those services ?
20:55
so, one for Role management and one for getting authorization from Roles?
you are suggesting simply making a "read" and "write" services?
essentially, yes.
I am ok with having a separate "read" service ... I would probably call it "Search" or something, but the rest of the tasks are kinda complicated
@tereško I suggest you first splice read out then and reevaluate then
ok, no, the "associate" part is kinda simple, bit the first two are pain in the ass
@bwoebi that' sounds reasonable
20:59
@tereško the first two sound strongly related though. I doubt you should forcibly separate them.
"resources" are basically magic strings, that are used to identify the thing that you grant permissions to
what I am doing is essentially taking a "kinda close source" lib that I made and opensourcing
@tereško well, essentially you can consider each permission on a resource a role, which you assign to parent roles then
nope
that's a terrible idea
why?
21:03
it creates a huge mess
uh, I expected simplification from that…
the graph that you end up with is extremely complicated
since same "resource" can be available for different groups at different levels
@tereško right, but does that matter? For displaying purposes you may partially unwrap the graph, yes.
but internally, does the graphs complexity matter?
it's just about recursion then
hmm ...
I don't think there is a way to represent it in a sane way in SQL
even if you ignore how damned hard it would be to collapse that graph correctly
@tereško simple 1:n parent-children relation?
21:07
the current implementation requires closure table
what do you mean with closure table?
anyway, the details are not important
event if I actually user it as a single graph, it would still make sense to separate those two notions at API level
@tereško sure, but it's the same services task to handle it.
I will have to sleep on that ... you might have a point
Just giving you ideas to think about … haven't thought about it in depth ;-)
21:13
the thing works (while it's something of a mess) and has been deployed on two production sites
but you are correct that there might be a better way of doing it
and doing a rewrite is a good opportunity to make the whole fuckery less annoying
In my experience, making code more generic (so that just one category of things is needed to be handled) usually ends up in a more powerful solution.
or you end up adding more compromise for two different things to be stored in the same table
At least given that the original thing is already quite complex, it helps. If it's simple, then usually not.
@tereško it depends on how different these are. They have similar properties (can be added to parent nodes), can be created and altered etc.
 
1 hour later…
22:23
$ sapi/cli/php -r '$x = array<int>("1"); var_dump($x);'

Fatal error: Array value 0 must be of the type integer, string given in Command line code on line 1
:3
well look at that
@Andrea references ;)
@NikiC screams
Do not allow references in typed arrays
@Dereleased we tried that with typed properties…
22:25
That's why typed properties should come first, they will solve the references issue (presumably)
@NikiC One should hope.
Is there any formal structure for a reference to get all the things that... reference it?
@Dereleased nope
Accessing a typed property whose value is byref to a thing which is the wrong thing issues a runtime error, partially to comply with types, but mostly to give critics of PHP another run-time type-check-error to roll their eyes at
Boy that sentence really got away from me
What if the type was also a property of the ZV of any typed thing (array, property, etc), whether or not a reference?
Once pointed to at any time by a typed thing, boom, type enforced
/me waits patiently to be schooled. =)
user1804599
@NikiC I'm now doing a similar thing; using a struct which is decoded up front.
user1804599
22:30
Also want to do bytecode verification but that's not difficult.
I have to go home now, @NikiC I am looking forward to an evisceration in my inbox. Lates r11
(or whomever)
22:58
hmm…
@NikiC is adding an extra field to the end of zend_array that's only there and allocated if there's a specific flag set, a bad idea? asking for a friend
@Andrea you have terrible friends
@FlorianMargaine ^^
23:32
@Andrea It's okay-ish
We do that kind of stuff for objects
But you will have to change some code making assumptions about that
@NikiC of course
E.g. efree_size calls and similar
But generally yes, that's totally what I would expect array generics to do
I assume zend_array is a fixed-length structure in memory?
yes
Cool.
Actually, that makes me wonder if there'd be any benefit in putting one of the separate allocations into the main one.
23:36
@Andrea You can't without some major changes
@NikiC arrays not relocatable?
nope
is that a „ja“ or a „doch“
(I guess the former.)
@NikiC What happens with strings?
same for strings
you can't resize a string unless your control all the use sites
Oh, I guess the places that resize them first deref, right…
the big thing with strings is that they don't resize without you telling them to
whereas an array does so dynamically whenever stuff is added, if needed
…I see.

« first day (2412 days earlier)      last day (2761 days later) »