![]() |
|
![]() |
|
it's fun to golf, but how big are pages these days, anyway? (and if you're using a language with a stack, your executable probably ultimately loads as at least two pages: r/o and r/w) |
![]() |
|
Compared to a Hello World program on C64 written in assembler probably not. ;) I need roughly 24 bytes. 16kb means 16.384 bytes. I can think of better usage of $4000 space in memory, FLI for example. |
![]() |
|
In case there are any DOS enthusiasts out here, a "hello, world" program written in assembly/machine code in DOS used to be as small as 23 bytes: https://github.com/susam/hello Out of these 23 bytes, 15 bytes are consumed by the dollar-terminated string itself. So really only eight bytes of machine code that consists of four x86 instructions. |
![]() |
|
This reminds me of one of my favorite CS assignments in college for a systems programming class:
I remember using tools like readelf and objdump to inspect the program and slowly rip away layers and compiler optimizations until I ended up with the smallest possible binary that still outputted "hello world". I googled around and of course found someone who did it likely much better than any of us students could have ever managed [1][1]: https://www.muppetlabs.com/%7Ebreadbox/software/tiny/teensy.... |
![]() |
|
I'd note that the smallest instruction sequence doesn't necessarily correspond to the smallest executable file, since you might be able to combine some instruction data with header data to make the file smaller. For instance, when I tried to make the smallest x86-64 Hello World program (https://tmpout.sh/3/22.html), I ended up lengthening it from 11 to 15 instructions, while shortening the ultimate file from 86 to 77 bytes. |
![]() |
|
Our curriculum was c++, so it was familiar territory for the students in terms of both the language and the compiler but yeah you can likely do this exercise with any compiled language.
|
![]() |
|
Assuming there's a vaccuum between the screen and your eyes (perfectly spherical), of course. Otherwise, its gets very interesting and very very complicated. :) |
![]() |
|
Strangely harsh comment. I mean it's impossible for anyone to "fully understand". This post didn't even get to the hardware level! This ancient Google+ post is one of my all time-favorites: Dizzying but Invisible Depth. https://archive.is/100Wn#selection-693.0-693.28 I do think it's critical for programmers to be curious and dig a few levels deep. This young programmer went about 7 levels deeper than almost anyone would. Kudos to him! |
![]() |
|
Just saying hi ! (and thanks for the read, got me back to the old days of ASM One and SEKA on Amiga, trying to clean up my memory dust pile)
|
![]() |
|
I've been thinking recently, we might have too many layers of abstraction in our systems. And I didn't even know about most of the ones in this post. |
![]() |
|
I'm 40, and I've done things down to the level of wiring discrete transistors into logic gates, as well as C64 BASIC, C, […], ObjC, and Swift. Even did a module on OSes at university (20 years ago, so they were simpler). I just… wrote my previous comment so badly everyone legitimately missed the point that was in my head. Consider that part framing. My problem with modern abstractions is the wheel keeps getting reinvented by people who don't know the lessons from the previous times it was invented, even when they're making their wheel out of other wheels — which is how I feel when I notice a website using javascript to implement I could go on (also don't like VIPER) but this would turn a comment into a long blog post. While I also don't like that web browsers are inner-OSes, can see how it happened from the second half of Zawinski's Law: Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can. - https://softwareengineering.stackexchange.com/questions/1502... |
![]() |
|
> All modern big and important programs that make a computer work are written this way [AoT-compiled to native code]. This is the conventional wisdom, but it's increasingly not true. |
![]() |
|
I think it’s definitely true if taken literally, “make a computer work”. From Python interpreter, to browsers, to OS, and most optimized libraries.
|
The "better behaved" way is to call vDSO. It's a magic mini-library which the kernel automatically maps into your address space. Thus the kernel is free to provide you with whatever code it deems optimal for doing a system call.
In particular some of the system calls might be optimized away and not require the `syscall` at all because they are executed in the userspace. Historically you could expect vDSO to choose between different mechanisms of calling the kernel (int 0x80, sysenter).
https://man7.org/linux/man-pages/man7/vdso.7.html