5 ms·
Hidden text inside every compiled Rust program
Here is a simple rust code:
// main.rs
//////////////
struct Point {
x: int,
y: int,
}
fn main() {
let origin = Point { x: 0i, y: 0i };
println!("The origin is at ({}, {})", origin.x, origin.y);
}
//////////////
Compile it using `rustc main.rs`
Now open the compiled `main` file in a text editor and search for this text:
It was from the artists and poets that the pertinent answers came, and I
know that panic would have broken loose had they been able to compare notes.
As it was, lacking their original letters, I half suspected the compiler of
having asked leading questions, or of having edited the correspondence in
corroboration of what he had latently resolved to see.....
- kalleboo 12y agoReminds me of how all HyperCard stacks ended with the Swedish phrase "Nu är det slut..."
- duskwuff 12y agoLiterally "this is the end". Appeared as the content of the TAIL chunk. :) Bonus: HyperCard 1.x used "That's all folks..."
- RailsUser2014 12y agoIt's a paragram from this book: H. P. Lovecraft Fiction Collection. (search for it in google books)
- Steuard 12y agoOr rather, these are all quotes from various Lovecraft short stories. (I don't think there's anything special about one particular collection.)
- mcguire 12y agoThat quote is specifically from "The Call of Cthulu".[1] [1] http://www.hplovecraft.com/writings/fiction/cc.aspx http://www.hplovecraft.com/writings/fiction/cc.aspx
- baxter001 12y agoSeemingly one of 6 possible inclusions: https://github.com/rust-lang/rust/blob/master/src/libgreen/macros.rs https://github.com/rust-lang/rust/blob/master/src/libgreen/m...
- RailsUser2014 12y agoWhat's the point of adding that to any program?
- Steuard 12y agoWhimsy? Fun? What is the point of any Easter egg in software?
- deleted 12y ago[deleted]
- RailsUser2014 12y ago@Steuard Fun? I neither expect a compiler to be funny nor add data I don't know about.
- coldtea 12y agoThe key characteristic of a funny person is that he doesn't comparmentalize fun ("this is serious business" vs "this is fun"). A humorous person can find something to make fun about and make people feel better even at a funeral -- heck even on his deathbed. I think we all have known people like that. OSes, compilers, interpreters, editors -- all kinds of programs have had easter eggs since way before the IBM PC. Those kind of things are inherent in hacker culture (check the Hacker's dictionary for lots of examples).
- spb 12y ago> The key characteristic of a funny person is that he doesn't comparmentalize fun ("this is serious business" vs "this is fun"). Actually, in my experience, that's the key characteristic of an unfunny person desperately trying to pass: http://www.theonion.com/articles/who-says-java-programmers-dont-have-a-sense-of-hum,10733/ http://www.theonion.com/articles/who-says-java-programmers-d... In contrast, here's somebody who could compartmentalize fun: http://www.reddit.com/r/IAmA/comments/2birwp/jeff_bridges_here_abiding_with_you_all_ama/cj5rknb http://www.reddit.com/r/IAmA/comments/2birwp/jeff_bridges_he... Also: https://twitter.com/stuartpb/status/508235714287259648 https://twitter.com/stuartpb/status/508235714287259648
- RailsUser2014 12y agoHere is the commit responsible for that: https://github.com/rust-lang/rust/commit/51abdee5f1ad932671350fdd8a7911fe144d08b8 https://github.com/rust-lang/rust/commit/51abdee5f1ad9326713... What's the point of adding this very long text?
- Someone1234 12y agoFun? Is that not allowed anymore?
- jwatte 12y agoIf Rust is widely adopted, and if this commit adds a kilobyte to every language and every library downloaded by everyone, would the fun for the author be worth it?
- 4ad 12y agoWow, a whole kilobyte! OMG. There are many valid reasons why this should be removed, but binary size is not one of them.
- ploxiln 12y agoIf Rust is widely adopted, it'll save megabytes per executable compared to go or a nodejs tool with all its copies of all its modules. Really, the scale of efficiency delta between various things used on computers today is vast, and it's hard to say whether something like this "easter egg" is really significant. A few years ago I knew of a linux distro called "slitaz" that was a 30mb ISO, and it had x windows and a minimal window manager and a barebones browser and such.
- pcwalton 12y agoIt's an Easter egg when the runtime crashes. There was discussion of removing it, but the size was found to be miniscule in comparison to the rest of the runtime. Note that the runtime will be removed entirely soon, so that text may go with it…
- knd775 12y agoI figured as much. I do like the "You've met with a terrible fate, haven't you?" part very much.
- JoshTriplett 12y agoThat one seems like the right length for a runtime error. The others seem far too large and distracting as prefaces for a runtime error.
- oconnor0 12y agoWhy is the runtime being removed? And is there discussion on that somewhere?
- ben0x539 12y agohttps://github.com/rust-lang/rfcs/pull/230 https://github.com/rust-lang/rfcs/pull/230 It's "just" an RFC, but the notion that has some momentum built up already.
- niix 12y agoThis is pretty great, makes me want to write Rust more.
- jbert 12y ago> Now open the compiled `main` file in a text editor and search for this text: FYI, the unix utility 'strings' has this as it's raison d'etre.
- metafex 12y agoWhat a beautiful way to deal with runtime errors. This makes me really want to pick up rust again (and find a bug in the runtime :) )