Playing Factorio makes you a software engineer, seriously.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is computer science is it the study of computation is it the reverse entropy of information or perhaps a corner where a university can quantin the students who don't shower what is factorio is it a game bad automation is it a commentary on the inherently unsustainable growth of capital or perhaps it's an activity that people in Prague invented because heroin wasn't addicting enough all these questions and more will be answered in this video so come take my hand and let's go on this journey in this beautiful factorio it's a notoriously addictive game on theme about automation you crash land on an alien planet you have to build a rocket to get off and to do that you plunder all the natural resources and you process them into higher and higher level materials software engineering is the uh end to-end process of creating and maintaining software applications usually that means sites like Instagram or YouTube but it could also mean things like Microsoft Word or even like the game itself factorio it's a lucrative industry that employs armies of young twitching neurotics like me to squeeze every last drop of brain juice out of their little skull C ity so that they can stick it in some code and I don't know make a website like count views or something my central thesis is simple the way that we transport impr processed materials in factorio and honestly any other automation game closely mirrors the way that information flows in our modern day software applications this combined with the fact that both of these are highly centered around automation means that factoral and software engineering end up sharing an insane amount of similarities so between the game about automated industrialization and the industry that brought us automated social gamification the first similarity we'll be talking about today is you guessed it spaghetti so the reason why we're starting with this topic is because it's one of the uh fastest easiest and best ways to demonstrate exactly how similar these two things are if you're a factorial player or a software engineer both of you are extremely familiar with the term spaghetti and if you're neither of those I've put together a completely sane uh normal analog as to what that is so we're gonna roll that clip now this is Isabelle and this is Lucy Isabelle wants to call Lucy so being the great hypothetical friend that you are you set up a phone line between them so they can call Oscar hears about this and wants to be connected to Lucy as well now luckily he lives in a really convenient spot that's right next to the phone line anyways so you can just plug him right into the network and this is where the fun starts because now Victor Edward and Tim live in the area and want to be connected to everyone on the network but they're only kind of close to the phone line and not close enough to just hook in so do you redo the current Network into a sensible grid system with directional hierarchy no of course not you just curve that phone line around do a little bit of squiggling and pushing here and uh just extend that bad boy and you're good to go okay now let's really crank things up so the rest of the neighborhood joins in Wendy Olivia Alice Nancy David Allen Hannah Anna Luke Frank I don't even know if that was enough names or if that was too many but anyways now you got all these complications cuz like Wendy wants to call David but doesn't care about Nancy so she doesn't need to be on the network per se but then Olivia wants to call Nancy so they need to be connected and Allan actually went they're in the same and before you know it you've made a bunch of spaghetti I mean it's always been spaghetti but like now the spaghetti is more spaghetti you get what I'm saying and if you're thinking okay those gummy beers are really cute cuz they grew on me but is this really relevant to factorio well guess what here's the actual factorio image I base this off of that's right you can't say I don't put effort into these because I do also those gummy bears lived happily ever after to a ripe old age and died peacefully in their sleep suckers oh it's not what it looks like anyways let's cut to the chase so this is what spaghetti looks like in factorio and this is what spaghetti looks like in a microservice architecture diagram which is a fancy word for saying a pretty picture that we use to describe our systems in fact I would just argue that you can replace any of these gummy bears with just random AWS services like AWS Kabuto andoro or Lon those are Pokémon by the way and and you would effectively have the a microservice architecture diagram the reason why we're starting with this and what I absolutely love about the similarity is that to the best of my knowledge both communities so the factor community and the coding Community have I feel like independently and individually come to the same conclusion that this is the term we use to describe a very specific type of pattern okay now I I hear what you're saying you might be screaming at your computer screen right now uh for one very obvious reason spaghetti is great we love spaghetti you can eat it on a train you can eat it on a bus you can eat it on a segue to our next section code [Music] tracing huh we're definitely not producing enough blue circuits I wonder why oh yeah we're not producing enough red circuits for the blue circuits but wait why are we not producing enough of these ah yeah that makes sense yeah not enough green circuits or the red circuits which are for the blue circuits but wait oh God right we don't have enough iron plates what we've done here is what I argued the exact same thing as code tracing and just to clarify like you could call this anything uh Cod tracing is just cuz it sounds better in the title but like you know people call it like debugging or just figuring out the problem or like looking at the stack Trace right and what it is is exactly what you saw you have an issue and you have to you have to fall follow your little breadcrumbs that you wrote when you were just like diseased and sad and the worst that those breadcrumbs are in the line the harder it is the more annoying it is to figure out if everything's in like a perfect little grid then it's a lot easier this also brings me to like a sub point that I want to talk about which is the topic of readability Story Time the first thing that comes to my mind whenever I was thinking about this was uh the story of when I was an intern at insert big tech company here like two summers ago and I was so so proud of writing this piece of code that was like this recursive structure um that could take uh uh any length array of any different length arrays and it would it would give you all the permutations of all the items and I was so stupidly proud of this uh because I thought it was like the best thing that anyone had ever written and that I had written and I got even more stupidly proud of it when it got approved and the code went through and the code is in the code base now uh and then I came back a year later as a full-time employee and I immediately realized why it was so dumb of me to be proud of that and in fact why it's actually insane that the code got improved in the first place because I was looking at it and I was like I have no idea what this is and it's not because previous me was smarter it was because it was just a really messy piece of code right it was something that sure might have been smart but if nobody can read it understand it when it breaks it's just broken forever and it's useless never mind somebody else like a different engineer coming back and doing it will you like your own human being two days from now will you be able to look at this and like work on it and fix it right because if you don't know what's going on God knows other people are not going to know what's going on and I think this really underscores my point about readability where the microsc that you might get from making algorithm that much more efficient or that many less lines is almost never worth the pain and time wasted that you will have in the future or somebody else will have in the future trying to understand it improve it fix it or change it and I want to acknowledge there's obviously a lot of caveats here right uh if you're working at like a high frequency trading shop the nanc that you save are probably worth billions of dollars to your company in that case yeah you you write whatever you can to make the most efficient Possible Trading algorithm so that you can earn that money for your company another caveat is like maybe there's just literally no other way right there are genuinely sometimes where you need to have this like really crazy algorithm or thing to do what you need it to do or maybe you're playing Factoria and there's just like a giant Lake in the middle of your base for some reason like yeah I get it you got to you got to do what you got to do now that we've identified that the issue with our systems is not enough processing because we've done the code tracing uh how do we fix this well that brings us to our next subject which is scaling I what am I doing okay so I am super excited about this chapter and the reason why is cuz this idea the one I'm about to talk about is the reason why I came up with this whole video essay this is the Inception of all the similarities I started to notice so you're going to want to stick around I promise because the very end where you know like everything comes together oh it's beautiful all right so let me drop some tech knowledge on you if you're not familiar with the internet the Internet is just other computers that we have somewhere else underground or just in giant warehouses what we do is we link up all those computers and some of these computers's only job is to take your computer's traffic and send them to other computers and those computers we call servers because they serve information to traffic now bear with me here this is the really cool and crazy part those servers those computers those machines each one of those can be seen as one of these branches and the way that we scale then becomes the exact same way we scale in factorio let me break it down imagine each one of these little smelting machines as like a CPU right this Branch becomes a computer and so when you have more of a processing need for higher traffic the way that we can scale Up This Server is by three axes the first axis of scaling right is we have this Branch we have this server and we can just add more furnaces we add more processes right so what happens is we have the Ser we have a computer right and we just make it bigger we make it taller and this is what we call vertical scaling ah ah see see vertical scaling isn't this cool the second axis of scaling uh is we can go this Direction that's right you guessed it horizontally and we can add more computers and that's what we call horizontal scaling in software engineering just let me this is so crazy like does anybody else see this it's this is a computer these are processors we literally scale vertically to add more processor into this one computer or we add more computers and we scale horizontally you know how to Vertical scale and horizontal scale now and now there's a third axis that I like out outly scaling yes I made this up yes I could be missing some axes if you're smarter than me yes you should be commenting right now what you can do is you can input speed modules uh into these furnaces and what that does is it doesn't change the amount of furnaces it doesn't change the amount of branches it makes the furnaces themselves faster and for me what that means in this analogy is that the server the computer that we have we keep the same amount of CPUs we keep the same computer but we swap out the CPUs for faster ones we're not adding them we're not adding another computer we're just making them better and those are the three axes scaling three axes of scaling that are the exact same thing as computer science and software engineering isn't that crazy like does anybody else realize how cool that is that like you're just playing a game and little did you know you've learned like a high value skill that a lot of people use on like a daily or weekly basis to make sure that giant websites like Google Amazon and Facebook don't just crash that's crazy and so now you know what scaling is we can start to talk about the really cool stuff which is traffic and traffic shaping so what better way to get into traffic than via Segway oh God somebody sent me to the nearest hospital all right traffic shaping now there's two subsections I want to talk about in this chapter the first one is autoscaling and the second one is load balancing and you're going to want to stick around because this plus the next chapter is going to just totally put together this beautiful image of how the internet works and how you yourself can become a software engineer let's start with auto scaling because we just talked about scaling and you're going to love this factorio players so you see this thing that we were just working with but you know what software Engineers have done we have automated the Automation in factorial terms we've hooked up wires and sensors to the inputs and outputs and then we can detect if we need more machines depending on how much is coming in when there is a need for more processing power it automatically adds more computers to our server base or it swaps out a computer for a different one that's all done now without any human intervention so for example uh Facebook usage goes up because your mom is trying to talk to me God damn it God damn it can't keep doing this our second subsection of this chapter is load balancing and load balancing is one of those other things that factorio and software engineering share as the same term in Factoria you have this beautiful guy who load balances you got your 2: one you got your 3:3 you got your 4:1 I'm going to hate animating this later because that's just a lot of random pictures I have to get and it's exactly what it sounds like you have a set amount of input and you're trying to get the correct amount of output so it's even among whatever your processing is so in the software engineering example these are our servers and the incoming traffic that we're getting we want to balance the load evenly across all of these so that this computer isn't getting a lot more than this computer unless this computer happens to be bigger right and this is what's really really cool go on to like AWS and search up AWS Auto scaling or AWS load balancing and there are services that are literally named that to do exactly what we said and furthermore you can go to like Google Cloud you go to Microsoft I can guarantee they have the exact same services this is a widespread thing that just people do nowadays that's a very common practice what I think is really awesome about this is that this is like public knowledge right like this isn't some crazy top secret like thing that I know that like only the Illuminati and people who can do this dance you know uh uh no this also gets to the core of what I said at the very very beginning of this video which is that these things are so alike because they also revolve around the idea of taking things that used to acquire Manpower and automating them away because we are lazy we do anything to not do a job even if it means that we ourselves will be out of one and this thing that took us decades to learn how to do to keep the internet running smoothly more about that later is something like you've just been naturally doing with your good factoral instincts playing games at home with your friends moving on to the next chapter I don't have a good segue for this so I'm just going to keep rambling until I get cut off okay upstream and downstream dependencies this is their last but I would argue maybe one of the most important points that I have to make in terms of keeping the internet running and so I'm really excited to at the end of this show you how this chapter in the previous chapter kind of conglomerate into this perfect beautiful image of why websites go down or how we keep them running and how maintenance Works in general so let's get into it so sticking with this analogy that the materials and the intermediary products in factorio are the exact same thing as the information we're handling in software engineering systems we can see here that there is in fact a general flow Direction Where We have lower value materials SL information being processed into higher value materials SL information so in Factor this case we just started out with iron ore and coal and copper ore and we get to extrapolate and and mutate all of this stuff into really high value things that we can then deliver now this becomes really cool when you put it into the context of traffic shaping because traffic shaping then affects your Downstream Services right so if we take a look at our whole iron service which we've upgraded to now be able to intake more iron or and output more iron plates you have to then think okay but in our entire system there must be some other service that's taking this output right that's going Downstream so you trace these iron plates Downstream and you realize now that you might be overloading other systems or in this case they might just be backing up now here's a slight difference between factorio and software engineering where in factorio it's okay if stuff backs up but in software engineering if these things back up that means that people aren't getting to your website you're losing money and that's bad because capitalism good and we need more of everything and everything must grow and the factory must grow and I oh my God and this is the lifeblood of basically all software applications as we are taking some sort of input information from the user like your birthday your password uh what kind of cat food your cat likes and we are spitting back out information either to another service or directly to you you see how beautiful this is and that it's the same thing the reason why you want to have this in your sort of like software engineering back pocket of lexicon is because a system up here will always impact a system down here if they're connected in some way and this brings us to the idea of contracts or schemas which is just a fancy way of saying the format in which you pass information between these things so if I have my Upstream iron intake here and my output is just like three full belts right then the down trre dependency has to take in three full belts or maybe one belt but you have three of those Services the point being here that the way that this thing outputs stuff will impact how we design the intake here right because this Upstream service impacts this Downstream service now I said earlier that the autoscaling groups I mentioned earlier that autoscaling load balancing and now upstream and downstream dependencies these three ideas together would form something really cool and I'm here to give you that right now whenever anything goes down ever right and and all of us including me think oh my God how is this possible I just want to log into Apex Legends I just want to log into Facebook so I can talk to your mom all of us are are thinking the same thing which is like how is this possible you have like a bajillion dollars and and just warehouses and Farms filled with rocks that we've taught to take in electricity and do thinking for us right and and yet somehow I I hit the button to go to your website and the website can't do the thing what is what is how's this well now you kind of understand where the different fault lines lie you could maybe have scaling issues where you just don't have enough throughput and therefore all of these servers are just clogged up and you can't get people through you could also have load balancing issues where you're not properly balancing between these three servers and so all of them are just trying to fit through this one server you could also have upstream or Downstream dependency issues where let's say one of these things goes down because your friend decided to Nuke your base Patrick and now you just don't have any iron processing so everything Downstream from that is impacted because I can't get the information they need and this is what's just so mind-blowingly cool about this and I know I keep harping on this but I have to repeat it if you're a factorio player and not a softw engineer you already know all these Concepts anyways I'm just rehashing it to you in a different form with different words but it's the exact same concept so you've been playing factorio for anywhere from 100 hours to 10,000 hours and just been sitting there playing games with your friends and you know now how the internet works and how Services can go down and how to structure systems that are robust self-healing that can serve millions of traffic so I can finally get on Facebook and talk to your mom so yeah I mean now you know kind of like everything you need to know about no that's not true that's not true at all no okay so here's the deal I realized halfway through um writing all the scripts that there's actually too much to talk about okay and uh let me break it down and just level with you there's two big topics here and we only covered one of them so originally I was thinking there's two different types of software engineering in terms of two different types of services you can make um or I guess I should say programs you create a monolithic program right which is just one Big Blob or you can create stuff with service oriented architecture and that's what we've been talking about where youing it up into little pieces that all talk to each other right and this is where I need your help I want to make another video but I don't know if I should I don't know how to make it better and also I just don't know if it's you know worth the time and effort so if you could comment below about what you think if you want more of this or if you want to like or even dislike just just give me feedback subscribe if you want to see the next one if it comes out and that would be absolutely amazing and I'd really appreciate that I know that this is cringe but thank you anyways thank you so much so so so much for watching the video um I'm going to put up some fun little cute uh videos I guess while I do the outro here um check out the patreon if you want uh links will be either here or in the description below um I also will have like a twitch link uh and just a bunch of other socials you really want to throw me a bone um I don't have like anything on the patreon right now but like maybe I'll put up like a director's commentary or something if this video gets big um anyways y thank you so much all right peace love you bye
Info
Channel: Tony Zhu
Views: 636,742
Rating: undefined out of 5
Keywords: Video Essay, Factorio Essay
Id: vPdUjLqC15Q
Channel Id: undefined
Length: 21min 26sec (1286 seconds)
Published: Thu Dec 07 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.