14 ms·
Signed Char Lotte
- edoceo 6y agoAbsolutely brilliant. And deciphering that C was a nice include, no surprise it won the competition.
- lupire 6y agoHow does it toggle the value of `get` between runs? Lots of analysis but the article stops short of analyzing how the core logic works.
- edoceo 6y agoScroll down and you'll see a deciphered get = !get That's a toggle.
- wnoise 6y ago> get = !get; from the original > for (get = !get; !out; (char)*lie & 0xD0 - !not)
- AnotherGoodName 6y agoIt doesn't. You're misreading it. A single invocation repeatedly prints './charlotte' and then loves me/loves me not. Note in the example he gave on the line '$./charlotte 5'. This is the only line that starts with a prompt ($).
- xrd 6y agoI'm saddened this does not use the union nor float nor volatile types. It could have ended somewhat better, or perhaps somewhat more dramatically, I think.
- karatinversion 6y ago> love 1s *!(not= atoi(let Probably my all time favourite C fragment.
- bqmjjx0kac 6y agoA close second for me is goto hell;
- koolba 6y agoWhen I first read Perl I was convinced all its advocates had some deep seated emotional problems. They kept insisting that the program would perform an action “or die”.
- jerf 6y agoIf you turn strict off, you can have doIt() or die screaming as literal code.
- kbenson 6y agoIf you make a screaming sub, that doesn't even require foregoing strict: $ perl -E 'use strict; use warnings; sub screaming { "SCREAM" } sub doIt { 0 } doIt or die screaming' SCREAM at -e line 1. Hell, we can go full English if we want: $ perl -E 'use strict; use warnings; sub screaming {"SCREAM"} sub it {0} sub do {0} do it or die screaming' SCREAM at -e line 1. For those following along that aren't quite as familiar with Perl, that's a statement "do it or die screaming" which is all completely valid, strict and well defined Perl. When not a one-liner, it would be: use strict; use warnings; sub screaming {"SCREAM"} sub it {0} sub do {0} do it or die screaming
- ak217 6y agoToday git informed me that it "could not detach HEAD" and refused to merge my work with that of my colleagues.
- rav 6y agoYou know it's prose written by a programmer when they use "else" in a sentence where other people would say "otherwise".
- zshrdlu 6y agohttps://www.smbc-comics.com/comic/the-program https://www.smbc-comics.com/comic/the-program
- kzrdude 6y agoAnd the poetry looks a bit programmer-damaged too, now that I think of it.
- waterhouse 6y agoMy first thought was: "Expenses be damned, sire! We need barracks! Else where will our soldiers rest their mighty lances?" https://www.youtube.com/watch?v=oFQDeYXq_iw&t=21s https://www.youtube.com/watch?v=oFQDeYXq_iw&t=21s Then I realized that Civilization II was created by, well, programmers. Though I couldn't say who wrote the dialogue.
- shawnz 6y agoRelated https://news.ycombinator.com/item?id=25406211 https://news.ycombinator.com/item?id=25406211
- h2odragon 6y agoBrilliant explanation. Since its "hiring day"; I'll ask: If you were interviewing someone and they listed an IOCCC win, would you count that as a plus? would you have to go look at the entry first? And turned around: if you've won (or even submitted an entry) to IOCCC, would you mention it when applying for work?
- l0b0 6y agoFor sure, as long as that's not how they/I write code normally! :D It demonstrates very in-depth understanding of the structure of the language, just as any good writing demonstrates expert-level understanding of natural language. Two caveats: - A lot of this knowledge might be kind of useless (for example, how to create unreachable code which nevertheless compiles), but I expect it would be difficult to demonstrate equally thorough understanding of the syntax of a language using exercises or looking at previous work (which ideally uses the minimum of sophistication to achieve the necessary functionality). - It proves mastery of the syntax, but not of idioms, security, maintainability, speed, or any other metric relevant for production code. These might be correlated, but I'd rather see/present some examples of these as well to be sure.
- golergka 6y agoI've almost never had to write or read C in a professional capacity, but if I saw that the candidate was such a geek, it would certainly be a huge plus. There's a huge gap in professionalism and knowledge between people who choose software engineering as a trade because it pays well, and people who love it for the sake of it. But there's a catch. Second kind of engineer is not only better, but also much more desirable and highly paid, so may be it's an indicator that you should check whether your salary range is high enough and your tasks are challenging enough for someone like that. For some (if not most) roles, 9-to-5, grunt work engineer that just closes tickets and doesn't write new languages in his spare time is really the best fit.
- omoikane 6y agoHaving won the IOCCC definitely helps to boost visibility, since it is one extra place where prospective employers can look you up, and it's a fairly exclusive one. I ended up doing some readability related work at my current job because of (in spite of) my IOCCC experience.
- kzrdude 6y agoCould you say that with a type like signed char, it inspires to writing such poetry or plays? I would wager it didn't come from nothing, but from such a strange spark.
- vaer-k 6y agoI wonder how you would go about writing something like this. I guess you'd start by writing sensible code, and then tweak and tweak until it was funny and weird and unrecognizable, but still functional?
- Ansil849 6y agoJust an idle rumination... It is curious to me how when a programmer does something beautiful and creative, it is (rightly) revered by other programmers, such as this example. On the other hand, if someone who is not a programmer but is an artist or a writer, dabbles in programming, it is often met with derision and extreme nitpicking by programmers. In other words, there seems to be a bit of a double-standard, where in one's own discipline one is able to appreciate creativity and art, but if someone else uses dabs of one's discipline in theirs, one can no longer see the artistic merit and can only fixate on the technical limitations.
- Swizec 6y agoI believe this happens in most professions. When an amateur announces they've created fine art and even dares put it up for auction at ridiculous prices, true artists complain. A lot. When you architect a building, architects complain about all the things you did wrong. There's even a popular blog making fun of McMansions. When you build a car in your garage, true car engineers will tell you it's dumb and you missed a whole bunch of important things. But those are not the folks who are great at their craft. Those are the gatekeepers afraid of newcomers. The greats encourage new entrants because they know the pie can only get bigger.
- Ansil849 6y agoThis is a good point, but it is a bit different from the observation I was trying to make. What I am more observing is that if someone within your discipline uses elements of another discipline and brings it into yours, if it is done well, others who are in that discipline will appreciate it. Case in point: if a programmer incorporates poetry into their code. On the other hand, if someone from another discipline uses your discipline as an element in theirs, those from whose discipline that element was taken from seem typically unable to appreciate the broader work of art, instead only fixating on how the materials from their discipline have not been used properly. Case in point: if for example a contemporary artist incorporates some programming in their art installation.
- 6y ago
- alanbernstein 6y agoFor those who haven't seen it: https://www.reddit.com/r/ProgrammerHumor/comments/4qw691/dr_seuss_writes_code/ https://www.reddit.com/r/ProgrammerHumor/comments/4qw691/dr_... https://i.imgur.com/vJFn0ov.png https://i.imgur.com/vJFn0ov.png
- azernik 6y agoIn similar C-string trickery, consider this lovely bool-to-string function: /** @brief Construct a String equal to "true" or "false" depending on the value of @a x. */ inline String::String(bool x) { // bool_data equals "false\0true\0" assign_memo(bool_data + (-x & 6), 5 - x, 0); } Source: https://github.com/kohler/click/blob/6fa978f0188bd0b8a266f65cd0e79d81838b7963/include/click/string.hh#L388 https://github.com/kohler/click/blob/6fa978f0188bd0b8a266f65... Context: This is the source code of the Click Modular Router, a system for implementing packet processing logic with a graph-like DSL. Both primitives, and certain complex logic, are implemented in C++; however, as this has to be able to run as a Linux kernel module or in userspace or as a BSD kernel module, it can't use the C++ standard library, and do has its own stdlib.
- zokier 6y ago> (-x & 6) wouldn't (x * 6) get the same result?
- azernik 6y ago* is an inherently more complicated action, and takes 3 cycles on x86 and from 3-5 cycles on ARM. & and - are stupid-simple and take 1 cycle, always. The real question is why this isn't done with ~. Possibly some weird embedded platform doesn't have an instruction for it? I doubt this string conversion code is ever on the hot path for packet processing, but Click is in general written like everything is.
- saagarjha 6y agoI don’t get why bool_data couldn’t be an array of two strings with x indexing into it…
- azernik 6y agoTwo pointer dereferences are slower than one - got to read from the top-level array, then use the pointer to read from the individual string. This way you can figure out the address of the string with about four very cheap instructions and zero memory accesses. Plus cache locality.
- ncmncm 6y agoLongest sentence using only C++ keywords, once each: "If new true friend not protected for explicit private union, break case and try using this". All C++98 keywords, here.
- marcodiego 6y agoI was once reprehended for wrting this: for//ever (;;){
- bogwog 6y agoThat's going in my codebase some day
- bitwize 6y agoThis reminds me of the "Perl Poetry" found in the back of the Camel Book. Larry Wall's toes probably curled with glee to know his little language was postmodern enough to admit many examples of that sort of thing.
- aasasd 6y agoThere's a vaguely entertaining esolang ‘Shakespeare’ in which programs look like plays: https://en.wikipedia.org/wiki/Shakespeare_Programming_Language https://en.wikipedia.org/wiki/Shakespeare_Programming_Langua... BTW, in the spirit of art that uses two mediums with one source, there's this thing ‘oscilloscope music’: as far as I understand, the same signal goes to the speakers and the display, so it likely doesn't get more raw than that. Though, most of it is abstract shapes. E.g.: https://www.youtube.com/watch?v=_6a_nz4uRd0 https://www.youtube.com/watch?v=_6a_nz4uRd0 https://www.youtube.com/watch?v=Y04LBDTsGIk https://www.youtube.com/watch?v=Y04LBDTsGIk
- svat 6y agoI wrote a program in Shakespeare once: https://codegolf.stackexchange.com/questions/123378/golf-my-shakespeare-quote-references/124821#124821 https://codegolf.stackexchange.com/questions/123378/golf-my-... It was a lot of fun, and I recommend the experience. You get to figure out control flow (if you've never written a program in anything lower level than C, as I hadn't, you'll need to figure out control flow with just jumps; there are no procedure calls or looping though there's "if"), and then there's some room for creativity in choosing the character names and scene descriptions.
- chokma 6y agoIt reminds me of a darker poem ... https://en.wikipedia.org/wiki/Black_Perl https://en.wikipedia.org/wiki/Black_Perl
- lifthrasiir 6y agoIf you speak Japanese (or can tolerate a machine translation), Yusuke Endoh, one of the best IOCCC winners all time, is writing short summaries [1] of every winning entries over the course of this year. Recommended as a starting point. [1] https://mame.github.io/ioccc-ja-spoilers/ https://mame.github.io/ioccc-ja-spoilers/
- aerovistae 6y agoWhat is the me= !oxface supposed to read as?
- cooper12 6y agoI read it as "[you] double-time[d] me, oxface", with "ox face" being meant as an insult.
- ufo 6y agoMy favorite part are the ;{ emoticons.