Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Hidden text inside every compiled Rust program
46 points by RailsUser2014 on Sept 12, 2014 | hide | past | favorite | 47 comments
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.....



It'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…


I figured as much. I do like the "You've met with a terrible fate, haven't you?" part very much.


That one seems like the right length for a runtime error. The others seem far too large and distracting as prefaces for a runtime error.


Why is the runtime being removed? And is there discussion on that somewhere?


https://github.com/rust-lang/rfcs/pull/230

It's "just" an RFC, but the notion that has some momentum built up already.



I hope that isn't random. It would break build systems that try to do repeatable builds and check via checksum.


It's the last digit of the sum of the chars in the error message converted to uints. I think, I don't really speak Rust.


What's the point of adding that to any program?


Whimsy? Fun? What is the point of any Easter egg in software?


It's the error message you get when you trip over a bug in the runtime.


@Steuard Fun? I neither expect a compiler to be funny nor add data I don't know about.


The 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).


> 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-d...

In contrast, here's somebody who could compartmentalize fun: http://www.reddit.com/r/IAmA/comments/2birwp/jeff_bridges_he...

Also: https://twitter.com/stuartpb/status/508235714287259648


Then make sure that's a stipulation in your RFP next time you're commissioning a compiler. One of the nice things about open source work is that we get to have a little fun with it.

Side note, I would expect someone named "rails user" to at least have a modicum of humor.


Little is worse in code land than a compiler that plays games, and bad games at that. This just reinforces my feeling that Rust is a toy and not for real work. A cute little dungeon when my (potentially critical) application just crashed is the opposite of humorous, it could be deadly. Compilers are serious business. Write games with them if you choose but understand that failure at the compiler/runtime level can have serious consequences for real people.

It reeks of immaturity.



It's weird that you link to a definition of "concern troll" and then manage to misapply it to a post that, even if it was trolling, is not concern-trolling.


I sort of agree with you - "concern troll" applies more to OP than this post, upon reflection - but let me explain my reasoning.

Lots of people have explained elsewhere in the thread why this is a completely trivial issue. I don't think it's a reasonable position to hold that a kilobyte of static data in the runtime is an actual problem that needs solving - if it were, we would see pull requests like any other bug, not a pearl-clutching HN thread.

Concern trolls attempt to weaken or fragment a community by pointing out "problems" that aren't actually big enough to actually warrant attention or energy, then accusing the community of weakness/malfeasance/hypocrisy for failing to act. This primarily serves to divide idealists (who want to solve every problem, no matter how small) from pragmatists (who want the community to focus its energy on things that matter).

Amplifying a small matter like this into a "deadly" one and claiming that it "reeks of immaturity" is such grandiose posturing that I personally cannot imagine it's in earnest. It seems more likely to me to be someone heavily invested in another toolchain who wants Rust to not be taken seriously, wants contributors to Rust to fret over every commit, and wants people considering Rust to worry about the consequences should they adopt it. That's all I intended to convey.


Actually I'm not invested in Rust (or Go) at all, but I am invested in critical infrastructure software. My intent was to support the op's assertion that compilers are serious business. I think they are. 1k among 100k might not make a difference, but to me it implicates an attitude and leaves me wondering what other cute games are hiding.


I agree with you. Tools are serious business.

Selling consumer lollipops? Use all the whimsy you want; it's part of your marketing.

I don't expect the beams of a trestle to spell "LOL WTF". I expect a bridge to be built by a person who does-not-fuck-around. My life depends on it.


You only use compilers that you fully understand? That's a high standard to live by.


This is pretty great, makes me want to write Rust more.


> 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.


It's a paragram from this book: H. P. Lovecraft Fiction Collection. (search for it in google books)


Or rather, these are all quotes from various Lovecraft short stories. (I don't think there's anything special about one particular collection.)


That quote is specifically from "The Call of Cthulu".[1]

[1] http://www.hplovecraft.com/writings/fiction/cc.aspx


What 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 :) )


Reminds me of how all HyperCard stacks ended with the Swedish phrase "Nu är det slut..."


Literally "this is the end". Appeared as the content of the TAIL chunk. :)

Bonus: HyperCard 1.x used "That's all folks..."


Here is the commit responsible for that:

https://github.com/rust-lang/rust/commit/51abdee5f1ad9326713...

What's the point of adding this very long text?


Fun? Is that not allowed anymore?


I'm sure it's deeply moving to read poetry when your program crashes in development.

But when I'm trying to resolve a production issue and I have to waste brain cycles ignoring garbage text to solve a problem, I will hunt you down.


"Come at me bro."

https://www.youtube.com/watch?v=aS1esgRV4Rc I'm not by any means the guy who wrote that easter egg, but I'm in absolute solidarity with his sentiment. I don't want to be a Randian Ubermensh like Howard Roark, in a soviet world stripped of all artifice and caprice.

The world needs to stay playful - and my world is software. Fun isn't optional; it's absolutely necessary for the human psyche - any description of a world without it is isomorphic to a prison or a hell. The price of fun is frivolity - one man's fun is another man's "stupid waste of time". There's no way around this; it's just the table ante we have to pay for having a non-spartan culture.

Yes, the overhead cost sucks ... but the alternative has been proven to be much much worse.


If 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?


If 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.


Genuine question: Megabytes compared to Go? Why?


Because the Go runtime is statically linked into every binary built by Go. This is nice for deployment, since you can just plop the binary onto any ol' server, but makes for large binaries.


Wow, a whole kilobyte! OMG.

There are many valid reasons why this should be removed, but binary size is not one of them.


Size is certainly an important factor in embedded systems, one of the areas there is a lot of interest in Rust.


Can you do the math for me of every user on the internet times every program downloaded?


Why not?


If Rust is widely adopted, and this actually becomes a problem for anyone, someone will submit a pull request to remove it, it will be debated, and probably pass.

On the other hand, its presence in the current codebase will tend to attract playful tinkerers, which is arguably what it needs in its current stage of development.


yes


@Someone1234 You're kidding? Try adding a new pull request in C and tell them that you want to add a text inside every compiled c program because "it's funny". I'm not sure they'll agree with you.


http://gcc.gnu.org/ml/gcc-patches/2012-03/msg00049.html

Search for "Here's a nickel"

[edit: clearer source than the text around the patch: https://github.com/gcc-mirror/gcc/blob/master/libgcc/soft-fp...]


That's a compile-time error message, though. It doesn't appear in compiled code, only in the source.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: