Programmer in 1969: I need only 72KB to send astronauts to the Moon Programmers in 2024: I need only 30GB to check if the number is even
@RedVio972 Жыл бұрын
Programmers in 1960s: We're NAND gating out of Earth with this one
@spicybaguette7706 Жыл бұрын
@@RedVio972The AGC is legitimately mind-blowing. It even had a software VM for a machine language to do the linear algebra required for heading calculations (kind of like the JVM but in the sixties, Apollo engineers were truly wild)
@user72974 Жыл бұрын
Now, now, no need to exaggerate. You're an order magnitude off. The number checking program was 330 GB, not 30 GB.
@Wyld1one Жыл бұрын
Charles Moore (creator of the FORTH programming language) all I need is 1K for the operating system. Maybe 12-14 bytes for the program
@rahulshah1408 Жыл бұрын
The 72kb moved the slide rule back and forth.
@SandTurtle Жыл бұрын
i love the pure irony of putting "if i % 2 = 0" to generate this
@flameofthephoenix8395 Жыл бұрын
Yes, he used a lesser thing to make a greater one.
@qsquared883311 ай бұрын
@@flameofthephoenix8395that depends on your definition of lesser and greater
@whohan77911 ай бұрын
The even worse irony is that you don't even need modulo for this. Assuming your base dimension is even, you can do the check for the last digit only. Here is my entire codeframe (&yes, I'm aware this video is intentional gore and can be 'solved' by checking for the last bit only): #include //the program wants to talk #include //technically superfluous if you check for termination (see below) int main(int argc, char* argv[]){ //the main function needs arguments (and their count) for (short i=1; i
@fal477011 ай бұрын
@@whohan779 You're right about only needing the final bit but all you need to do is a bitwise AND with 0x1 unless there's something I'm missing with this approach: #include int main(int argc, char* argv[]) { if (argc < 2) { fprintf(stderr, "No input number given!"); return -1; //can't be bothered to check all invalid inputs rn lol } int number = atoi(argv[1]); if (number & 0x1) { printf("%d is odd.", number); } else { printf"%d is even.", number); } return 0; }
@qsquared883311 ай бұрын
@@whohan779 my dude, you would never do this, it would be easiest to return the value of the last bit in the integer as a bool It's value of true means odd, and false means even.
@nikilk Жыл бұрын
Imagine the tech lead explaining to the CFO, of why they need quarter a million dollars of cloud funding because of this new crazy even/odd algorithm the crack dev team came up with.
@MrLordLowbob Жыл бұрын
move it to the edge!
@photoniccannon2117 Жыл бұрын
Show this to the KZbinr “tech lead” (who admitted to lying about being a former Google tech lead) and watch him try to figure it out. 😂
@rahulshah1408 Жыл бұрын
I’ve worked at a shop that refused to add indexes to the oracle exadata database. They were forcing the issue to purchase in-memory licensing. A million dollar solution before trying the free one.
@photoniccannon211711 ай бұрын
@@rahulshah1408 That's... amazing. Was it the shop's idea to do this on purpose? Knowing Oracle, they were probably quite pleased.
@davidmartin808911 ай бұрын
more like dev team on crack haha
@pavolkomlos3343 Жыл бұрын
Might be a good idea to optimize this by doing a binary search to find the correct if statement.
@volodyanarchist Жыл бұрын
But... the binary search needs the division operation, and i think we can implement it thusly: uint32_t divide(uint32_t a, uint32_t b, uint32_t potentialResult=0) { if(potentialResult*b >= a) return potentialResult; return divide(a, b, potentialResult+1); }
@Avighna Жыл бұрын
Smart!
@igotnoname4557 Жыл бұрын
Definitely! Then you can offload the work to a cluster to take care of the heavy lifting.
@pacomatic9833 Жыл бұрын
...or don't use if statements. Ah wait, this is crackhouse, how about we use IF statements to find which statement?
@Guhlius Жыл бұрын
Second function starting at the highest number going down, add wrapper with bool to indicate if number is propably big, half execution time
@xBiggs Жыл бұрын
Can't wait for Yandere dev to install this package
@t3dotgg Жыл бұрын
I hate that I get this reference
@captainplasma1012 Жыл бұрын
didn't he literally do the exact same thing? with a clock or smth
@Nessie14 Жыл бұрын
Don't think I get it~ 😅
@FireSiku Жыл бұрын
@@Nessie14 YanDev is infamous for having written some of the worst code in teh gaming industry. For example, Instead of having a logical event handler for the many things that could happen in their game, it's just a GIANT IF/ELSE block
@potatoheadpokemario1931 Жыл бұрын
@@FireSikuand not only that, he'll refuse any help and insists he'll clean it up when he's done, but the longer it goes like that the harder it'll be to clean up, eventually he might as well make a new game
@MelkeyDev Жыл бұрын
Wait.. so im NOT supposed to have 4 billion if statements..?
@t3dotgg Жыл бұрын
No more than 2.5 billion in go :(
@Household-u4b Жыл бұрын
It's actually using a switch statement would improve performance.
@rohit-gupta Жыл бұрын
a hashmap of numberboolean would have been faster but not sure about memory
@maxz999 Жыл бұрын
@@rohit-guptaarray of length 4 billion?
@beck4715 Жыл бұрын
@@t3dotgg3/4 of that would be error handling so closer to 625 million
@Eyeclops_ Жыл бұрын
I'm a graduate student, and this reminds me of an assignment I had gotten for a class I TA'd a few years back. The assignment was an assembler for a slimmed down version of MIPS that would convert instructions from their assembly representation to a binary representation. Since the instructions were small enough and it was simply a conversion, it took most students around 130 - 200 lines of code to get it up and running. It was basically done in two passes. Converting simple instructions in one of the passes, and the other to resolve labels. One student submitted an 15000 line C program that was a single while loop in main which attempted to exhaustively read in every possible input into the program and convert it into binary. It had no comments, all variables were in a single array, and there were no functions aside from main. Not only did it not work with labels (since offsets for labels you haven't seen can't be calculated without a second pass) and it did not output anything remotely correct, it somehow managed to delete all of my test input files in the process. That student got no points anywhere, aside from the "effort" category, because while they sure didn't work smart, they definitely worked hard.
@minerscale Жыл бұрын
Did you run the program and then read it or did you read the code and then decided it would be a good idea to run it? :P I'd hide malware on line 8,500.
@Bogosbinted12 Жыл бұрын
@@minerscale8543
@Wyld1one Жыл бұрын
All I had one of those group projects once we were supposed to each do a specific chunk of the code merge them together and then compile the result. Had one of the people who didn't understand recursion totally rewrite my code which wasn't his job. The project was for a simple calculator. Where you would put it in an equation and it would spit out the answer. We're just talking plus minus times divides no higher functions at all. Well my simple recursive solution was about a page of code. His rewrite took over 20 ft of paper to print out. I refused to take that so I submitted my solution to the teacher as well saying that wasn't my code. I passed with an A
@minerscale Жыл бұрын
@@Wyld1one was the recursion for processing brackets? That's like the poster child for recursion is it not!
@heikkiaho6605 Жыл бұрын
sounds like me XD
@joppekoers3992 Жыл бұрын
Of course we need 64 bit numbers. For storing the amount of build warings I get for example
@JetJockey8711 ай бұрын
4,200,000,000 warnings but no errors, if it's good enough for the compiler it's good enough for me. Ship it to prod
@whohan77911 ай бұрын
@@JetJockey87 For real though: while just building a program that checks the last digit for oddity as a joke I know probably now most of the warnings and errors and can vouch that most of them are valid and deserved.
@theaninova Жыл бұрын
Have a file with 2^32 bytes alternating between 0-1 Compress the file with gzip to practically zero size Have the program load and unpack the file Use the input as a memory address
@photoniccannon2117 Жыл бұрын
I’m gonna try this just for the heck of it. 😂
@nextgenstudios335 Жыл бұрын
@@photoniccannon2117 post the results 👀I HAVE to know now
@photoniccannon2117 Жыл бұрын
@@nextgenstudios335 See I was thinking about how to do this. Here is problem number 1: I literally don’t have a drive large enough to store the file with the code (I have a hard drive, but that’s way too slow). So I need to get a gigantic SSD first (or find a way to clear space on my Mac). I think the latter is manageable, so we will see.
@flameofthephoenix8395 Жыл бұрын
Should be able to split it into more than one file to avoid having to decompress too much at once.
@decycle291211 ай бұрын
the file size is only a gb without compression!
@otter502 Жыл бұрын
8:58 the comedy of using the modulus operator to code a program to replace the modulus operator
@jsonkody Жыл бұрын
world would be much better place if every math function would be implemented in such elegant way
@simono.899 Жыл бұрын
A function to add two values with convoluted switch statements to account for all combinations
@comradepeter87 Жыл бұрын
hell yeah. Imagine how faster computers will be when we can throw away all the ALUs and just lookup the answer for any calculation in a lookup table!
@Blast-Forward Жыл бұрын
Clear and concise.
@AnsisPlepis Жыл бұрын
If only pi was a function that computed it with the odd reciprocal formula at runtime
@hungrymusicwolf Жыл бұрын
@@simono.899Now that would be a sight to see.
@astral6749 Жыл бұрын
When he reached the compiler part, I thought he's just gonna make python output an assembly file then use an assembler to turn it into a binary. I wasn't expecting him to write the binary directly. lol
@fltfathin Жыл бұрын
First time i understand how things actually work it is kinda dumb that toolchains got so scary for me
@volodyanarchist Жыл бұрын
I was expecting him to remove new line characters from the file, this way it was just one line...
@finminder2928 Жыл бұрын
Would removing beeline characters from the file actually work?
@volodyanarchist Жыл бұрын
@@finminder2928 C separates commands with ; it treats new-line as any other space. Exception is precompile directives, so a couple of includes would have to be on the line of their own.
@moistness482 Жыл бұрын
Time to call this as a new process each time I check if a number is even
@Exilum Жыл бұрын
The even funnier thing is you can probably optimize it by hardcoding using binary search. The file would be even bigger but I wouldn't be surprised if it was faster, considering the main bottleneck at that point is the reading speed.
@OMGclueless Жыл бұрын
Binary search is unnecessary. Can just index directly into the right memory location.
@Exilum Жыл бұрын
@@OMGclueless Isn't not counting the time spent building an index cheating? And if you do it from a file, then there's still the same issue of file reading speed. If it is counted and still is faster, it's pretty much functionally equivalent to avoiding the self-imposed problem rather than trying to solve it as you go from 4 billion conditions with jumps to read to... 4 billion references in an index. If you use indexing to 'turn' it into a single condition leading to the right condition, then the 4 billion conditions aren't used, so it's cheating as well. Binary search has the advantage of hypothetically being able to use all conditions in two calls. Using all conditions in 4 billion calls seems a bit *too* spread out to not be cheating your way out.
@OMGclueless Жыл бұрын
@@Exilum Mapping a file into memory is a constant-time operation: just setting up a page mapping in the OS. Jumping into the middle of the file and reading the answer there is also a constant time operation, it takes a single page fault to go read the file from disk and map the page you accessed into memory (this step technically takes log time, most likely, since the file's blocks are probably stored in a structure like a btree). Creating the file takes a long time, of course, but you only do it once and then can answer as many queries as you like with no extra work. Re: binary search vs indexing. I think if one is allowed they both are allowed. log(n) operations to find the right answer and 1 operation to find the right answer are both skipping billions of comparisons so both are cheating by just about as much.
@Exilum Жыл бұрын
@@OMGclueless Hmm, I see your point. I still think think they're far from cheating equally.
@OMGclueless Жыл бұрын
@@Exilum Well, look at it this way, binary search skips ~2 billion - 32 comparisons, while indexing skips ~2 billion - 1 comparisons, so the amount of cheating is pretty close :D
@TomNook. Жыл бұрын
"a very thick c file" Thicccc. Missed opportunity
@Remiwi-bp6nw Жыл бұрын
That's so interesting that you have that trauma with Assembly, because when I took that equivalent class the compiler/runtime was my favorite thing! I even made a slightly different one again the summer after that class ended lol
@smallfox8623 Жыл бұрын
Same the compiler class I took was my favorite and I learned so much about programming in that one class. The assembly class which was separate was my 2nd favorite 😊
@BrandonVout Жыл бұрын
I have a lot of nostalgia for PIC assembly. I wouldn't do it again but it was a lot of fun. VHDL too.
@NithinJuneАй бұрын
2:16 I love that the copyright statement says “persecuted to the fullest extent of the law” instead of “prosecuted” 😂😂
@cubed.public10 ай бұрын
Idk what people are complaining about, this is an O(1) solution, it’s perfect!
@MaxSharpy Жыл бұрын
This is pure gold. Ty you made my day
@keineahnung2339 Жыл бұрын
I have an even bigger idea: return 1 or 0 instead of even or odd. Then we have implemented the mod operator for 2 (number mod 2) so we execute that program with all the 2^32-2 numbers and we have implemented the whole mod operator. I have heard that AWS S3 has enough storage for a program this huge
@williamdrum9899 Жыл бұрын
That's ridiculous. What's next? Using bit rotates and carry flags? Poppycock!
@Sandromatic9 ай бұрын
That's actually what the assembly version does by the looks of things, so there you go. :P
@omkelderman Жыл бұрын
I remember reading that blogpost a while back, absolutely amazing work. One thing I kinda hoped for what didnt happen was instead of writing that asm to bin madness and then loading it as a memory mapped file and executing a function pointer, I hoped he would output it as an object file that he then could reference in his main.c file and link together with an actual linker. But this was also pretty fun xd
@TurtleKwitty Жыл бұрын
the linker would run into the 4gb limit though no?
@omkelderman Жыл бұрын
@@TurtleKwitty uuuh, good point lol, honestly no idea
@photoniccannon2117 Жыл бұрын
It’d be torture if this was written in such a way as to purposefully hint at the branch predictors to mispredict it at every branch. It would take hours instead of seconds and force the pipeline to be flushed on every single if statement!
@Slashx92 Жыл бұрын
I love the "fully functioning and PERFORMANT program" in the conclussion, just after mentioning that the program can take up to 10 seconds to give a response LMAO
@HippieInHeart11 ай бұрын
It takes only 10 seconds at most, I'd say that is extremely performant and efficient. He's done a very good job. XD
@EddyVinck Жыл бұрын
Looks like an O(1) algorithm Prime would be proud
@Anonymous-u8r8j10 ай бұрын
Wouldn’t it be O(N)?
@polygontower9 ай бұрын
@@Anonymous-u8r8j You seem to be conflating 'if' with 'else if'. If statements don't terminate once one outputs True, logically. That's what else ifs do, hence the name, 'else, if......., then .........'
@KontarAlt11 ай бұрын
This is the most fun ive had watching a video in *years*
@zaffyr Жыл бұрын
I have a great suggestion to make the code more efficient: if the number ends in 0 2 4 6 or 8, you can have it skip every second number. if the number ends in 1 3 5 7 or 9, do the same. Truly remarkable how much mathematics is advancing thanks to computers.
@gomi-hako Жыл бұрын
Actually I've needed a bigger number than 64 bits for my number conversion program from japanese to our numeral system, where the biggest power of then is 一千無量大数 = 1E71. Even 128 bit didn't cut it.
@Xudmud Жыл бұрын
Why stop there? At that point couldn't you easily do 九万九千九百九十九無量大数, just to add more bits to account for? (now I really want to try and see how long that number would be written out)
@gomi-hako Жыл бұрын
@@Xudmud In the scale used currently 中数(万進) that's not possible. For every big power you can only go up to 千(10^3) since these powers increment like this: 4, 8, 12 ... 68. Maybe with the 中数(万万進) scale, but with the notation of this scale I am not really familiar. 三千三百三十三無量大数三千三百三十三不可思議三千三百三十三那由他三千三百三十三阿僧祇三千三百三十三恒河沙三千三百三十三極三千三百三十三載三千三百三十三正三千三百三十三澗三千三百三十三溝三千三百三十三穰三千三百三十三𥝱三千三百三十三垓三千三百三十三京三千三百三十三兆三千三百三十三億三千三百三十三万三千三百三十三
@Xudmud Жыл бұрын
@@gomi-hako Whoops, I knew it was 10^3 per but miscounted where that ends up at. (been long enough since I took Japanese and I'm too used to working with 10^2 per big power). So I guess 九千九百九十九無量大数... would be the highest? (it'd add another two or three bits to the numeric value)
@angelodc165211 ай бұрын
What about Googolplex?
@the-answer-is-4211 ай бұрын
That final solution is so beautiful. Who needs type safty when we can throw a bunch of bytes from disc into a function?
@lupirite637311 ай бұрын
I was visiting my friends high school programming class when I saw the absolute horror of the checkers game one of his classmates made. It was a simple javascript checkers game, yet he programmed it by checking every single possible state of the board and then allowing the player to take each corrisponding move based on it. The final script ended up being over 4000 lines of code.
@prozacgod Жыл бұрын
I once found a PHP function that was a cascading layer of if / return statements for formatting the numbers 1-31... every single number. function formatNumber($n) { if ($n == 1) return '1st'; if ($n == 2) return '2nd'; if ($n == 3) return '3rd'; if ($n == 4) return '4th'; if ($n == 5) return '5th'; ... } top notch, beautiful, works to spec...
@volodyanarchist Жыл бұрын
In all honesty it is possible that it started with strings like "first", "second", etc, and only then got changed... which would make sense. And let's be honest, there is a slight difference between 31 and 2**32-1.
@GRBtutorials Жыл бұрын
@@volodyanarchistI’d use an array or at least a switch statement, though…
@volodyanarchist Жыл бұрын
@@GRBtutorials I agree with switch. But again can think of a caveat. Assume you also have language like russian. First would be первый if it's masculine, первая feminine, первое neuter, первые plural... And also different cases. And you only had 1, 2, and 3. But i would definitely advise anybody to do a multidimensional array. Anyhow, just to be clear, i agree with you, but am trying to find a reason why somebody would do something like that where it made sense at least initially.
@julianemery718 Жыл бұрын
Wow, what a glorious trainwreck of an article.
@_scourvinate Жыл бұрын
Soo... funny story, I actually did a similar thing because of Tiktok. I used the same meta programing idea except I used python to write python. The "advantage" my method had was because python is just "so quirky", I was able to write the python code, save it to a file and then import it and use the function in the same program.
@Solarbonite11 ай бұрын
That's code generation with self-modifying code. Yeah it's useful sometimes. Beats writing it yourself!
@umbaupause10 ай бұрын
"What's wrong with getting paid by line?"
@neoney Жыл бұрын
O(1) memory, O(n) time!
@the_disco_option Жыл бұрын
that was one wild descent into into madness. loved it!
@dylanvidal2221 Жыл бұрын
sat next to 3 maniacs who wrote tic-tac-toe with only if statements in C for a hackathon…
@steves9250 Жыл бұрын
Next option would be to code each if statement into its own executable and call it dynamically😂
@NeroDefogger11 ай бұрын
reading that gave me nausea... I love it...
@witchofengineering Жыл бұрын
"There's no need for more than 32 bits, give me an example of a 64-bit value" Astronomers: *burst in laughter*
@FM-kl7oc Жыл бұрын
Can be solved heuristically: return ( input != 0 ) Because we know 0 is even and we return false otherwise, we are above 50% accuracy in our heuristic when checked against the set of all digits.
@Mikewee77711 ай бұрын
smart
@bren.r Жыл бұрын
Thanks for including the source! You have no idea how often creators never leave sources.
@radspiderjackson Жыл бұрын
i never once tried reading assembly, and i only just now feel like i got a decent grasp on all of the concepts covered in that CS50 course, but after learning the absolute bare minimum about logic gates and seeing this 'isEven' assembly code I really feel like starting with assembly before c++ might be the best route to thoroughly learn computer science concepts. It could just be because a few key ideas finally stuck with me, but it really feels like learning assembly logic gates to some degree woulda really gave me a better idea of what was really going on behind the scenes.
@BrocoliMan2002 Жыл бұрын
I spent a lot of time looking at assembly before learning higher level languages like java and it worked out fine for me so I say go for it.
@Aim54Delta Жыл бұрын
I come from digital electronics - so, logic gates, op amps (for some analog applications) and DSP functions. I built a digital clock before touching an 8080 microprocessor and writing programs to it using its assembly and tracking memory use by pen and paper.... which... you can write more to a sheet of paper than it had memory to work with in many cases. This was all back when Pokemon was 8 bit and taking the world by storm. I highly recommend people learn assembly and make use of it on small scale computers before studying more modern architectures and using higher level languages. It's also recommended to study operating systems, file/drive structures, etc. Speaking of Pokemon, the original red/blue games are highly recommended case studies in programming. On the surface, it all generally works. There are some accidental bugs with how things work vs their intent - but the big ones play out when dealing with the fact that there js a shared memory space between many different parts of the program. The missingno glitch is abaolutely fascinating from a programming perspective and is an example of why coding conventions exist or, in some cases, compilers/languages handle it in the background (and why you might want to, in some cases, not initialize a variable if you know where it's pointed in memory - granted, it's bad practice, but that's what comments are for - when you're performing voodoo rituals). So, in a sense: Logic gates and boolean algebra Possibly op amps for those who want to delve into ancient dark rituals to be able to contract the demons of solomon with mixed signal processing. Then 8080/z80 etc assembly and program mapping. Then C compilers. Then Pokemon code and bug analysis (end by catching mew without tools and/or hacking the game to put mew under the damned truck). Then disc structures Then Operating Systems (start with a command line operating system - dos or something). Then 32 bit computing, risc vs cisc (everything is actually risc - cisc just has schedulers trying to keep the ALUs busy) - which leads us into floats vs ints and some other paradigms. Which is still C, but now we add C++ because larger programs tend to use that next higher level. After that, a programmer can go almost anywhere and do anything at least in terms of core computing. Networking should be a separate step, but require completion of what I consider to be the basic computer course above. Networking is just a lot more involved and not really necessary for most programming. To do it properly, it's both the underlying hardware which facilitates network topologies/protocols, but also the implementation of operating system access controls and accounts. I have a friend who works the helpdesk, mostly for internal issues for the company (they have field agents and customers who also get routed into their ticket system) the network admin got herself locked out of her computer in a situation she was convinced was unrecoverable. People mentioned he'd probably be able to fix it, and of course she was skeptical some help desk goon from a community college could undo a problem her networking degree couldn't solve. He just used basic system tools and 5 minutes to have her password wiped and her account ready to be claimed. The look on her face was that of abject horror. People are not being taught the basics and don't have the tools to solve their problems - which gives them a warped and distorted view of the present standards/claims of products.
@radspiderjackson Жыл бұрын
that last statement in this comment is pretty much exactly what i have feared for the past decade or so. Like sure i could mimic whats done in a high level java script or python course and be able to output the desired results, but i hated not knowing how it was even possible to get to that point. I also know that harvards cs50 is an excellent resource to get started but even that doesnt have this level of what i guess could be called first principle knowledge. Im sure what you outlined isnt something that could be thoroughly grasped from 0 over the course of just a year or so but it has that "Nand to tetris" route where i feel the most vital information will be learned. @@Aim54Delta
@SoreBrain Жыл бұрын
What is the yarn command to install this?
@n0mad385 Жыл бұрын
You should write some code that bruteforces that command
@heinrichagrippa1259 Жыл бұрын
By the title I thought this is going to be about AI/ML.
@ea_naseer Жыл бұрын
Akshually....
@AnAnonymousAuditor Жыл бұрын
"fun" is definitely one of the descriptors of all time for this.
@CodecrafterArtemis Жыл бұрын
‼FUN‼
@exoZelia11 ай бұрын
oh we're still doing this joke format. okay
@lukasalt629411 ай бұрын
I'd suggest to check the input modulo 2 at the beginning. This way, we can skip every 2nd if statement and have a impressive 2x Speedup
@MrWaterraft11 ай бұрын
I like how much you added to the other person’s well written blog post
@LeTtRrZ11 ай бұрын
Cant wait for version 2.0 that performs a sum by adding 1 several times.
@TimKessler-q3s11 ай бұрын
Interesting video and article
@TheHappyKamper10 ай бұрын
function isEven(number) { return number % 2 === 0; } function isOdd(number) { return !isEven(number); }
@gardian06_8511 ай бұрын
64-bit numbers I use quite often: 0, 1 what?
@Trizzi2931 Жыл бұрын
I was continuously laughing through the video thank you for this
@serg_sel752611 ай бұрын
Aah, this is why all programs are increasing in space over time... They need to increase amount of if statements)
@Amonimus10 ай бұрын
To be honest, it's good that someone has benchmarked this. When you're engineering military or space machinery, anything may happen and every bit matters, so even the silliest things can be interesting.
@dreamecho100 Жыл бұрын
Package and ship it to npm
@codetoil Жыл бұрын
npm is a javascript/typescript package manager. The code was written in c(++) and assembly.
@Slashx92 Жыл бұрын
@@codetoil package it as a node script that executes the original program
@spicybaguette7706 Жыл бұрын
@@codetoilwe just need to modify it to produce a 30gb wasm file instead
@minerscale Жыл бұрын
@@codetoil just write an x86 interpreter in javascript and ship the bin as a blob.
@volodyanarchist Жыл бұрын
@@codetoilI volunteer you to write a wrapper for it.
@binaryguru Жыл бұрын
I work with multi-terabyte files regularly in windows and I never have a problem with them.
@cocoelacanth11 ай бұрын
2:16 i love that it says "unauthorized distribution will be *persecuted* to the fullest extent of the law" basically saying "copy my code and you won't get in trouble but everyone will hate you"
@SowbugMori Жыл бұрын
This entire article is a shitshow and I love it for that
@immortaldev1489 Жыл бұрын
the forbidden O(N) time complexity is even method
@brycemw Жыл бұрын
I use x86_64 assembly quite often yet I am still finding out surprises. SHL and SHR affect flags differently depending on shift count. If BT or BTS are given a memory argument, rather than truncating the bit index, it adds the top bits to the memory address in a way that’s slower than you doing it yourself. As some examples of recent things
@KnightSwordAG11 ай бұрын
I did the same project in my architecture class in college, and I didn't think it was that bad. But my professor also said my implementation was the most correct.
@eldonad11 ай бұрын
The if lines spacing on the miniature matches exactly the scroll increment on my browser. When this popped up in my feed, it was a trippy experience ! 😵💫
@TourFaint10 ай бұрын
the 330 gb c file made me remember that one time VLC started going crazy and generating some error code as fast as it could, resulting in a 400+gb log file. good times
@wacpas Жыл бұрын
We've implemented the MIPS architecture on a Xilinx FPGA in university and then loaded some assembly onto it. One of the best classes tbh!
@TurtleKwitty Жыл бұрын
I love that the blog essentially describes how JIT works "make machine code, put in read and exec memory and just call it" but for such a ridiculous usecase is absolutely magnificent
@fgregerfeaxcwfeffece Жыл бұрын
That's why I am excited. Stuff like this will make me look better even more consistently.
@gubiithefish Жыл бұрын
This is amazing, thank you for sharing🎉😂
@bebobauomy126511 ай бұрын
I tried inlining 1 million function call instead of using the for loop, and it improved the performance in Go by a lot.
@judebreheny392511 ай бұрын
I only understood like half of this but it was still very entertaining. One huge advantage of this code is it's very readable - you probably wouldn't need to comment it. I think I'll start trying this strategy in my future projects.
@maxz999 Жыл бұрын
Dang, you got this video out quick
@Noritoshi-r8m Жыл бұрын
Sanest Holy C developer
@smellthel Жыл бұрын
Imagine if a huge technological leap happens and this somehow becomes more efficient than the modulo operator
@volodyanarchist Жыл бұрын
Quantum computers, that can somehow do all of those ifs at the same time.
@sebay465411 ай бұрын
Well the first way of checking if a number is odd or even id think of is through evaluating the validity of an Equation (N(some Number) ÷ 2 (smallest even number) = Int(an integer which cannot possess any odd Numbers when divided By 2 as as any odd number when divided will always either produce a reminder which we could evaluate or create Decimal Places so instead I'm checking if the Equation itself is Valid rather then directly working with the result (Data validation so if it divides an odd Number the Equation becomes invalid as the result Of the Equation isn't an Integer
@Tomas9970_111 ай бұрын
Been a while since I last coded anything but if you just wanted to know if a number is odd or even, you could just look at the last bit (of a 32 bit int so no need to guess the length) and spit out an answer, which will be way faster than the modulo operator. last bit 0 = even last bit 1 = odd This obviously wouldn't work for any other multiple like %3 or %4 but neither would the if-else monstrosity.
@sxlg_32 Жыл бұрын
the saddest thing is you could take that original code and make one change and it would work for any number.
@cagdasucar3932 Жыл бұрын
The problem is ridiculous, but these are valuable techniques that can be useful in real life. I don't know how OpenAI handles their models, but I imagine the C++ assembly loader technique may come in handy for large programs like LLMs.
@matt.loupe. Жыл бұрын
Seems like it would end up just being a hashtable and a single comparison with O(1) complexity
@Mokrator Жыл бұрын
i wonder if loading this code does need more time for "loading the code" than running it. As it does contain 4 billion 'odd' or 'even' strings... i love the part where code prints the "bad" code... thats really genious.
@majidmehmood378011 ай бұрын
i looked this guy up and he is an apple software engineer
@MrFlarespeed Жыл бұрын
Fyi, the magic of the 800MB/s is that its probably compressed vram, so the entirety of the program is likely smaller in memory than it is as a file.
@thezoque_ Жыл бұрын
i think the next step now is to put all the results from this program into a hashtable and then we can all easily find out what numbers are even or odd! this could be revolutionary
@benschubert983011 ай бұрын
I’m so glad the modulo operator isn’t real, I love if statements
@TheWorldWideWebTheSqueakuel211 ай бұрын
I can't believe I looked at this and didn't immediately go "this is stupid, just use modulo", but instead going "this is stupid. Instead of using an if statement for every value, simply use an array that store the evenness of every integer ". Mmm, yummy RAM.
@jacoblockwood4034 Жыл бұрын
Yeah I saw this article last week, it's incredible
@user-le8ul4nr5t Жыл бұрын
chad 4 billion if statements vs virgin !(number&1)
@Mikewee77711 ай бұрын
Proof that string length does not matter as much as high impact brevity .
@jorgelenny4711 ай бұрын
Genuinely thought that when he pulled assembly, he was going to check if the number was 0 or 1, and if it wasn't, subtract 2 and try again. Not 4 billion if statements, but that would've been amazing for performance experiments
@vorrnth873411 ай бұрын
The next step after loop unrolling -> function unrolling.
@tutacat11 ай бұрын
We need switch case, or use a hash dict, that is way more performant
@Vladimir-V-Kondratyev Жыл бұрын
This is funny as hell!
@Netro1992 Жыл бұрын
This is so horribly beautiful.
@Baburun-Sama Жыл бұрын
Now let's Mass-Compress it into 1 If Statement and 1 Else Statement... ...or just Split it in Half so that it's 2 Billion If Statements and 2 Billion Else Statements.
@plague180 Жыл бұрын
This reminded me of the nightmares I had to deal with a 500 gig single file years ago
@Milanka98911 ай бұрын
What about: if(number == 0) { print "even"; } else if(number == 2) { print "even"; } else if(number == 4) { print "even"; } ...... else { print "odd"; } ? This way, we can reduce the size ~the half.
@benjaminweeg968411 ай бұрын
Sure, I'll name a 64 bit value. I'll name it Bob. For no reason in particular. It's just the first name that came to mind.
@something319411 ай бұрын
I remember that one of the nvidia implementation for sqrt and a few other basic functions uses a switch case hardcoded for the most common values
@SIRBOB10211 ай бұрын
i need to figure out how to write a rust macro so this can be created as it compiles
@Dom-zy1qy Жыл бұрын
Idk why i just always assumed you couldnt pipe outputs from the windows terminal. This article has taught me something very valuable
@majidmehmood378011 ай бұрын
assembly code and trauma is permanent
@chadthunder95 Жыл бұрын
your thumbnails get crazier and crazier
@attilatorok5767 Жыл бұрын
I wonder how fast this would be with a switch statement. Probably much faster as it is basically a lookup table, but you still need to load a very large file into memory.
@ZealotPewPewPew11 ай бұрын
Name ONE 64-bit value that isn't Jackie Chan.
@phrygianphreak442811 ай бұрын
I refuse to eat a single morsel of food until I see four billion gotos