 We're ready. Hello everybody. Welcome to Chicago Lug. We're at, first let's give a round of applause to Carl for getting the recording going. So we are here to talk about 8SYNC. And 8SYNC is a network library I've been working on top of on top of GnuGuyle. It is a built on top of the actor model which is one way of doing concurrent programming. And in fact if you go to the 8SYNC homepage which is at gnu.org slash software slash 8SYNC you can it has this little snippet of code and it has real running code in this amount of code you can write a real IRC bot. And that's it. And most of this is actually about it switching between different things you know. So here it's saying when I get an action that says bot snack it says yay I do a dance and etc. So there is a monitor being rotated in front of me so maybe I should make sure that. Okay all right so anyway but that's just one actor right this is just one IRC bot actor. What would be more fun would be having a lot of actors running around. So I was participated in something called the List Game Jam which is a game programming contest. And I built a mud on top of 8SYNC which is a multi user dungeon. Who here has ever played a text adventure or a mud type thing? Where is your hat? Okay actually good chunk of the room has done that type of thing but if in case you haven't the URL so I'm gonna let everybody connect to it in a second so you can connect if you want you can pull out your laptop. Now before you connect I'm gonna say if sometimes when we do these types of things like it's people start like saying sexist or racist bullshit or like a bunch of other stuff like that if you're gonna do that kind of stuff just don't connect since it will be recorded. But if you're not gonna do that type of stuff you can connect by going to dustycloud.org 8888 assuming I remember to turn on yep there we go so we should see people connect there we go a bunch of people are connecting so it's dustycloud.org colon 8888 yes oh somebody already figured out how to talk so you can talk like this you can either do say foo or you can do double quotes or single quotes space and then you know I everybody and at this point we're kind of have like a multiplayer chat room. Hooray so if you type look somebody already figured out how to ring the bell so yeah somebody to ring the bell and a uniform woman rushes into the room she's wearing a badge that says desk clerk so I should give the context of what's happening here we are in a hotel lobby that is the state of the game it's called Hotel Bricka Brack and there's a bell that says ring bell terrible music etc and and somebody has already rung the bell summoning the clerk so what do we do we can ask the yeah so if I can chat with clerk Eva's already done this she's kind of cheating so you know it says so if you need help with anything you can ask about it so I want to change my name so I can do ask clerk about changing name and she says oh you know change your names easy just say they've got a sign in form so sign form as and then you put your name so sign form as C. Weber and now I'm known as C. Weber let's look in the room we've still got a lot of guest dash whatever is you can sign the form and switch what for dusty cloud the door colon 8888 you can also do forward slash me or emote to do something emote does a dance yes exactly so if we look in the room we'll see some other stuff around there is a sign so I could read the sign for example and it says hotel big bracket smudge pasty text I can also dear says that there is a curio cabinet here so if I look at cabinet it says oh something's catches your eye telephone shaped like an orange cartoon cat look at cat oh look at phone it's made out of cheap plastic it's orange and has a striped tabby with you know smarmy looking face somebody probably made a lot of money in the 1990s oh great okay so don't solve the puzzle body body already knows what's going on so there's also the desk clerk which the yes so the clerk's complaining about the prior tighter having no idea to run out though well anyway if you type help we'll see that there's other commands so for example there's go so if I do a look I can see that to the north there's some kind of hallway so I'm gonna go north and there's already Bonnie here since Barney has already kind of had a preview of this game you know some of the things that's going on and you can join me there's Jim so in this room we see kind of a bunch of statues around and etc. and there is a statue in the middle of the room called hackfina I'm gonna there's also a hotel map so I'm gonna read the map and it says you are here right in the middle of a lobby at the right in the middle of a hallway you can also see where the lobby is and these other rooms you can move around if you like so there is a statue of hackfina so I'm going to look at statue hatch this so this is the statue of hackfina guardian of the hacker spirit she's holding the form of a human woman she's got holding some sort of keyboard and a shield so we could look at keyboard it says that it's a it's a it's a it's a night keyboard which means that it's a she must be an emacs user it was already picking things up and dropping them look at QB oh wait they've already took QB again so so if I look at shield oh it looks like it's some sort of hard disk platter it's kind of loose so what do you think we would do here somebody can guess or just do it take the shield take the shield that a completely separate copy of the disk materialize it into our hands and says share the software you'll be free okay great so what do we need to do next so read sign yes and everybody can take a copy of it if they want since it makes their own individual copy and you can type in to see what's in your inventory so read sign read map we could go east or west or whatever where should we go well we're right north of the lobby so why don't we go well there's a fun joke you can go east and there's some some there's some like table and chairs and stuff like that we can go south again and somebody must have go south dismiss clerk she will go back and if we go south of the smoking parlor we'll see that the hotel desk clerk is here if somebody goes and rings the bell again she'll run out of here and freak out but anyway yep there we go somebody rang the bell so anyway that what I'm trying to demonstrate here is that this is a world of objects everything in here is itself a its own individual actor under the eight sync type vision of actors and it's this whole world is live hackable so we can actually change things and add things as a world is running so I'm gonna go what I'm gonna do is I'm gonna go west of the main hallway to the playroom now there's a few things in here including a toy chest which has a tin foil hat in it so I'm gonna take hat from chest wear hat and it's a lot harder to take me seriously now but you know so so one of the nice things about this is that we can actually add things and change the world as it goes so for example toy chest what's something that somebody would like as a toy like a frog a frog okay we'll just make a simple toy which is a toy frog so we're gonna call this toy or rubber plastic frog a plastic frog plastic frog and frog plastic plastic frog with its arm with you guys so it's a simple thing you can take it but I'm gonna insert it since is a now if I was doing a normal programming environment what I would have to do is I would actually have to kind of kill the entire world while this was running in order to be able to in order to be able to change things as they're running but I don't have to do that here so I have this nice thing where I can inject things straight into the game so I'm gonna inject this plastic frog all right now look at chest and there is a plastic frog in there oh so I see that Sheila has already started messing with the Rube Goldberg machine but somebody can take that frog if they want now so now actually she was already uncovered a problem with this group Goldberg machine it started the dominoes toppled on the line the last domino ran to switch the switch lights a match match like a candle and the candle burns and it just stopped what happens right I bet you were disappointed right that's because there's something wrong with the machine so I'm gonna have to fix it so I'm gonna look at the the machine the Rube Goldberg machine now the thing that it broke on was the candle now when I look at this candle here I see that I've got this kind of little language that says all the steps that happen so for example the switch it said the switch lights a match and for two-thirds of a second it pauses and then it says the match lights a candle one and a half seconds it pauses and then it kicks off the next thing see so that same thing here the candle burns the candle is and then it's supposed to say the candle is burning away rope but I made an error when I program this there's this thing in list where you can switch between you know one two that's writing adding together one and two and you get three or you can do something like this and if you put this quote before it it actually turns into data now we have a list of one and two and I can do a quasi quote where I do something like this minus eight and nine and I'll just switch that plus two elephant and see that thing that I unquoted here actually performed kind of executed that thing in the middle of it so it's kind of a mini little listy templating language and I made a mistake when I programmed this candle where I forgot to unquote this so it was actually returning a list of slash two three instead of actually evaluating it and do two divided by three so I can fix that I fixed that and I'm going to inject the injecting things is kind of a mud sink which is a mud thing that's not actually an eight-sink thing but you can build these kind of live hacking things on top of there so I'm gonna inject the fixed version of the candle right into the game while it's running so now so I'm gonna reset the root Goldberg machine so a glove comes out and switches everything back and then retreats into the wall and I'm going to run the machine so I start the root Goldberg machine and hopefully it's fixed Dom was toppled on the line last download to switch switch lights a match match lights a candle candle burns candles burning way rope the rope snaps snap rope unleashes a catapult which throws a rock walk flies through a water demon the water demon starts spraying water everywhere the water the water hits a quick yeah the cuddles water beaten love the quick heaters on button quick heater fills a heats up kettle vanilla foot the kettle is filled kettle is heated up the water is boiled oh and there's a cup of hot tea a tea sip tea however fine I can also just drink the tea but that'll burn my throat but now I have no more tea but anyway but you get the idea so if you've done any concurrent programming before you might have run into this issue where like it's actually hard to plan out so a concurrent programming environment and what's really exciting is to be able to actually figure out and evolve the system live while it's running so this whole game pretty much I actually built while the program was running like the parser and everything so that's one of the big advantages of each thing is that you can program things in a network environment and actually change things around as it goes so let's go we're still in this room in the playroom but we know West is a computer room so let's go West and so now let's see if we can solve this possible there's a large computer cabinet and there's a large hard drive and there's a floor a panel on the floor that we'd like to go down into but it seems to be closed and that's where my talk is downstairs so in order to be able to go to the rest of my talk we have to solve this puzzle so let's look at the computer large closed size closet closet size computer label PDP 11.5 looks like we could run a program on it so run program on computer oh disk error so we need to somehow fix whatever the disk here is so look at drive so the drive says that it contains a slit where we could oh and somebody already inserted the golden platter so that's done somebody solved part of the puzzle but there's a load button which it which is glowing so we should probably oh Eva figured it out press the button on the hard disk and it begins to spin up and the ready light turns on so now we can run the program on the computer somebody can do that I'll just I'll just let somebody else do it there we go ever once the program on the computer your gears gland and a metal pan around the planet around the ground panel on the ground opens and reveals a scare about going down hurray nice job so let's go down so here's where the main talk is we're in an underground laboratory which is an eight-sync laboratory let's read the map oh nice it's a nice ask your map here so to the north is a eight-sync hive we're in some sort of laboratory to the east of the Federation Station there's a guile async museum to the west some sort of swamp below where should we go any votes go to the swamp I didn't finish that it's walled off yeah sorry that was gonna be the best part of the thing I was gonna have frogs in there you could attack and everything but I ran out of time but the other rooms are open so yeah you would be able to punch the frogs what about that like secret looking room on the bottom oh pieces here oh the secret room this one here yeah well we you know we can get there in order to do that we have to go into the async museum but maybe actually there's one more thing in this room that we should probably look at before we leave it there is a sign to label the eight-sync design goals and since this is theoretically a talk about the eight-sync we should probably read that sign so read the sign so what are the goals of eight-sync so a it's after based so who here knows what the after model is anybody one kind of a few kind of yeah so it's a map it's where you send messages so in the after model there are no nobody has a direct reference to anyone else and there's no shared state so if you're familiar with like the with if you're familiar with any kind of concurrent programming and you're familiar with dining philosophers etc you know that sharing resources is hard so what the actor model does is each thing that's in the environment actually just sends messages to each other and each actor has an inbox that they read messages out of so this prevents us from running into deadlocks and etc it's also live hackable so the whole because it's so hard to be able to program a concurrent system it should be possible to extend it as you go and no callback how so who here is programmed in something like no JS or twisted or anything like that at least yeah a few people here so you're probably familiar with what callback how is you have to call some procedure which needs to call another procedure which needs to call another procedure and eventually you just get like lost right it just turns into a bunch of spaghetti and you try to use promises or something to make it easier but they only make it so much easier so in each sink what happens is there are so here's an example where if when we were taking things like from that statue from the taking things from a pack Tina we needed to find out we could actually go I'm gonna actually just demonstrate so when I I'm going back to the grand hallway you can do the take shield but you can also do take shield from hack Athena so I didn't want it to error out no matter which one you did right so in order to do that the hack Tina actor needs to be able to ask it's other like the actors that it knows about how do I actually what names you go by so that it can correctly proxy to them correct you know so that makes sense but how do we prevent that from being a big mess and the way that we do that so that we don't have to actually split things at all right here is where we send a message to the other object and you can send messages that you don't wait on for example here we're telling the odd player that they don't see anything here but if we do see something we can just actually wait on the message and we'll get back a response kind of like doing a web server request where you have a request in a response and our function will suspend mid execution and be woken up by the scheduler as soon as there's something available so instead of splitting things into separate functions you can write a function that moves straight ahead and in fact the first example I ever had when I first started working on these things I wanted to have a robust example that had a warehouse full of a bunch of like droid robots and another robot that had to go through and find out which ones are infected and I had to scan each robot and then if I found it was infected shoot it until it's dead and then move to the next room now if you did that in something like no JS you have to split that into like 50 functions that you'd have to keep track of and kind of thrive between them this is all one function so each bit of it actually is able to just the function is able to just suspend mid execution that's because we're using something that's really cool and scheme called the limited continuations to really get really nice co-routines so now that I've dropped a huge amount of jargon like message at a time oh so like send it out to a bunch of actors and then kind of collect them so you can there's a there's not quite as much the easy like weight thing what you would do is that you'd actually send it to a proxy method of yourself that you would wait on that would send it to each one of the actors it would collect the responses and then it would come back so yeah you can split it out it's not there's not as quite of a one-liner as it as it is but you can have it in the function that's actually waiting on the response look like a one-liner so yes it's possible so if you need to broadcast things to get things you can do so so let's see here read the map what is why don't we actually go up to the eight sync hive so I'm going to go north so I'm at the entrance of the eight sync hive so this is my abstract concept of what things actually look like inside of eight sync do you see a bunch of actors kind of milling around and they all have like this umbilical cord attached to them that leads into this dome-like structure and that's and that's where all the messages actually come into so there's actually a meta actor we can chat with actor here and they will like complain about things about going to sleep and stuff like that most of the NPCs you can chat with because I spent way too much time messing around here but uh yeah yeah so but anyway if I look we can also go north to go inside of the hive and that's one of the fun things here so inside of here it actually looks it says full so it's obvious that everything's kind of goopy so one thing about this is more significant I guess if you are a guile user but we use the object oriented system inside of guile that's called goops not everybody really loves it in guile but I like it because it allows you to actually change and add slots and redefine things without it breaking while the system is running which I think is important if you want a live hacking environment now we there are some more functional people in the guile community that are like oh you know it's got too much mutation and stuff like that well I submitted a patch that allows or a there's a function that I have that allows you to actually swap out to make clones of things instead of mutating them I was originally gonna have a room inside of this game where you could walk in there and there would be like it would be like the mutation chamber and you see each actor inside of its own little cell they send messages at each other and each one would mutate and there's like this woman in the corner who is like the function of the program she's like disgusting every time that it mutates like gross and then like if you chat with her she would like I ran out of time for this unfortunate she'd be like follow the white rabbit to see the answer you could follow it and then you'd end up in another room that also has actors inside of these like like individual pods but then instead of mutating they would clone a completely different but altered version of it and throw the old body on top of the garbage collector that would then get thrown out of heat and just dispose then she'd be like so much more humane but unfortunately I ran out of time for that so anyway so it's possible to do kind of more functional things we replace things but I don't have it quite in there yet so inside of this room we see the 8 the hive actor itself so if we look at the hive actor this is kind of a meta actor that actually distributes messages to all the different actors in the game and then it has an umbrella cord sticking to itself but the the but yes so yeah I don't yell at you if you start talking to it so I hear that fiber system as a nice work ceiling system but the proprietor is not convinced that her design won't corrupt actor state that the actor certain to strike when it came up last so right now each sink actually will suspend on IO so anytime that you would actually be writing something to read or write from a file it'll automatically suspended in a mid execution and just be woken back up when there's something available so you also don't need to split your functions on IO but it's possible to split it on CPU bound stuff but we don't but that's actually tricky to avoid corruption and stuff like that so the more fun thing that's in here is a stray message so look at message it's floating above the floor for some reason so if I read the message due to his bizarre error in space time the message prints itself out okay so this is actually the message that was sent to the actor asking it to print itself out so if I read it again it'll switch out the ID for a new one so what happens is you know it's an incremented the number on this side so the way this is basically how it works each message has its own individual ID it's sending to some sort of address you can see that this one has its own actor ID and hive ID and the hive meta message thing and the player meta message both share the same hive ID so they're both part of the same hive and you can each one has kind of an action which allows you to kind of specify the method so that's very similar to methods on any sort of object as you would have in Python or anything and these are all arguments that are passed into the message handler so and this stuff is just all to make that wait stuff automatically happen so that's that's basically the crux of how the message passing works yep so anyway what else do we have to do here in this talk so let's go south go south so here and read the map again Gaila sync museum or Federation station what's more interesting at the moment well I guess we can cover both along arbitrary choice okay let's go to the museum so go west a security guard steps aside as we try going through and then stands in front of the door oh that's interesting so let's try actually going back east again and security guard stops and tells us the only exit is through the gift shop anyway so there's a list of exhibits so let's look at list so 2016 progress so look at 2016 exhibit this is a giant wall of text as this whole talk is I guess but just as a summary so the at the Canoe 30th meeting we started talking about the fact that we needed some sort of asynchronous answer to things and we a number of us met up at veggie galaxy starting to plan things eight sink came out in kind of late 2015 early 2016 as well as another person's project Gaila sync and and then kind of one of the main Gaila developers kind of blew everything away by allowing this by adding a new feature to Gaila called suspendable ports and what suspendable ports allow us to do is what I said earlier where you can write IO code so if you were doing something like where you were doing you know you know while you know like something to read in file you know read from file you know this won't block whereas in most code that loop would be a busy loop this will actually just suspend any time that it needs it doesn't have something to read from it and will allow other actors to continue and and will wake up again as soon as there's something available so it makes writing network and like IO based code really easy without splitting things up again so and Andy Wingo started his own library called fibers which is another library for guys so right now it's not completely clear what the future and whether or not we'll have one or multiple of the high level APIs so let's talk about each thing in fibers guy I found out after giving this talk from the Gaila async author that async and fibers are pretty close so look at each sink and fibers exhibit so both of them are pretty similar if you look at each sink and you look at fibers both of them involved using the suspendable ports feature which is not surprising since Andy wrote it both of them use message passing so what's different about them well fibers can technically has processes it's using something called the communicating sequential processes and if you've looked at go or something like that it's very similar to go and those types of designs so it's in that school of things but it's the same thing you're reading from some sort of inbox except you can read from that inbox at any point in the loop which also can be a problem because if you have two inboxes and you're reading from one of them and the other one you need to get to at some point you can end up in live lock but but it has some more but there are some advantages also to using its idea of CSP which is a form of process calculator because it's a little bit more mathy and but what's nice is that async is based on the actor model and fibers is based on CSP and these are technically for mathy people will use the term dual and mathy people get excited about that because it means you can implement each one is in terms of each other so fibers probably has a better underline design because Andy Wingo is way smarter than I am but that's the gist of it I'm not going to read this suspendable courts exhibit because I kind of already talked about it enough so let's look at the actor model exhibit so factoids about the actor model it's conceived initially by Carl Hewitt in the 1970s and the idea is that you're supposed to have a society of experts so each actor in there is supposed to have some sort of actor's expertise in some sort of domain and if you talk to Carl Hewitt about it he says the actor is a fundamental unit of concurrency I don't follow that you know like if you look at Erlang even numbers are actors in 8-sync some an actor can kind of be as large or as lean as you like but but so anyway shared nothing but what's really funny is that actors originally were what scheme which is what 8-sync is programmed in was designed to explore in the 1970s and while they were exploring message passing into the Lambda calculus they basically were like oh wait a minute these are exactly the same thing the Lambda calculus already handles this whole thing except there's a little bit of a difference in terms of how in an expectation as in terms of a dress space usually when you're dealing with something where it's just like the Lambda calculus you're expecting that whatever code you call will return to that thing right you don't have that guarantee in an asynchronous environment you might call code and then suddenly it might never get back or whatever right or it might come back at some sort of completely different time or something like that so there's a certain amount of different expectation that involves when you have message passing I think and so that's that's one reason why I think the actor model is still valid despite that it can be seen as very similar to the Lambda calculus so anyway Ava said we should see what that thing is below and so let's go south and we're in the museum gift shop unfortunately this is also somewhat of a cop out because I didn't completely finish it but so everything's just glued to the walls and you can't take it but in an ideal world you'll be able to punch the frog get its gold and come here and buy things but that's not true anyway we can go northeast and now we can go through the revolving door and get back into laboratory so there's only one more room to look at and that's the Federation station section so let's go east and in this room you see a bunch of nodes on the walls and they're all interconnected and glowing as messages pass between them and stuff and if some of you know Federation is kind of my main thing that's what I spend most of my time on is about decentralizing network environments and stuff and that's actually what partly got me interested in an actor model in the first place so if you have heard of activity pub that's the main thing that I work on with the W3C so there is it's a standard you can look at it today if you're interested in building one of these decentralized networking protocols you can read the standard and it explains how to be able to actually federate things as in terms of things going from one endpoint to another so say you have some sort of place book like alternative right and you want to share a note between two different servers how do you do that so this is what it actually looks like it's a simple JSON syntax you see that you like this is a like object which comes from this actor in Valerie and she's sending it to these different of these other actors and she and the object that she's liking is a note that says I'm a goat right so but it's pretty simple to read right but wait a minute wait a minute this seems oh yeah that's a funny gift I did not meant to open but anyway the basic idea is that you have each server has an inbox in your setting messages between them but doesn't that sound familiar that sounds an awful lot like what we're doing here so there's a conspiracy chart I'm gonna read it read conspiracy chart it's all related shots over in super and conspiracy activity pub Federation the actor model scheme text adventures months what do these have in common merely everything so on this poster there's like a bunch of like things drawn on it with all these different names that a red marker highlighting them and drawing lines between them and it seems crazy but maybe maybe it's just crazy enough to be true so scheme as I said before was originally started to explore the actor model and though it became more famous for its work on the lambda calculus that exploration of the interrelatedness of that is at its very heart the activity pub protocol for Federation it uses activity streams which huh like you know like it actually looks very similar you have a public subject predicate object type relationship like you know take duck from from from bathtub is not too far away from you know like post by you know by Mallory or whatever right so it turns out that those are kind of similar in its grammatical structure so the federal so but there's also related with Federation in the actor model because both of them involve having nodes that shoot messages between each other so pretty similar in concept and Zorn the world's first text adventure will actually second if you encounter adventure but the first major one is used model as its language which actually looks almost exactly like scheme in fact it's scheme pretty much with angle brackets and before it got a little bit more along the calculus II and so that has some relationship and before the 1990s there was actually this vision that we were going to instead of reading web pages on the internet we're gonna live in a much more cyberpunk future where everybody was like going from room to room and talking with each other and you know like you know like Neil Gibson in you know fighting each other in some sort of like electronic hallway or something like that right and so their mods were actually a major form of research and there were a number of research labs actually studying them at the time so for example the AT&T Network Lab and I think the Xerox Park Network Lab both had some research projects and here is an article that is talking about building federated mods before the federated web started so anyway I just think that it's interesting that in a certain sense none of these things look related but they're all are kind of related so anyway that's pretty much my talk I hope you got a flavor for how you can build worlds that are alive try to make network based environments that you know can change and be modeled as the world is running that are easy to kind of thread together and how in some ways this is kind of related to the various decentralized Internet things I've been trying to explore that's it thanks everyone