Even one of the simplest programs (a “Hello, World!n” program) is still much larger than it strictly needs to be. In this video, I demonstrate how to reduce executable file size starting in C, then dropping down to assembly, then even raw machine code, and more.
00:00 Introduction
01:00 Definitions and constraints
02:14 C
06:20 Assembly
13:05 ELF binary
22:36 Looser constraints
33:41 Outro
source

<html>
<body>Hello, world!</body>
# my thought process was that html code for putting text on the screen is just putting the text in the code,
# (i hope that these comments register as comments,)
# but i mean there's all that junk like all the stuff in <here!> oh that's funny it auto printed that -> </here!>
</html>
oh nevermind the output was:
Hello, world! # my thought process was that html code for putting text on the screen is just putting the text in the code, # (i hope that these comments register as comments,) # but i mean there's all that junk like all the stuff in oh that's funny it auto printed that ->
I'm just thinking "wow! more reason to be scared of assembly!"
i feel so left out because i type "Dummy Placeholder"
are you Isoco?
Finally, now I can run "Hello, World".
29:48 Wasn't there an esoteric programming language whose interpreter for codegolf reasons interpreted an empty source code file as a hello world program?
thought it said smartest instead of smallest
If you allow any operating system and achitexture to be used, i found this program online that works on dos that is in assembally, and is 24 bytes:
MOV AH,9
MOV DX,108
INT 21
RET
DB 'Hello, world!',0D,0A,'$'
nah best hello world is holyC you just do "Hello World!" thats it
Replace n with byte 0A
Meh, I wrote an entire functioning 4 axis 4 button gamepad/joystick driver in raw assembly, and when compiled to machine code, only took up 65 bytes of space. Not KB, certainly not MB, just 65 bytes of raw x86 machine code.
And no, I refuse to update my terminology to that stupid KiBiByte or whatever people call that crap these days. If the base measurement is in bytes, then it's by definition in base 2, so as was in the 80s, 90s, and 2000s, a Kilobyte is 1024 bytes, a Megabyte is 1048576 bytes, and if you actually do know programming (which clearly you do OP), you ought to stick to OG terminology and leave the dummies to count in base 10.
Sigh, rant over, but yeah it irritates the hell out of me when established computer terminology for over 40~50+ years gets arbitrarily changed (and even sounds stupid like dog kibble) because non tech savvy people have no comprehension of binary/base 2…
Bro what is that terminal Im dead 💀 otherwise cool video
in stuck, just save the file and boom, hello world in 0 bytes
reminds me of that one code-glof language in which an empty file in interpreted as a hello world lol
I was totally expecting assembly. But I also expected some embedded too. Or similar. Like, even for x86, have the "OS" as the Hello World. I guess you need some initializations, so maybe still have it as a program in a very bare-bones OS. On that note, I wonder if x86 in 16 bit mode can allow for a smaller binary. For this program in particular, I guess not, since there aren't any pointers. Still, a FreeDOS executable, I expect to be able to have less bytes.
Your work is not over Mr. Joshua! We're counting on it 😄
Jokes aside, this was neat. I appreciate the comment annotations for the various headers, it made things much easier to understand. Though I did space out a bit starting from that 58 byte version, things got a complicated fast and I would've needed to pause and parse and was lazy to do so. Still enjoyed the full video, keep it up!
less than 1,000 subscribers is criminal – great video!
AI SLOP + Paid for comments.
@Joshua Rayton
Why make so many constraints? If I were to write the shortest Hello World! program I'd start with the first thing I think of which is this:
LDX #11
Loop:
LDA message,x
STA $0400,x
DEX
BPL Loop
RTS
message .byte "Hello World!"
That's 24 bytes.
peak optimization
this video needs more views really, in-depth explanation of all the methods used to compress sizes, the elf file format, etc, well done!
This should have more views not speaking of subs,
No matter how much you'll try there will still be some Terry Davis who'll make a hello world in 0.7 times smaller as your version.
(that's not the reason to give up)
kernel component for hello world? amazing video
I have no idea why this got into my feed, but I'm very happy it did.
crazy you have so few subs with this high quality content
Awesome video
Bro typing at the speed of light 💀
The only person in the world who uses "mebibytes":
Woah! Sometimes ago I was just dreaming of getting this far low level. Now with a little knowledge I have, I can assure that all of this doesn't help me to write real programs. I wrote a calculator in netwide assembly but I still don't know the advanced C++ and graphical things at all!
I made a virtual machine wiht a file size of 249 bytes
in holy c just "Hello, world!n"
cool!
are you're dot files public? esp the nvim config
really cool video!
damn i expected alot more than less tha 1k subs with this quality of video!
Eliminated software bloat in exchange for kernel bloat! Next step would be designing an x86 CPU that has a ROM dedicated to the "Hello, World!n" bytes and circuitry to write it to whichever memory address gets mapped to stdout. Perhaps have a firmware running a scan on memory to inject the Hello World when a certain magic number is read from I/O. The possibilities are endless.
even smaller hello world would be to use cryptinstructions or an rng, and then just run it until it eventually writes "Hello, World!"
there are 256^13 possible combinations of ascii characters in hello world, so youd have to wait a while
13:00 "surely there's no more way to make it smaller"
>not even half of the video
"okay i was wrong" 😂
i recommend you run the audio through a de-esser
very engaging presentation style!
The kernel module is still kinda cheating, it's equivalent to having a compressor that can compress the entire of wikipedia in 0 bytes (all of it is in the decompressor). But still love the idea :3
Finally "Hello, world." with no bloat.
How do you not have a million subscribers? Such high quality!