[HN Gopher] Signed Char Lotte
___________________________________________________________________
Signed Char Lotte
Author : signa11
Score : 378 points
Date : 2021-03-31 08:36 UTC (1 days ago)
(HTM) web link (nickdrozd.github.io)
(TXT) w3m dump (nickdrozd.github.io)
| karatinversion wrote:
| > love 1s *!(not= atoi(let
|
| Probably my all time favourite C fragment.
| bqmjjx0kac wrote:
| A close second for me is goto hell;
| alanbernstein wrote:
| For those who haven't seen it:
|
| https://www.reddit.com/r/ProgrammerHumor/comments/4qw691/dr_...
|
| https://i.imgur.com/vJFn0ov.png
| vaer-k wrote:
| I 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?
| azernik wrote:
| In 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/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 wrote:
| > (-x & 6)
|
| wouldn't (x * 6) get the same result?
| Ansil849 wrote:
| Just 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 wrote:
| I 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 wrote:
| This 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.
| Swizec wrote:
| Yeah that's what I was trying to say.
|
| When a wizard from a different house uses _your_ magic, you
| gotta defend your holy right and exclusivity.
|
| When one of your wizards uses another's magic, that's
| fantastic! No threat to your tribe and might even make it
| better.
| Ansil849 wrote:
| Yes, I like this. That's quite a fun way to get the point
| I was trying to make across indeed!
| lstamour wrote:
| Here's a thought. If a poet were presented with this code-
| poetry, would they appreciate it as much as a coder?
|
| That said, I'm a programmer who took digital media art
| installation courses in school and I didn't find it to be
| that different from programming, just with different
| results/goals. https://cycling74.com/products/max isn't a
| toy programming environment any more than
| https://www.ableton.com/en/ is a toy environment or
| https://origami.design/ is a toy environment. They just
| have different goals, and perhaps different standards of
| quality?
| Someone wrote:
| I don't think so. It's a form of constrained writing
| (https://en.wikipedia.org/wiki/Constrained_writing).
|
| In such writing, the challenge is to construct beautiful
| texts despite of artificial constraints.
|
| They wouldn't understand the constraints, so they
| wouldn't be able to understand why nicer texts wouldn't
| satisfy them.
| rhizome wrote:
| You're making a category error, the relationship is not
| symmetrical.
|
| Comparing apples to apples, if the programmer dabbled in
| artmaking or writing, I'm confident they would get a similar
| reaction from accomplished artists or writers.
|
| There are many, _many_ , MANY examples of programmers
| attempting to write, and I'll stick a pin in this to say most
| of it is not good--if not truly bad--and in both disciplines
| the number of people who take the difference in expertise as an
| altruistic teaching opportunity are very few indeed.
| Igelau wrote:
| > 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
|
| I've honestly never seen this happen and have no idea what kind
| of person would react this way.
| Ansil849 wrote:
| >> 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
|
| > I've honestly never seen this happen and have no idea what
| kind of person would react this way.
|
| Take a look at some HN user responses to when the Google Will
| Eat Itself art project was posted here [1].
|
| [1] https://news.ycombinator.com/from?site=gwei.org
|
| A couple choice examples of the kind of behavior I am talking
| about:
|
| > I'm pretty sure it would be trivial to write a program that
| automatically generates modern "art" exhibit descriptions
| like this one.
|
| > I'm not sure what's worse, the fact that this is a stupid
| idea - or the background
|
| And so on...
| zokier wrote:
| Intent means a lot. I feel the Picasso quote fits here
| somewhat:
|
| > _It took me four years to paint like Raphael, but a lifetime
| to paint like a child_
|
| So you could ask why Picassos stylized paintings are revered,
| but kindergarteners works are not
| biosed wrote:
| You are correct but it happens in all fields/passions ...etc
| E.G. Jazz, you need to be a very good musician to create good
| jazz. A programmer could create something that creates jazz but
| jazz musicians will find it lacking, for want of a better word.
|
| Got lost in a train of thought but I hope you understand what
| I'm trying to say.
| ncmncm wrote:
| Longest 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.
| edoceo wrote:
| Absolutely brilliant. And deciphering that C was a nice include,
| no surprise it won the competition.
| lupire wrote:
| How does it toggle the value of `get` between runs?
|
| Lots of analysis but the article stops short of analyzing how the
| core logic works.
| wnoise wrote:
| > get = !get;
|
| from the original
|
| > for (get = !get; !out; (char)*lie & 0xD0 - !not)
| AnotherGoodName wrote:
| It 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 ($).
| edoceo wrote:
| Scroll down and you'll see a deciphered get =
| !get
|
| That's a toggle.
| h2odragon wrote:
| Brilliant 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 wrote:
| For 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.
| omoikane wrote:
| Having 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.
| golergka wrote:
| I'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.
| byronr wrote:
| As an IOCCC winner I've had my winning entry verbatim on my
| resume for years. It's small enough to look like a decorative
| footer and it always garners comments.
|
| Your question has another angle: why would I care to work for
| an employer who looked down on my IOCCC win? It acts as a
| filter both ways.
| [deleted]
| nickdrozd wrote:
| Has anyone ever tried to compile it? It doesn't work for me:
| gcc -w 1990/tbr.c 1990/tbr.c: In function 'main':
| 1990/tbr.c:7:50: error: void value not ignored as it ought to
| be 7 | e(-8) ,gets (1+( c=q) )||
| exit (0); r(0,0) |
| ^~~~~~~~~~~~~ 1990/tbr.c: In function 'e':
| 1990/tbr.c:22:43: error: void value not ignored as it ought
| to be 22 | 3 ;}e(x){x<0?write(2,"?\n$
| "-x/4,2),x+1||exit(1): |
| ^~~~~~~
|
| Similar for clang. I'm sure there is an easy fix, but I don't
| know what it is.
|
| The program in question, if anyone is wondering, was the 1990
| winner of IOCCC "Best Utility" award. Source is here:
| https://www.ioccc.org/1990/tbr.c
|
| The authors explain in rot13: "Guvf cebtenz vf n ehqvzragnel
| furyy."
| [deleted]
| jfk13 wrote:
| Works for me with clang -std=c89 -Wno-
| implicit-function-declaration -fno-builtin tbr.c
|
| Compilers are fussier (with good reason!) than they used to
| be.
| nickdrozd wrote:
| Those flags work with gcc too. A deleted commented
| suggested adding `int exit();`, which also worked.
| oh_sigh wrote:
| I've been hired at half of the FANG companies and I'm convinced
| I was hired not because of my direct performance in the
| interview questions, but I threw in bizarre minutiae about the
| problems that I've picked up over the years merely because I
| enjoy trivia.
|
| I also failed an interview (or rather was not offered a job) at
| one of the FANGs, and I thought I did good enough on the
| interview portion, but it was the only interview where I didn't
| have the opportunity to drop some obscure trivia.
| rav wrote:
| You know it's prose written by a programmer when they use "else"
| in a sentence where other people would say "otherwise".
| zshrdlu wrote:
| https://www.smbc-comics.com/comic/the-program
| kzrdude wrote:
| And the poetry looks a bit programmer-damaged too, now that I
| think of it.
| kzrdude wrote:
| Could 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.
| xrd wrote:
| I'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.
| drivers99 wrote:
| Now's your chance.
|
| Exercises
|
| ...
|
| 2. Modify "signed char lotte" so as to include more C keywords.
| snakeboy wrote:
| As this is a purely creative endeavor, it's your prerogative to
| turn those feelings into inspiration for your own attempt -
| nothing sad about it :)
___________________________________________________________________
(page generated 2021-04-01 23:00 UTC)