In D programming language, enumerations (enums) provide a type-safe way to represent fixed sets of values, such as different file paths or configurations. The video demonstrates how to define an enumeration with named constants (like path.supporters, path.dlang, path.fail) and use it in switch statements to handle different file types. This approach improves code maintainability by centralizing path definitions and making the code more readable. The presenter struggles with the concept initially but eventually understands that enumerations allow matching actual data with different names, making code easier to maintain and less error-prone.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Live programming (I use Arch btw)
Added:It was muted. I'm so I'm so sorry.
I'm so sorry, guys. Let me Let me reiterate what I just said. I need to get a background that looks like this.
but with um Linus Torvalds instead.
Okay, it's going to replace this one.
Okay, if somebody makes that for me, I'll use it in a video and I'll uh put your name into I'll put a thing for the into the viewer text file.
Um so yeah, just let me know if you do that and uh send it to me on like Discord or something. I don't know.
Anyway, um me I am working on the project of all time and I got it to work. You know what's really cringe is when you use one class constructor to do all of your code. So I have my void main entry point and then I do autodo thing equals new do thing and it just uses the default constructor which in turn imports core.runtime and then uses this or takes this.orgs from runtime.orgs and uh just don't worry about this enumeration. I'm probably going to make this a global thing cuz I don't really think I mean it's fine to put it in here, but like uh also you don't really want to put it in there because obviously that's going to basically be the same as having it globally declared. Um so yeah, there's a couple implications with this.
Uh probably going to scope guard this honestly cuz you're only going to need that for so long before it's just not something you need. Uh anyway, continuing down, we have do thing.
Supporter and uh we're going to use [clears throat] the enumeration for this.orgs and that's what I'm going to do. Yeah, actually enume this.orgs args of zero.
And that should just give us our uh runtime or or whatever the [ __ ] it's called. That's the enumeration. Okay, so enumeration is going to allow us to basically put supporters or dlang and give us a path from there. Um, and then pass that to the supporter handler.
We're just going to change to um do thing uh I don't know like fun fact. I don't know. It's not not really a fun fact. I mean u I don't know. I got I guess fun fact.
Yeah. or no, fact.
Just call it fact. Okay. Yeah, that's is that's cool. That that's that's a good name. Uh I feel like naming shit's probably the hardest thing I struggle with, bro. Uh but that just means I'm a [ __ ] genius in disguise. Anyway, that takes string uh string path. And uh instead of doing that, we're just going to use the enumeration and uh put that in there instead. So I should be able to use Is that how enumeration works?
Bro, I need to read the D lang guide on enumeration.
We're using tour today. Brave browser is going to kill me inside.
Oh god.
Uh, delaying documentation.
Beautiful. This is going to get us to where we need to be. Oh, I didn't check the microphone.
Did I check the microphone? Hello.
Microphone. Good. Right. Oh, hold on.
Oh yeah, that's good. Nice.
Thank you, me. Um, what?
Where's my documentation, bro?
Try cleaning it up. Restart the tour browser.
Please take me to the Dang documentation at this time. Thank you.
Sorry. Um, sometimes I get the the Chud theme song stuck in my head because my brain is fry.
Library reference. We're going to go to the library reference. So, we're to do um find something enumeration, right? Uh let's just look up enumeration because I have no clue what I'm doing.
Coolio.
What? Whoa, Google, bro. Our systems have detected unusual traffic from your network.
Um, I'm not letting my computer get backed by Google, a bunch of amateurs.
Me, I am less than amateur.
Wow, everybody likes LLVM tool chain. Except nobody does, but I do. I'm a big fan of LLVM tool chain actually.
[ __ ] you VS Code. [ __ ] you, Windows. I mean, wind blows.
CentOS. Is CentOS pretty cool? What do you guys think of CentOS? Tell me.
thirdparty downloads.
You're saying my Arch Linux is not the same as regular Dang.
Snap. Snap to open BSD for weirdos who want closed BSD. Um uh guys should just be in one of the standard ones though.
You know what? Just type in numeration.
Wow. Nice.
Oh my god. I can't I can't read it because it says Ubuntu make your life suck in the background. Bro, I'm getting [ __ ] lost in this. Bro, Lionus Torbolts is watching us from the background telling Nvidia to go [ __ ] themselves.
And uh man, the Ubuntu make my life suck is really doing it for me right now.
F in it.
Oh wow.
Enum identifier. Enum body.
Okay.
Can you do enum identifier colon anonymous base decoration enum colon enum base type and bro? What the hell? Oh, you stopped falling asleep, bro. We have works to do and that work does not involve Ubuntu. Um, fu.
Here we have enum e where e is what?
I guess expression.
Please explain it this time. Fu e. Oh, enum fu and then e.
So like if okay enum e is car a comma b equals car domax c equal or c and then overflow interesting static asserture e do ah so that's the name and then the dot is just whatever is under But we know that there's multiple potential values that come in from our this.org args. Bro, enumeration is one of the things that always gets me broke. And anyway, um I guess I've declared it as n on my swipe somehow, but this args should enum, right?
So here we have enum A equals 3, enum B, enum C. Those are like a bunch of different enums. Enum E colon C. See, we want a different name for the main thing and then then different states of it. Um so if I for example had anonymous enums the if the enum identifier is not present the enum is an anonymous enum and the enum members are declared in a scope enum ABC enum long enum string Oh, hold on.
So, we want an anonymous enumeration and um sets A= 3, B= 4. Maybe we don't want that.
No, I think I'm wrong. I think I'm just confused because I've used Enum before.
What does the doc say?
When when you have any kind of doubt, you just got to consult your documentation or what does what does what does what is his name? What does Ali say? What what what is his documentation? I cannot say his last name. I apologize at this time.
Um because that's uh I should be better anyway.
Wow.
programming in DtrlF.
Let's find enumeration enum. He he doesn't seriosa.
What?
Ah, here we go. So, that's the name.
And that's a switch with that, but he uses enumeration on which one?
Uhhuh. Uhhuh. Uhhuh. Okay. Where's Where's the [ __ ] enumeration enum Elon Wear, bro?
I like how it opens a second web browser. Makes my [ __ ] relax.
Wow. Wow. Wow.
Wow. No.
Enum operation. The enum type operation.
Oh, you need to do an equals.
Okay, so equals and then your switch has to be defined based off of that.
Very good.
Good job, Mr. Freeman. Uh, thanks. Today I have become Enam, the enumerator of worlds. Thank you enumeration.
Thank you enumeration for helping out the this video. Anyway, this is completely wrong.
What?
And that is simply just have to call it as a um simple mode.
I don't know in um we're going to put this places. We got to think of a good name.
Maybe our our supporters our deal path.
Yeah. Yeah, path. Just just call it path. What it what it [ __ ] is path do thing fact is going to use the path dot whatever. Um the thing is that I'm kind of confused on how you would use this.
Would you just use in place of how would you get runtime.orgs args as path.
Um, I think the first thing you do is you make a block of code that does a bunch of if statements. It says, need to see more examples.
Dang uh enum examples, bro. Let's see.
Yeah. Yeah. Ubuntu make my life suck, bro. Alias email members online tutorials library. Let's see what they gots. What are they cooking on tutorialspoint.com?
My high-speed web browser is routing traffic through the tour network.
Aha. Oh, days. And then days equals days do month or day equals day what um I'm confused.
So what is days.mmon?
Where where's your full code, bro? Come on. But anyway, I'm pretty sure that you can just set that equals something else.
So you create your enum days and then day equals day.mmon but days day.
So you create your enum and then you do days.mmon.
Oh Monday. Wow that's great. But then how well actually I don't know maybe you would use enum days. So, bro, I don't know why enumeration always just eats my [ __ ] brain cells.
Like, every time I go ahead and do that anonymous pseudo sy.
Oh, so that just means you can just write them down.
Add on.
Oh, get me out of that website. What the hell extension? No pseudo block that request.
They're going to backdo my network if I let them do that. Anyway, we might want to anonymously enumerate.
And uh to do that, you would just put something like this, I guess, and then put a colon string.
Yeah. Yeah. Yeah. We'll just [ __ ] wing it. colon string.
And then we'll probably put a right line since I don't really know if it's going to work.
And that's going to write ln and put our um it's going to put our uh interesting stuff going on which is going to be runtime.orgs.
Not runtime.orgs. It's going to be this.orgs.
This args and then one What? Zero. I'm really confused right now. I just saw something that really confuses me, but I'm not going to say what it is because um that information is very interesting and quite weird at the same time. It's like uh there's almost nobody watching, but it still says the average view duration is 22 minutes. And and so that leads me to believe some suspicion of interesting thing.
No. Take me to the Arch Linux page.
Yeah.
Art mode. Extruded up black man. That's why you DMD gesture. The What?
DMD gesture. D.
Okay, let's see what it says.
What do you say, Mr. Freeman?
when expecting semicolon found semicolon when expecting comma thank you very much bro I don't know if I'm a fan of enumeration it sounds pretty lame actually you know it really doesn't change anything because it just doesn't so um What?
I might pull up an example. What am I doing? Uh, I'm working on a pretty cool tool. It's going to be able to read uh names out of a file. It's going to randomly select an index and then start from the end and take 20 lines and just print them out. It's going to be some really cool stuff. Um, but me, I don't use enumeration or like anything that's cool. So, I gotta check one of my references, one of my old reference codes I wrote with enumeration because I'm really quite confused on what I'm doing with enumeration at this time. Um, because it's kind of kind of lame. I think enumeration is kind of lame, but also uh I want my code to look prettier and this.orgs is [ __ ] disgusting to me.
Is that rust? No.
Why would I use rust, bro? Jody Brutecon says rust bad. And I listen to Jody. He says rust is bad.
So, it's Dang, by the way. Um, anyway, [snorts] I'm just referencing some other data. It should be my calculator example. I should have one that's just called calc.
Ah, perfect.
Let me see what it said. Oh my god, this code killing me. So, it's got one. It's got a switch called operation.
Oh.
Oh, you know where enumeration is just amazing? So, enumeration is great when you'd have to write a name out for what it is. And uh so you would create your enumeration, right? And it'd be like enumeration path. And uh this actually doesn't go here. Okay, so we pass this off to the function or the method in this case. Um, and it's going to take care of that for us. So, just slapicate that in there.
Uh, probably not here, though. Also, we don't really don't need to get the all of that.
We've already done the file.getlength, but we're going to do it differently uh because we want to have a length of we want to have all of the lines. So, we'll probably call a different thread that takes all of the lines of the file and then just does all of the counting lines while the main thread does other initialization things. And hopefully it syncs well enough that it ends up um No, we could just have both tasks be handled in two separate threads and then have who cares? Well, we could just do all in one thread and just be be like, "Fuck it." And just go slow.
Go go go lameo mode. Lauo mode. That's what we're gonna do.
Oh, yes. Lauo mode. What a what a great thing. Um anyways, just going to write the line for the file size to start off that way. I have that kind of initialized. This will just be here. Um in in void facts, do think fact.
Then uh we have our path.
So the thing I like about enumeration is that it allows you to put dots between stuff, which I think is really cool, but at the same time, uh I've never really used it that much.
So, I really don't know how useful that is. Anyway, we'd have like a case and it'd be like, "All right, case." And the case is simple. It's just going to be like or no, we'd do a switch.
That's what we did yesterday, too. But we did the switch in here. But here, we're going to do a switch in the void fact, and it's just going to basically change what which um which thing is going in. And uh the way we're going to do that is we're going to take uh the name of our thingamajib and shove the data into here for example path but this is now shadowing path. So it has to be um the font act or real path or like underscore path or like path and then uh instead this will be file and then uh that that makes more sense right file and path and then we're just enumerating the path so that the paths can go into here which makes it really easy to maintain and then all of this can be my uh actual cases. So I can do case and then I can do literally just path dot boom and then also if path does not exist or like if there is no path do don't work. That's what we'll do. The default will just be throw an exception.
Um, if it does not work, let it crash.
And then we just put a colon after that.
Put our paths delaying supporters.
And that's how it's done cuz that makes it look really pretty.
[clears throat] Basically, enumeration allows you to match up the actual data with a different name. So, that's literally all it is. I mean, there's a there's a few other usages for it, but obviously it's not the most useful thing of all the time or it's not really a feature I really use that much.
I'm sure a lot of people use it more than I do, especially people who know more than I do. So, um, if enumeration has changed your life, then let me know.
But really for me, I don't really think it's had much impact. Um, but I guess now it has because I had to relearn. So, congratulations to me for not using enumeration ever. I guess write ln and then just put no path. Technically, I could put another one and we could call it fail.
And fail can equal another string. For example, not uh no path or no arguments or yeah no path provided or uh no arguments. Why not?
I can't write, bro. I I am the worst writer.
No arguments provided.
All right, that's good. And then just do that. All right, so then we can just instead of doing this, I can put file or path.fail.
Although I feel like uh doesn't this technically this is like a constant or like uh enumeration is like immutable almost. So it's like uh once this is in existence uh it's in memory isn't it?
And I don't like to put strings in memory because they use a lot of memory because how they work each letter being a bite. So um I mean I guess the more bytes you put into memory um the more more letters you have the more you put in memory. So I'm not exactly entirely sure on that. I haven't really done much research into how that entirely works.
Uh anyway so yeah now we can just use path.sup supporters and u that will be how we can use our our file paths now and then the case will be break.
So just like in a loop where if you are in a loop you just can throw a break. Now break will work here because we're not in a loop. So because we're not in a loop we don't need to return to the lower level of the loop to continue doing iterations. we can just throw a break. I I think that will be fine.
Um because well anything that goes in this body of the case will be just executing code. Now the problem is that anything we do in this one or this one probably going to be the same stuff. Although this one we know is going to be shorter and uh it's for the supporters text file which if I open you'll see is pretty short viewer and uh this was from a viewer yesterday so well a supporter yesterday. So that's um kind of different big big difference anyway.
And so this is what you type into the args and then this is what it will do.
And for now we're just going to put write ln for uh path.sup supporters.
And then we'll just check that these are actually working.
Oh my gosh.
Path. Delane Dang.
Boom. So, this is going to take excerpts of the Dlang Bible, and this one's going to take excerpts of um any any supporter messages I get and stuff. And then uh yeah, pretty much all that is for now.
The default is path.fail by the way.
Oh yes.
Let's go back to here. Let's go ahead and uh dmd jester.d found sudo when expecting what the [ __ ] is setto pseudo. What the hell is this? When expecting parenthesis.
What is dealing? It's the deep programming language.
Where did it find this at? Hold on. Let me Let me use my eyeballs. Line 13.
Pseudo. Bro, why did I type in pseudo?
When did I type that in? That must have been yesterday. I must have been like [ __ ] tired as hell working on this.
Unidentified identifier paths. How is it unidentified identifier? Right. It's literally inside of the the code. Um, hold on. Let me check.
Arm path.orters.
Maybe it needs me to capitalize my enumeration like a real enumeration enjoyer.
I'm going to enum so hard this stream.
I haven't really used enum that much, but wow. Now it's got capital paths.
Oh, really?
Oh, wait. You know what it is?
Let me hit control-z a few times. That No, that's not a thing that exists.
File.
Boom.
Write len file size, which is get size file. And it's just the name of the thing that args zero holds in the constructor, which gets passed off to this thing. Um, which is weird, but uh it keeps my constructor from looking like absolute complete balonian garbage. Although it still looks like [ __ ] garbage because then I have to have this giant block of [ __ ] garbage right here. Some would call this bloat, but me I call this um incompetency.
Ah, good.
Wow. index zero is out of bounds for length of zero because I didn't I didn't provide anything here's something we need to do is add exception handling for stuff like that um delaying delaying no such file or directory uh um what what is this hold on let me check filefile exception user include dlang file dang no such Um, what was the path again? Oh, you know, it probably was, um, ah, you know what I'm doing wrong right now? The enumeration should come first and then we just convert the file into the path and then that's how that should be.
Tab tab tab.
Instead, we should put it down here instead of trying to use [ __ ] file.
Because if file is going to be our actual path, then that works. But if file isn't the actual path, it doesn't work.
No work. Oh [ __ ] My bad, guys.
So, let's go down.
Cannot pass type path as function in as a function argument.
Okay. Well, you know what? I can always just remove that. Um, because I don't really need the size. Although, it'd be cool to get the file size. It really isn't necessary.
Oh, you know what it is? Uh, path dot one of those three, I guess. Path dot the literal of file.
Oh, [ __ ] Um, well, you know, I'm not rewriting this. Well, actually, oh my god, man. This man, this hurts me inside. Okay, we'll just get rid of all that. We We don't need that. I know why it's not working because that that's just taking um it's trying to take the path, the entirety of the type path, which means basically the enumeration, and shove it into there as a as a function thing. But I I don't need the length of the file. I don't need that anymore. That was something I was working with yesterday, but I'm not really going to need that.
So, let's just um fail. Oh, I love when it fails. Wow. Delay. Maybe it's just not probably needs a new line character at the end. Actually, no.
Does it?
Yeah, like delaying fail because uh let's go ahead and put in Let's put another write in and we'll call it's uh this.org args. So that way it writes out the full uh args for this uh is that what it's called? Yeah, this args. So oh [ __ ] my bad.
Okay, non-static this.orgs requires an instance of do thing. Oh, okay.
Oh, but no, that can't work because then it's [sighs] um let's do that outside of here then.
Actually, that's that's that's amazing. Let's use G-shared next time. Unders this. Okay, let me let me explain something. I think classes are really great for one thing.
Um, which really makes them stand alone is that they can be used for like threads and stuff. That's one time I really thought about using them. I was like, "This will make everything really clean." And they kind of do if you're not using them as your main function like I am. I mean, like, what am I [ __ ] doing? This is abnormal.
This is inhumane. And I should have been stopped before I started. But I should have been stopped like four months ago when I started learning Dang. How long was it like five months ago now? 6 months, bro. Should have been stopped six months ago when I started. And but now I'm here where I kind of know a lot, but not enough yet to really do super exceptional things yet.
But that's why I like to learn every stream so I can learn stuff. Um, I'm going to shut up and I'm going to get back to the point. Uh, so we're just going to do a inside of my this constructor, we're going to write the line for this.
Before we do the do thing because the do thing just breaks right ln and then this.orgs args zero because why not? All right, that will give me my that will give me my debug so I can see if it has a new line character. Although odds are it will just print that. Um I could also do a roll write and we can just use a hacks editor to do it.
We could also do for each of this.org zero and we'll do for each chr and uh for each character I want to write out what that is in a u bite. So we'll just um write ln ch uh cast.
No, we don't need to do constant ubi chr.
Um yeah, that will work, guys. I'm I'm telling you that will give me uh the raw information so I can look at it and tell you if it's terrible and disgusting me.
Um, all right.
Help. And you can see it gives me all of the lines. Uh, 112. That looks like it would be the P probably because the the new line character is like slash10 or slash20 or something.
So why does it fail then? So if I do delay lang and then I also wrote out dlayang as okay. So yeah they don't end in the same thing. So that just gives you the characters. Um it doesn't take the enter and put it into the end of this which is really good. Um I didn't know that. So now now that that means bad though because uh I didn't find the answer there. So where is it going wrong? Because switch file is based on file. So we'll just write line for file then too.
And and we also know that file is also a strct or no not a strruct also a um array. So we could technically write that with all of its beauty as a thing as well. In fact, I'll just take this and uh slapicate that down there. And we'll do for each uh for each of the file because that will allow me to figure it out pretty quick. Save. And for each of file, just write it as a ubite so I can look at it and see if it's right because I can read numbers into letters because I that's something I've worked with a lot.
Sir, what do you do or what do you do for a living? Me, I just uh yeah, I really can't answer that question, man. Why do people always ask me questions I can't really answer without like damn.
But yeah, I can't really talk about that.
Uh anyway, we'll get back to what matters. Uh which is the that's not working still. Um my brain cells are racked, bro. They're tired.
3:00 am and I'm programming before I have to go fry my brain for till 5:00 pm and then go and uh dumb stuff all day, bro. Anyway, I I hope that answers your question in the most vague way possible. Uh cuz I really cannot discuss what I actually do. So I mean right Ellen cast you bite chrn't really telling me much what is the path though like what what what path is it doing? It's just writing the [ __ ] fail. So um it's writing the path.fail which means it doesn't really tell me much. Like the case is pathdang.
Oh, my brain cells are stupid.
You know what I'm doing wrong is that I'm not putting so I'm putting switch and switch is based on file and uh that's not this is not how this is not how it works. Um we're passing delaying right into file and the cases case has path delaying right. So dlang dlang you'd think oh if file is path dlang which dlang equals that then do this. Um the problem is that doesn't work. So, what we're going to do instead is try the colon anonymous method, which is like this.
Um, and see what that does. So, I don't really need to worry about any of this stuff anymore because I I kind of understand why it's not working. So, I don't need to really look at that because I know that's going to work uh eventually. Uh, probably lots of uh and probably because um really I have no idea. It it might work today. It might work next month. Might make might happen the second Tuesday next month or second Tuesday next week. Who knows? Um let's see. Case path.orters path.sup supporters break continuing. So if we take that then we can just say if it's oh but that doesn't work because these are basically to say that those are that um we we need to set that back to path.
So technically it could be an a if statement but that's not how it works either. How do I convert string file into one of these? I think you'd have to do like some kind of matching and stuff.
Documentation, please.
The Dlang documentation is amazing.
Wowee. Uh, control F and look for enum.
This is not really the documentation.
This is the book though.
Final switch statement.
Enumeration, bro.
Let's enumerate, my dudes. Um, enumeration. I like to enumerate a lot.
Sometimes it's necessary to specify the actual type, the base type as values as well.
Okay. So, type name colon base type.
Okay.
So, yeah, if you had add, it'd be one, subtract is two, multiply is three, and divide is four.
It's kind of like a container almost for well it is a container but you can declare multiple different things. Uh interesting stuff. The real question is um heads or heads tails spades hearts diamonds. Okay, that makes sense. Then how do you how do you really use this? Uh if results equals that God damn it. It's one of those I can't I can't use the I guess it allows me to make it a little bit simpler because we still need Okay, so we still need to have um we still pass file, right? So passing file just passes dlang into there. But the path should be like case supporters and then we can use path.sup supporters and then we could use path.dlang for example for our file paths. It makes it simpler to look at the paths but it really doesn't help us much and kind of over complicates things. Although I feel like it's great for main setting ability. Like I don't really think enumeration is something I'm going to use a whole lot because it seems like something that would just waste memory.
Um I I feel like it's something that's a waste. That's my honest review for um [ __ ] this [ __ ] The enumeration right here. Oh, this [ __ ] Yeah, switch is great. I love switch.
But otherwise, pretty much useless. I don't see the supports supporters.
And uh there we go. So that will give us our paths.
So, let's go into here and run.
[ __ ] I'm sure there's some way I can make my code more and more high speed, bro. I want that. Not high speed as in high performance, but I just want my code to look cool, bro. Highspeed code.
Question mark. Is it real? Can high-speed code exist?
I don't think so.
No such thing as high-speed code on this side of um the world. Just rust.
All right. So now Dlang what?
Okay. So it writes out path dot delaying which means what exactly does that mean? Like what? So what does dealing delay equal? What? What? What?
All right. Now let's go ahead and put in file.get size.
Um, well, and now I have to create a a helper function for all of these uh some kinds.
Also, the the codes [ __ ] spaghetti.
It's [ __ ] spaghetti code season, and that's can only mean one thing.
I program spaghetti.
I'm the spaghetti master right now. And I am soon to master the spaghetti.
All right. Anyway, uh static void.
This is my static objectoriented spaghetti slot. It's really the cream of the crop for spaghetti. Um absolutely disgusting to most people. We use the class constructor to run the code. It's it's my main area.
do thing.Fact and then fact string file. And then this one also passes a string.
Some might say you don't really need this, but uh me I say well if I don't know if I have multiple statements, I can use the same thing. I might as well make a a thing with J to do it all for me. And if I don't want to look disgusting in here, then we'll just have to do that.
Uh call this fact.
No, not fact. Call this um fact_helper and it's going to just do take a stream.
This needs to be pre-installed bloatware for fish OS. Yes, it will be. It's going to be like God from uh Temple OS, but you know, you can't really call God bloatware because God is God. We're going to take file and uh so so all this does is um enumerates the [ __ ] um maybe I should rename this one to do thing translate.
Yep, that's what I'm calling it. Do thing.trans.
Keep going, bro. Yeah, I'm cooking, man.
Uh, instead now this is going to become Yip Yap.
Uh, do we want snake case or do we want the [ __ ] whatever that language I don't know what is this called? Haskell pearl case or something? Bro, those are languages I should check out. They're on my list to check out for their cool names, but they're probably absolutely I don't know. Actually, I might be able to get into them. Pearl or Haskell. I might be able to get into those. Java's on my list now, bro. Java's on my list of languages to try.
Anyway, this this function will immediately afterwards call uh this function after it goes in this. Um, so we'll just add a do thing.
yip_yap and uh and we're going to put our string file in there. We're going to put our instead of doing that, we're just going to put the path.sup supporters in there.
So, yeah, we've got the great code going.
All right, don't forget that's a capital T because this one's snake case. I should do snake case for my strus and classes. And then here's the problem is that like with programming and naming things now I have to think about what case I'm using because VLAN taught me about using cases and I'm like um there's a syntactically way different way to do it and like I've always just done lowercase first letter and then if there's another word in there do an uppercase on that. So I did snake case the entire time. Um, either way, these just create the do thing yip yap with the correct path. So that way it enumerates for you. Um, I'm sure there's a greater way of doing this because uh, this is terrible.
And but here's the thing though, at least it's kind of scope guarded. Okay, I can kind of defend the scope guarding on this because as long as it's in that void trans, then um when it sends it to Yip Yap, uh all it's got to do is uh well, it's only going to have memory in this block, so I'm not too worried. And then anything that's in the [ __ ] anything that else that's static inside of this.
Continuing down in my chain of madness.
Um, we're going to add some other [ __ ] Let's see.
So, now we have to do stuff with it.
So, we're [snorts] going to take string.file. We're going to do file. Uh, we're going to put that back in here.
import standard.
And then we're going to do a get size.
Also, that's not the correct uh formatting for that.
This one is snake case. I guess that is the standard for methods or functions.
Methods and functions, I guess. But in this case, I feel like it looks better to just put an underscore.
I don't know. What do you guys think?
Let me know.
Let's go ahead and put my uh get size.
Technically, why would I do it up here?
because now I have a helper function that can do this for me. So, um, cut that and this will allow me to keep my functions that I'm using one time locally.
So, [snorts] we're going to get the size and uh, we're going to be like, well, what's the size of the file? We're going to put the string file in there. Hopefully that can pass in as a file or as a string and uh for now we're just going to put write ln get size file which should produce a string produces I mean it produces some some or some output that I can print noise. That just works, bro. That gets me the dealanging one. And then supporters and then we can just have it uh choose a random line from the supporters file and uh print it out or or something like that or select a random block of uh text to print out or stuff like that.
So, now we just got to get the size of the file and be like, [snorts] what can we do with it from there? Oh [ __ ] you guys didn't see that. You guys You guys didn't see anything. The Nvidia gate.
Um, this this is why I like having six wallpapers. Uh, it's pretty funny when I accidentally slip under like this one and go, "Why is Arch Linux man in the background, bro?" That's the future of humanity. All all of humanity will be the arch links, man.
Arch arch enjoyers, bro. Um, continuing on.
Boom.
Let's see.
So, we get the size of file.
Really, I don't think I'm going to mess with that that much. I need to count the lines of it.
But, uh, that's going to be like counting lines. What am I What am I doing with that? So, we count the lines of file. How exactly are we going to count the lines of file? Let's uh Good question I haven't thought of yet.
So, we'd probably do file. We open the file though. It's the first thing I know. Auto file.
Uh, create a scope card first.
[snorts] Which is like probably not super useful, but can be useful in some cases.
We we'll eventually have a use for the get size file, but I don't have that use at this time. So, um it's kind of kind of not super great.
Backspace. Okay, we get we do that and get size file. Continuing on, auto file equals file uh and then just put the file name.
[snorts] So file and then uh go from there and then put a comma and give it read access. That should be pretty good. And then we can put our scope.
So I look all fancy and [ __ ] using a scope. Exit. Oh, file.Close. close.
[snorts] Look at that, guys. Am I Am I just gutted or what? I'm using a scope exit here to close my file if something goes wrong. So, that means if you exit the scope at any point besides hitting this last bracket, it will just close the file. So, that's that's Bro, I just hallucinated my alarm going off. I was like, what the [ __ ] Anyway, literally all you need is that. Um, okay. So, file is shadowing variable gesture.do thing. Yep. Yep. File.
Are you kidding me? God damn it. Why?
Okay. Well, underscore file close.
[snorts] Or maybe we call this something else.
um o file. No, just just put a [ __ ] underscore like a like like a a decent human being and then keep adding underscores for every time you add a name for file which technically that file is a strruct you use arch so hot. Yeah.
Uh yeah, it's really nice, right? Look at Look at all the rice I do. I don't think we're ricing this weekend, but um maybe Look at all of this rice, bro.
I I riced it so hard that I got [ __ ] shaders in my file browser.
500 files. Yeah, only good code. Only good code on this channel. Um, all right. Let's go ahead and save it.
Actually, let's not save it. Let's go ahead and Oh, we could add a compile time feature.
So that way, every time I add a new text file, it will just scan for text files in the data folder and find them all and then put them in the enum enumeration.
Um and then for for when we open the file let's do file.right ln or for each line of file for each file. EOF I think is what it is or maybe until end of file.
Wait, how is it called again? Let me open up the documentation again.
Well, the not documentation that I still use as documentation because why not?
Um, file. This book is actually really good. If you need if you need to learn Dang for some [ __ ] reason, this book will be the ultimate guide.
Good.
Wowee.
Wow.
Oh, okay.
Oh, well, not file. Okay, cool. Got it.
Or you could do Yeah, that's all your axis. There's actually more accesses than this. You got like B and stuff. Um, but that's for like u super great stuff like [ __ ] binary stuff. You can do raw binary things with it like raw write raw read while not file.
I guess I'm using a while loop like a lame person. Bro, I don't like while loops because they're [ __ ] lame in my opinion.
I'm a lame guy. I'm using a while loop today. The the while loop is lame. Can I use a for each loop for this? Please, please give me for each loop next time, please. Thank you. Uh, anyway, well, not file.
Then execute this file.
Ln boom. And then we'll start working on our random indexing feature and range selection. Well, actually, we'll just do range selection first. We already determined yesterday. We'll just use ulong end. We'll assign that somehow to give it an end point. And then we'll subtract 24 uh lines to select the beginning. So, this is going to be a number of lines. And I don't know why I used a [ __ ] ulong, but I guess it works because it's never going to be negative. There's never going to be negative lines in a [ __ ] PDF.
So, um, or in a text file.
Are you sure there's no EOF?
Oh, because I'm a jingus, bro.
I'm a jingus.
Today I am become jingus, the destroyer of programs. Let me program in the Linux kernel and I will destroy it.
No property eof for file of type string.
My brain cells have been damaged because I forgot it's exclamation point underscore file.
But that means that file still exist here. And after we use file to initialize file, let's go ahead and destroy that like get rid of that. So um do a gcol and destroy the file name.
Actually, can we use the um regular calls? I think we could use a regular C uh function call and just call one of those into existence to just [ __ ] get rid of that. Oh yeah, me I am a good programmer. I will program the next Linux kernel. We'll call it uh Linux 2.
Oh god, I have screwed up at this time.
I don't know what I did wrong. Let me go ahead and check.
Well, not file. File. Ln Jingus, bro.
G. Wait a second.
That's a thing?
No. No. That That can't be a thing.
What? So instead of doing write ln Gordon in this CA scenario, you can assign Gordon to a [ __ ] like a string d equals Gordon.
Um, let me see if this is actually a thing cuz I never knew this. But, um, D.L.
ln. Is this [ __ ] real?
Is Is this Is this an actual thing? Like, what? That's a [ __ ] bro if that's real. No [ __ ] um wow.
Wow. So yeah, you can do that or [snorts] or you just not do that.
So, while not file.eaf, but then how is he doing it in the book?
Because I'm really confused right now.
Wow.
Oh, wait. Really? What?
Help me, Gordon.
Escape.
You know what it is? Uh, we just Hold on.
62.
Still 62 because it only has read access. So, I didn't [ __ ] up. I was like, did I just write 1,000 lines of Gordon into there? Bro, that'd be like literally Isaac Kleiner from Halflife, bro. Isaac Kleiner. We just created the Isaac Kleiner file. Uh, the Kleiner files, bro.
Um, anyway, weird stuff discovered today that you can do uh string.right ln. I didn't know that was a thing. I don't think I'm ever going to use that because that doesn't seem practical for anything unless you can do string. Ln and put like [ __ ] other [ __ ] in there and have it also write that maybe, but I don't know what implications that would have. Probably not something I need. Just going to be honest with you. Definitely not something I need.
Let my my spine explode for a couple seconds real quick.
Spinal the spinal countdown.
Oh [ __ ] that's so cringe, bro.
But this is supposed to be readalind because I'm a [ __ ] jackass.
See, that's what I realized. [laughter] >> [snorts] >> Sorry, I'm getting I'm getting distracted a lot today. But that's okay because I'm learning a lot today. Nice.
Good job, bro. What?
Um, hold on.
And uh for this one, we might have to have a case handling for this.
Oh, because because this one's going to be like lines, isn't it? It's going to be just choose a random line of this file and read it. Whereas the other ones, they're going to be like pick a block of this file and then print it into the terminal. um because that's what uh Terry Davis did.
He he just picked a block of a file and then uh something like that. But he also loaded the whole file into memory first.
U he had this weird idea where he would just load files into memory and use all of his memory or something like that. I don't know. But he was he was he has he's smarter than I am. So like what am I saying? Um so it finds the file but then when it opens the file it does um let's see file what am I what am I looking at? Oh if I said I don't know Linux what advice would you give me to start with it? Um use Linux mints. Congratulations. you use Linux. If you use Linux Mint, you're using Linux. That's how you can get started. Linux Mint is easy. And then just work from there. Be like, "Oh, yeah. Well, maybe I want to try other distros." And then be like, "Let me see what else there is out there. I'll try Fedora.
I'll try Kubuntu." But for that's what I went. I went Kabunu, Fedora, and then I settled on Arch because I'm like, "Bro, it actually works." whereas the other two were just like exploding my computer.
Yeah, just go with go with go with the go with Linux Mint. Honestly, see what I what I don't like is when like people ask like to like um what is it? Uh I don't like when people ask like what DRO should I use because uh that's a question that only you can answer and you have to kind of do the searching yourself. Like I I didn't have anybody telling me to go use Arch or stuff like that. I didn't have anybody telling me to go use Linux Mint. Well, actually my friend was like, "Yeah, you should go use Linux Mint. It it's easy."
Um, that was where I got started, though. And then I ended up on Arch uh because I'm a weirdo.
Wow, it's real.
File that strip. read len which is uh from standard string colon strip by the way um by the way the file is a strct by the way well well thanks uh no problem I I hope I helped you I I hope I I genuinely hope I helped you because I I don't know um so these are follow the right lines says if you want to write lines to a file.
Um and then there's also a file read which uh we should be writing the read line because file read ln does that underscore file read ln and semicolon. You know what? I guess it I guess it does make sense that you can try that. Let's try that. Let's see if that works.
Clearly, we're not getting anywhere with it on here.
What? No. No. No. Nothing.
On scope exit file. Close.
What if I have to do write ln read ln?
That doesn't seem like it's a thing. I swear that was not a thing before.
Should just read it to the terminal.
Uh, save that.
Let's see.
Am I dumb? I've done this before. Let me just reference one of my other codes.
Hold on. It's on my other system.
Let's see.
I guess uh open desktop dtools. I [snorts] haven't done this for a while. What am I doing? modulus for loop dlu. What the hell was I making there?
Um file readallet. Where is that at?
[snorts] I guess I don't have that one anymore. I might not have it because um reasons.
Hello world. Of course I have hello world. That was amazing.
[snorts] actually doesn't fish runtime has it? No.
What? Oh my gosh.
[snorts] Terminal gooey threading vibed for loop.
Man, I don't even Oh, maybe that one.
Yeah, that one's got it.
All right, let's open.
You all can't even see what I'm doing, but uh fish bitwise.d.
Bro, that's such an unorganized program.
I don't know how I wrote this [ __ ] because that's like so [ __ ] unorganized.
Um, fish 64.B. Ah, there we go. Now I can see the horrible amount of code.
I see file that raw read or anything. Oh, it uses a strruct, bro. It's [ __ ] disgusting. A [ __ ] strct. God damn strus cringe.
Fetch 32 bits.
Okay.
So like fish bitwise there should be a function then called fetch 32. Ah which opens a file and it has a scope exit with file.clo and then and then file.sek seek.
Also, the underscore file probably isn't a good idea. Um, I think that's probably what's [ __ ] us over here.
It's also got a return for B swap.
B swap. Bit swap. Okay. Anyway, um guys, how am I going to call this file?
I'm going to call it f I'm going to call it um um f to pay respect.
F L E FL.
Um, got to come up with a good name. What am I coding? Uh, man, everybody asks me this. I'm starting to get tired of answering this question, but um, basically, we're going to make a thing that's going to open a file. And, uh, it's going to it's going to open a file.
It's going to do it in a in the worst way possible. And uh what the [ __ ] is wrong with this language? Uh oh, because I decided to use class and instead of main function, I'm creating the world's most [ __ ] ass uh class of all time. It literally will be the entire [ __ ] program. Is it a class? All you need to do is import this class and you have the entire program.
Very nice, right? Anyway, I'm going to just put F now because I can't really come up with a name. So, my brain's hurting. And uh you know, we're just going to do F and see if that helps me figure it out why it's not working because I should just read the lines and print them out. Unless you put X equals.
We'll try that next, but that's [ __ ] cringe if I have to do that. Um, all right. So it it does that. But maybe if it needs a for each for each until file. I guess it could need that. Let's try for eaching it cuz then it won't have a it'll just be like for each.
Oh, maybe this is actually a way of doing that.
file read ln and then uh put a right l and a new line character at the end.
Actually, I don't know how to do that.
We'll just put a [ __ ] right L. Right L and uh L.
Save it.
for each aggregate of type bool. Oh, so it's a that's a truth statement. Oh, I had no [ __ ] clue, bro. I really don't work with files much. Also, I say that about everything. Okay, that makes sense. Um because it would just be true or false.
I guess we do a four. We could do a force statement and uh say that we have I actually no just do a while cuz what I think is happening is it's not it's not reaching the end of the file because it the first line of the file is the last line of the file.
So would it read the last line of the file?
Maybe I need to add last line.
There we go. That That's good enough for me. I I think that's satisfactory. Um so maybe it only reads the first line, which makes no sense to me. But um I don't even know. My my brain cells are are gone. Don't worry, guys. I'm okay.
I've been neuralized at this time. Oh.
Oh, [ __ ] Huh?
So, does it need me to write ln the file read ln?
Is this the case?
Let's see. Um, go back to here.
Aha. So you you do need to write the ln and read the ln. What a what a great thing. However, now we're going to implement random line selection for this one. Um this one in particular. So, this is going to be handled by a So, the supporters file is the only one that needs it, but it needs to have have us um probably we're probably just going to put in like a Let's go ahead and do that. Supporter um if supporters What is it? Oh god, I'll have to put the path the full path this time. Unless I make this a um this dot that that would also be a local thing.
But uh I'm I'm not going to do that.
That seems lame.
Maybe I could pass a one or You know what? We should just make this into, you know, it'd be a lot easier if this was just declared inside the class.
I also don't know why I wanted to use a [ __ ] class for this. I mean, I guess it was just because it was funny, but this is not funny. This is this is disgusting.
This is slimy. This is this is not what a class is for. Classes are for inheritance, not not [ __ ] not being the entire main function. Um, classes are a reference type, not a function, not a a main function. Uh, I mean, I don't know what advantages there even is to this really.
I think you even load all of the functions and [ __ ] all into memory at once when you do this. When you when you call autodo thing, I think it might just load all of this into [ __ ] memory.
[laughter] So, it would have been better to program it functionally, not dysfunctionally where we just have a [ __ ] class. Bro, I'm I'm dying right now if you all couldn't tell. I'm This is killing me right now.
This is actually terrible. Um, the worst software design in history, yet I'm I know it's so bad and I don't really want to change anything because it looks cool. I'm using the class so I can tell my Java friends to suck it because I used I used the class for once instead of using functions for everything. Yeah, that's a I I can justify it, right? You you guys understand like you guys also probably program and you guys also probably have friend one friend who does Java programming. So now you can be like ah yes one time I've seen a guy who just programmed a worse class than you and his class is literally the entire main function. Uh replace do thing replaces main.
[snorts] Do thing supplement main. Yes.
Hi. Hello.
Welcome to seeing my [ __ ] ass program. I actually do think I might change the name to auto [laughter] equals new do thing. I have IRL friends.
Yeah, me too.
And one of my IRL friends wants to learn Python and Java. He's going to take Java as a college course. And I told him, uh, Java is hard, bro. Why would you do that? And he said, because listical say that J, uh, I should take Java or some [ __ ] because it will get me jobs and they only want people who know Java. I was like, "Okay, whatever universe you live in when Rust is the new craze, bro." See, I would put him on that Rust Rust bandwagon. But, uh, I I for completely forgot about it because it eluded in my mind. He was like, "Python and Java are the things that people want." I'm like, "Okay."
And I'm pretty sure they don't teach Rust in colleges because Rust is so [ __ ] cringe. Why would they do that?
But I correct me if I'm wrong. Somebody knows. Um, and uh, probably nowadays they do. So, I'm just saying it's like how Java was cringe when Java was new. Um, so maybe Rust will become less cringe, but to to be honest, I don't know. All right. So, we're going to create a random number uh, that gets created before this. So, before we do thing.trans, trans we need to create a number and uh for that I'm going to go and use standard.random which we we had it yesterday which was like mercen twister 19937 or something like that. So let's go ahead and uh do that. So um brain cells brain brainial and sanitosis. I think I have standard random right here.
We might not even use the mercene twister for this because there is a random range. So the rand gen can be a random range between that and that. But um we need to get the number of lines in the file first. So when the file when the file is loading um we just got to run this. So while not file eof and instead of writing the line we're going to create a counter of file.length inside of a scope here inside of yet another scope guard.
So we're going to we don't even need to get the file size but anyway I have that just in case.
So while not eof we are going to increment.
We're gonna take the file length and divide it by uh [snorts] I guess we could take like the amount of characters in the first file or the first line of file and use that to determine the rest of them and then do some that's too much quantum mechanics. No quantum mechanics because less moving parts. Um, less moving parts is the future, says the Arch Linux enjoyers. Um, like this guy in the background.
But I I really don't know yet because we could just we could just take like a a length and go, "Oh, well, if we know it's not that long, we don't have to do uh from whatever from the top to the There's so many ways you could do this, but also because there's so many ways, it means I have to choose which way I'm going to do it, which I hate making choices obviously because I like to program. And if I hate making choices, um, that's just standard for me.
Hate choices. H, imagine the shiny flaws of Python and then write the whole WM with it. That's QT QT isle.
Yeah.
Yeah, bro. That [ __ ] actually is Is that like related to QT? Like um but yeah, I know what you're talking about. QT Isle. Is that related to QT?
Anyway, there's a really easy one in here and it's called like dice.
No, we don't need dice. We need random rand random singleton instance of the default generator. So you can do rand genen. So you import standard.random and rand genen and then it gives you a number. Um let's go ahead and do that first.
We'll put the import uh probably inside this scope just just so it looks even more terrible. import standard dot random colon R&D.
Yeah, give me random, please. Pseudo, please give me random in my new [ __ ] ass import. Um, yet again, more terrible randomness. Uh, so R&D.take Take three.
Oh, what the hell is standard range take?
What?
Anyway, uh we'll have to look at what standard.range take is. What's this one?
The mandelro thingy. Get rid of that garbage.
Go back up to the top.
This is old file stuff which is lame and useless to me. Uh Google search failed on tour but it will work on Brave browser although I don't want them back during my my uh network. So we're not going to use Google. Um cuz Google is cringe.
That's right guys. Google is cringe. I'm pretty sure everybody agrees with me.
Um, thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank uh think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank think thank Microsoft yeah thinky gates wait is this one I needed standard range though it was like standard outrange and take hardware whoa contains hardware support for floating point numbers wow Wow, amazing.
of the C phes library to be.
I don't know what that is, but that's cool. Binary heap provides a binary heap.
A priority Q adapter.
Whoa.
Makes me like think of Java with heap [snorts] and stack.
I like my heap and my stack, bro.
Or actually OSD week. He likes heap and stack. Random Randy random, bro.
Ranges right. Range. Oh yeah, good.
Standard range primitives chain. No, no, no. Why is it all like this? What? Who decided to write back in the equation that looks like this? Lazily takes only one elements of a range when using infinite ranges. What? Infinite ranges?
Oh, okay. So, they're just taking the third one of that.
What? What? What the hell is standard tag for then? You could just do that by specifying an index.
I'm going to be on. Oh, wait. Random.
Take three sum.
That's for for dice, right? Or random.
Man, this is uh this this this is what what is this?
Why would you need center to take take that three that sum?
Anyway, we need to get the Mercing twister to give us a range. Also, what the hell are these like unsigned 42 billion bit or long units like 32 LU? That sounds familiar.
The default favorite suggested random number generator type on the current platform. It is an alias for one of the previously defined generators. You may want to use it if you need to generate some nice random numbers and you don't care for a minuit menu of the method being used.
Oh wow. Nice. So if I don't really care what I'm going to do, then go ahead and use any of them. [laughter] Just [ __ ] shovel it in there.
Uh, but it says Mercen Twister engine and I'm guessing it's just randomly doing those. I don't know.
So, that's how you would do that. So, you do random unpredicted seed and then but you you could swap that with MT9 1 9 937 and that gives you the same thing. Um my problem is I want to select a between two numbers, right? So I want to have like a range almost. So like I want let's go ahead and say oh actually we could just be like let's take the last number right that so that number the end number is going to be generated. It's going to be the last something. It's gonna be like a last samurai or something like that. Oh my brain's frying. Um, it's overloaded at this time. So, the end end thing is going to be local instead of that one.
Please don't delete everything.
I don't dare use that keyboard, guys.
Scrolling all the way down.
All right. So while not file end of line, we're going to go ahead and create our end or actually ulong file size. Wowee. And while we're doing that, let's go ahead and get rid of this because I certainly don't need that slop in my program. And um this awesome code is slowly becoming and and steadily becoming way more awesome as I add more and more lines to it. Uh eventually I'll hit one billion lines like the Linux kernel and I'll say my code is awesome because I have a billion lines. Um because more lines must be more good or something. It's not that uh you know anyway I can't really talk [ __ ] on the Linux kernel because I use Linux every day but and I also don't create my own version own kernel to um uh be able to fight with the the Linux kernel. Uh so I mean I I have no foot to stand on there. Um 1 million lines could be completely justified but I I'm not in that space.
Anyway, fill size also. Where's my semicolon please? Pseudo please semicolon fill size. Uh yes, this one fill the fill size here is approximately 30 L. Uh potentially potentially might be 30 liters. Could be. I'm not sure though. Might want to check that.
Let's go ahead and So, we create file size.
Why would I do it here? Oh, because that makes sense. Shut up, brain. What are you What are you questioning? Brain.
Let's go ahead and uh So, for each of those plus+ file size, I was thinking about some quantum mechanics, right? So if the file length is really big, then go ahead and increment it by like five lines and as you get closer to the end, decrease it. But um no, that's not going to work because you have to you have to get the final size by doing each line. And then we're going to just at the end of that, we're going to just write the line for file size.
write ln file size.
But uh make sure to put it inside of these because uh that would be kind of lame of me not to do that. Coolio, good job. Damn. [sighs] Import random. Not found. Randy, why are you not finding random?
Randy random, bro. Actually, we're going to import MT1 19937.
Should be the correct spelling of that.
I'm pretty sure it is a structural class of some kind. Yep.
Wowee.
Oh, it's it stopped.
Oh god.
How did it go wrong? Let's see.
write ln file well not end the file write ln file size and then file read do we really need to have a [ __ ] file read it shouldn't be counting up oh maybe we could just do well oh wait a second file size is or eof is actually size Let's see.
I should probably put a I'm gonna What I'm gonna do is I'm gonna put a right ln for the file eoof. Um, let's go ahead and finish this part first.
Write ln file foof cuz I'm guessing Oh, wait. That's a true. that thing is true or false. It's not a size. That just means you reached the end of the file. But how does it know when it's true? That's like the real question. And technically, isn't this supposed to have the closing parameters on it? I'm not really entirely sure.
One I I mean, I guess it works now. All right. I mean, well, this would be true. So, of course, it's just writing [ __ ] one.
So, while does not equal file eo.
Try that again.
Zero supporters. Zero. Wow. Okay. Maybe I'm dumb, but shouldn't it have worked with the fileef?
So, while not true, plus+ file size.
And uh does it really need me to write the [ __ ] lines out?
F write ln.
Maybe I should look at the the deeper code and be like, "Oh, yes, that's interesting." Um, what? God damn it.
Read Ellen, please.
Sudo, please read Ellen.
What?
Oh, you know what I did wrong? I forgot this thing of a jib. Um, not that thing. I'm a jib. What the [ __ ] is Why are we trying What are we trying to delimmit today? The entire string will be delimited, guys.
Last line.
Last line. Semicolon 2. I dislike when others [ __ ] my pants for me.
Sorry, I I don't think I should read it in that voice. That might be funny, but um to be honest, that did not work out the way I expected. uh cuz it I don't want it to write the lines. We don't need it to write the lines. In fact, we wanted to just add every size. We just want to keep adding size until file read ln is the last one. But what if file readn is more than just read ln?
What's going on here that it means it reaches the last line of the file?
Because when I do plus+ file size, you will see that all it does is just [ __ ] run forever.
We can't have that.
So, how does it know when it's done reading the file then? I'm guessing it does a file. Read and be like, well, is there no more bytes?
I could just use assembly to do it.
[laughter] Ah, yes. Am I going to use assembly to attempt to read a file? No, because I don't know how I would go about using assembly to [ __ ] read a file. That but that would be a funny idea. Um, we we to I could totally could put inline 86 here and probably try to figure out when I reach the end, but that's for like I learned how to make a print or writes lm.
Um so well not file read l or file that and then just keep adding plus+ file size and how does it keep track of that? What is the file strruct in in dlang even looking like? Take me to the file file things again.
It should be in standard at standard ei.
So like literally the standard input output stream the most basics.
[sighs and snorts] So read a line lines iterate through the lines of a file by using a for each brains.
Okay.
For each line you do an increment. You add a plus. Technically you could do for each line lines and then write a line or something like that.
It's a strct called lines by the way.
Oh wow. Wowee.
lines standard input string line.
So, um I think we just put a we need to probably include that in here.
A B CDE E F G H I JK element of P line.
Noise.
Noise. Good job.
Totally to totally dude lines.
So is that that's a replacement for for eof, right?
Wow.
Noise noise.
Wait.
Same as formatted read. Okay.
I am a certified genius.
No, not really. Anyway, uh yeah, replace that with for each because I said so.
for each and then line for well for each I of the [ __ ] file which is file or line.
I think you just put in F lines F. What great naming I and F now. Wow, we are really stooping to that low low low low low level of um naming [ __ ] in the most cringe way possible.
I'm guessing that's something they initialize.
Um probably probably a file. I'm pretty sure they do that. That's what they call it. Um anyway, lines of file. And uh then we'll just [snorts] for each eye of lines of file you will plus+ the file size and then we can get our number to use for magic reasons which will be described at a later date. Also since this is inside of a scope we're going to put that there and since this is all happening in steps we are going to do it correctly. So file size is going to be used and passed off eventually. So it's going to be opened well in here and it's going to close to be handed off in another one. Um, so it it literally just opens in here and and then it's How do you So, we need to create file size. So, we're going to create it here.
Then, we're going to do all of this stuff to uh maybe I don't need to put all that in there, but I I could have left it in the Who cares? Actually, uh, I do kind of care. So, I might I'm I'm going to put it back. I'm so sorry.
All of this moving things back and forth is such a waste of valuable precious time, but we need to make sure that it looks pretty to the standard and makes sense. Okay, so we have file and we're doing plus+ file size. I think it will work. Fingers crossed it works. It's not like it matters. [ __ ] Perhaps it explicitly cannot infer type cringanium for each int i ++ file size and do it fast.
So that's how you iterate your files.
[ __ ] God damn it. Anyway, I guess we have to do string. I really don't want to initialize a string, but I'm going to have to, guys. And you know why? Because I hate string. So, string is massive bytes. We're throwing massive bytes into my RAM, my valuable, precious RAM, and I do not want to throw massive bytes in there.
Supporters, too. There was two lines.
However, is that actually the number of lines?
Let's go ahead and run it again.
Three lines. Wow, I got three lines in there. Nice. Good job. Good job, me. All right. So, if it determines the amount of lines we have, then all we have to do now is go ahead and print out the lines. And this is pretty much the standard template for what we needed.
So, we create our ulong for file size and it gives us that. Then, we need to actually I should put these on the outside.
I'm so sorry all this back and forth, but I I realized why I was thinking that I need to put it on the outside and I've realized yes, I need to put it on the outside. Reason being is because if we keep it on the inside, then when I don't need this anymore, I'm I'm going to literally just use the scope card as an uninitialization for my ulong file size. I don't want you file size. I don't I don't want that. So, I'm just going to do file size.
And here we're going to get rid of file size as soon as we hit the end. Should be pretty easy. So we have ulong file size and we'll just run through that. We do a for each loop strings I lines f and then we just do plus+ file size increasing our file size. That gives us our end number, right? So if our end number is three, then we can up do up to three random lines. If we wanted to do random lines, obviously, uh, these got to contain a little bit more than just I guess we could do a strct and enumerate a strct in here, which is kind of kind of even more cringe. Um, but for now, we'll just put in these. These are just going to stay there. I guess I could enumerate a strct, but that is absolutely the most disgusting thing you can do. Having an enumeration for all of that is bad enough. Let alone having enumeration for [ __ ] struts. That would be like double.
That'd be like double memory, bro.
That'd be like disgusting cringe memory usage.
So, an enumeration of strrus is a funny idea, but let's not do that. String I lines F and then plus+ file size. And it's just going to go through and do plus file size.
And once it gets to the end, it's going to write the line for file size. But we need to figure out if it what number we can can we do random number or what uh how to do random numbers. So we'll take our file size. That's going to be our upper limit for how large our random number we can generate is going to be. And then from there I just need to read about how you generate random numbers.
We got exor shifts. We got bunch of stuff available. You got RANS linear congruence uh with wellchosen parameters.
Implements Park and Miller's minimal standard generator that uses 16807 for the multiplier.
Implements a variant that has slightly better spectral behavior by using multiplier 48271.
So here they do auto R&D. This is the I don't know these are probably like these are like strruxing classes. Mercine Twister generator is a pseudo random number generator developed by in 1997 by Macado Matsumato.
Very nice. and Taikui Nishum Mura.
Wow, funny names. Uh, funny block characters, too.
[laughter] That just means they don't have the [ __ ] characters installed for that. But I never thought I would run into [ __ ] Japanese letters and [ __ ] Um, I'm not even sure what they're called. Japanese symbols.
And then this is the type of math that hurts your brain cells. So you don't even want to look at it, but you're like x comma 1 is less than or equal to m is less than n.
Good god, this hurts my brain cells.
Brain cells.
Like what? Brains. Ow.
Cells gone.
How much do I need to compute?
Yeah, that's great, guys. Wow.
Whoa.
You in minint max default seed.
gives two starting points. The lowest to lowest allow RNG to be started at advances the generator.
Always always false.
Enum bool empty.
Empty is always false. That's [ __ ] hilarious.
Ah, yes.
Pretty much aliasing for my variables is enumemer rating.
I didn't expect we would enume so hard today, but we did.
uh merge instantiated with the parameters of the original MT9 1 937 generating uni uniformally distributed 32-bit numbers with a period of two and a lower. Okay.
The direction of shift positive means left.
This is exor shift.
Zor shift if you want to have a funny name for it.
So I don't really know how you generate a number between two values, but uh I mean I guess you could generate a number between uh anyway. So regardless of the file, we're going to count the lines so I can get a file that endline. We we know that much.
We know I'm going to count the lines and then I'm going to go ahead and say put an if statement which is going to be to handle whether or not it's um if if it's a oh and we might need to actually has it been compiled since I moved that out but um let's see actually let's see See if that works. So this is the the void trans and uh a static void trans or whatever. And uh this is the enu path and it does stuff. Uh great summary. My brains are frying. That that compiles that runs and it gives you a number of those. And so we're going to go ahead and say if if if the size of it is bro I hate if statements bro they they kill me inside.
We should probably just do a switch but I'm also checking multiple things.
Maybe we'll be setting multiple things.
If size if if file size actually is less than uh 24 then is is not less than 20 or is not less than 24. Let me be to say that if this file size is not or actually we don't need to do that.
Why would I put a not there? If it's if it's less than 24 don't don't even bother trying it's not less than is does not equal that. If it does not equal 24 then do the other stuff. That's what I want. Okay.
Brain cells are kicking in.
Brain cells are in this year. So brain cells are so in guys.
File size is not equal 24. Then do that block. Else if I mean the first thing it should check is the path.
Um so if and do we uninitialize file? Oh no, we still have file in there. Um, if file equals path path uh what is it supporters?
Let's see if I can even do that.
I don't know if that works, but I hope it does.
and then uh write ln yes just to see that it works just just to prove myself that it that it works.
Yes. Okay. Cool. So it enters here and it writes the yes line else and then it will just do everything else.
So it only needs one if statement and then the else will be actually the else if because we need to have an else if to handle.
Yeah, that would if the file size is or does not equal or is is less than uh 24 then then don't just select a random index and grab 24 lines from it. Here's the problem is that if we just grab 24 lines from the end to the beginning, that doesn't work.
But if you select a start point and increment your way up to the end point, that will work. We just need to be able to handle uh any exceptions of where the actual output would be. Um regardless, that's fine.
Cool.
I I mean, I guess I don't even really need that. I don't I don't think I need that at all. Else do that.
But if it is path.suporters, just create a random number. Now, so the random thing is going to be outside of the scope. And so the way that's going to work is we're just going to initialize random here.
rand equals or ulong print. Actually, it doesn't even need to be that. It can be a uh short and it will still work because a uh short should have enough length to not have problems of pages of a book. Anyway, you short and then we'll just do our length rant and then we'll scope guard it.
We'll we'll we'll scope guard the whole thing. Man, I'm scope guarding so hard because that allows me to put the this on the outside and then still grab the file or the actual random generation because we only need, think about it, we only need to use this for this portion.
So why would I need anywhere else? So does not make sense to have it anywhere else. This then means I can just use rand to pull out that number. And uh so we're going to just say rand equals and then a line one through three um or one through the to the length. So uh We need to choose a length random sample.
What do these run?
Oh, wow. Minced rand.
Minced rand. What?
Oh, do I love my minced random the shuffled random? I guess that is just shuffled the random access range.
Uh, I don't actually know. Random isn't really a great library. It's hard to find information in here.
Wonder if uh this has an example.
Rand uniform one to 100. Uh he's choosing a range but he's choosing between those two. Ah brain power activated. Go back to standard random. We'll just select a range.
So uniform 01 and there's uniform uniform 01 for sper variates of random variants of oh okay.
So yeah, for the viewers uh for viewer or supporter uh recommended stuff, we'll have it in here and we'll just do rand equals and we'll use uniform instead of rand the mercene twister engine.
I didn't even know you could technically do that.
I'm pretty sure uniform is also struck.
It it it should literally just be a strct called uniform.
No, actually it isn't. Um, yeah, we can just literally import it as a uniform between A and B. Perfect.
Between zero and length. So, this is the easiest one we can do.
So, for DMD gesture.t, get that queued up because we're going to have to compile it against you. Rand equals uniform uh and do one comma file size and then boom. Now we go back to our for each loop type of thing.
So if the size is one then obviously it's cool. Um we probably will put a switch here to or maybe for now that's going to be all it's going to do. It's going to just be like if file paths and borders else write ln todo and then continue on downwards and now we have our usort random initialize because of this. So this um scope initialize rim scope initialize ramp.
Cool.
So all I have to do now is use rand to find my file.
But also we probably want file size.
Technically ulong for file size is wrong too. That should be a U short because there's no reason it should be that should not be anything but a short.
So um that's all I need for that. Now, I am just going to need to do one last thing before I can say that we finished today's episode.
That's going to be literally just seeing what it does with with the file and if it works, which I forgot how to do that. God damn it. Um, but we're going to do a for each and we're going to do string i and semicolon lines of f and do that. And then we're going to just write a ln file read ln. However, that's not correct because it needs to go inside of another function.
If statement correct amongus if statement if we are at the file read which is rand actually and then uh comma string line. Oh, hey, we don't even need to do file read ln. We can just do ln and uh this.
God damn it. Put in put in line.
All right, there we go. For each line and then we'll use I I to determine if I equals equals rand write ln line.
So that's the um other portion of that.
I'm pretty sure we're going to end up putting this in there because there's no reason to pass it out of there. We might even reduce the amount of scope guards even.
And uh actually I'm going to do that now to make this code actually better since uh I don't really want to have all of that going on. So reduce that to dust.
And then we'll figure out the rest of this from here. Should just be removing one of those. Actually replace that one.
That one I'm pretty sure goes in there.
where I'm I'm removing every line. What am I What am I doing?
Amogous.
That's what I'm doing.
All right, there we go.
Me, I am great at keyboard skills.
There we go. That should make everything a lot better. I'm initializing my ushort file size and my rand and I am now ready to go. DMD Jester.d cannot implicitly convert uniform uh file size to tag int and uh short [ __ ] Okay. for each int.
Please let me initialize a [ __ ] integer in that. Otherwise, it's cringe.
[snorts] Actually, why would I do why did I do lines? We just got to do rand. Uh, actually, no, I know why I do lines. Cuz because if I do lines, right, here's the advantage. All I have to do is write line in here in the code. Although if I did rand it'd be way simpler. If this doesn't work, we'll try rand. All all I really need to do is put rand and if it reaches that technically this should be a long.
So um yeah unidentified for r. What do you mean rand is unidentified? Define uniform one. All right, that one's easy to solve as well. Probably just need to cast it to a [ __ ] uh short uh short one. I hope that doesn't need me to cast because otherwise I'm going to be annoyed.
Amus Pogus. Oh god.
Random. So rant. Where's Rand?
Why is random? Oh, you know why?
Because this needs to go here.
Boom.
Got him. Nice.
Tab. Tab. Tab.
Tab.
Tab.
Backspace.
Enter.
Enter. Tab.
Noise.
Boom. Looks good. should only be uh one of these. [ __ ] And now syntaxing kills me.
Found weren't expecting a semicolon after expression.
Yeah. So it needs to be cast unless I I do use short one.
I hope that's a way of defining the value as as that.
Sea style cast.
Oh man. Damn, bro. I wish I could use a sea style cast, bro.
All right, cool. Slash gesture.
How many times did I attempt to compile?
Three. But it won't write the third line.
What's What's the rand?
And uh if it's correct, write rand. I want to know what rand becomes.
Randy random, bro.
Okay. Two, two, one, two, one, two.
Bobby. Amongus. Amongus Bobby. Uh, cool.
So, we have it. It only wants to do two and one. I don't see any threes in there. Anybody see any threes in that?
I don't I don't see any threes in there.
Um, so it it doesn't want threes, but it wants to do two and one.
Um, so I mean, I guess why isn't it writing the line called line from lines of f? I mean, I guess really what I should be doing is the other technique that we prescribed in the the great great idea I had. Um, so this technique, we're going to take this and we're just going to go all the way to rand, which completely negates the need for one of these.
Essentially, all I have to do is that.
And then also, we might want to add a boolean check. Uh, that will be a tomorrow problem though or a later today's problem if I have time today. I got to figure out what I'm doing besides this today or not really besides this. But why does this look weird? That that should be there. That should be there.
Why is this one all the way down here when it needs to be up there? And where's that one's? It's there.
So, uh, where's the that one?
Um, see, that's kind of an issue cuz that one has the end bracket. This one got no end bracket. What What the [ __ ] going on here? How How do we How do we screw up? You give it an end bracket.
See the end bracket here.
I don't know where we messed that up at, but okay. I'm sure somebody knows. Uh, and anyway, rand of type uh short. So what you would do is instead you'd go zero to dot rand. Um that means basically it will on the last one if I equals rand do that and so that means that's our end line basically.
However file readn needs to also be synchronized with that.
And so the entire time, let's run file read ln and hope and pray that this is the correct way to do it because technically we don't have eof to help us. Uh we'll figure that out at a later. Well, eof doesn't work anyway.
EOF is like the [ __ ] slog.
So I or I choose that. Let's do this.
Uh, and I think it's all good.
I think that's all I need to do. I think I'm missing something though. So, I equals equals rand. So, it's doing it a check there.
So, when I equals, it's not really an if, it's when.
Anyway, when I equals rand, that's going to happen.
So, we know it's going to happen at some point. it will hit that and then write that line otherwise just do nothing with that and then uh I guess cast void technically you can do that aggregate rand of type you short oh right that's the other thing I had to fix I had to do zero to dot dot rand because it needs a range so it needs that zero to dot dot is a range basically um or a slice of type string. What file? Oh, you know what it is? It needs fred readell. I'm getting confused because usually I call my files dot I call them an file, not an F dot readell.
That should compile. Dot slash jester index zero is out of Oh, right.
um supporters and it doesn't really do it. I'm going to have to fix this later today. I'm going to end today's episode here because I'm out of time. I got to do stuff so I can get ready for today.
Anyway, I'd like to thank you all for watching. I'll see you guys next time.
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23