Last issue included a script. Deák Ferenc plays with the paradigm and dives into (a) deep sea (deap C).
(A digital drama in 3 acts)
Dramatis Personae
The Speaker – the one introducing the other characters, reading up ere an act, and having the general moderator role.
The Source – the one character who is’t acts irresponsibly through the entire playeth, oft changes its shape, and mostly doest not collaborate very well with other actors in the scene, doest not coequal conform to standards, but since Source being the central person in the entire playeth, everyone tries to winneth his favours.
The Compiler – the character with a huge responsibility of trying understandeth the humor swings of the Source while in the same time taming the shrew in the direction of being a productive member of society without uncovering an overly abusive encroachment while being expos’d to the behavioural traits of the Source. Sadly, due to excess pressure, a high workload and constant propagation, the Compiler suffers from a light version of schizophrenia, which expresses himself in the form, yond the Compiler oft calleth himself gcc, oft clang, and oft something else, and coequal at which hour taking one persona, the Compiler cannot decideth in some very basic features, such as a version number so all these combinations cometh up with very amusing conversations the Compiler hast with the same Source.
Did lay the scene
(Speaker enters the scene, softly pulling the Source after himself with one handeth, while holding his headeth in dismay with the other.)
Speaker Thither is programming, and thither art programmers. Thither art most wondrous practices, thither art poor practices and thither art nay practices. And then thither is the very much obscure ordinary of code yond no-one understands.
Source And thither is me!
Speaker Contrary to the mainstream development methodologies and recommendations at which thy cometh about writing code which is easy to readeth, maintain and generally can beest pondered obeying the laws of crisp code, in this lightheart’d drama we shall explore the enshielf depths of exceptionally obscure coding disciplines at which hour one tries to writeth code which is hard to readeth, disobeys the ingraft sense, uses practices which oft can beest pondered dangerous but still worketh did bind to specific Compiler and platforms, and last but not least thee would not wanteth to see those imbued into thy production code base.
Source And yond is me!
Speaker Thee wast did warn, thee shalt not followeth the traits of the Source, useth thy inner force to raiseth above him and deliver for thy peers a much better version while learning from mistakes done hither.
Act 1 – The one who did nothing
Speaker (Stands alone in the middle of the scene, a single beam of light shines down upon him) There are programs that do nothing, lazy Sources wasting their life in the wast emptiness of the digital landscape, without having a meaning, except to annoy specific Compilers, but here, witness dear spectators an interaction of one of these.
(Source haughtily enters the scene, he wears a very finely decorated mantle, the scene lits up)
Source Here we are, born to be kings, without excess doings of precise one time useth of the keywords the C language shall present to us, dear Compiler, but warned be thy meant to be, not more than one of all of them shall be presented by us. And hither we art:
int main(long _, char __) { switch (_) do { case 0: default: for (auto float _ = sizeof(union {}); _; *(const double*)&_) { extern struct { enum { _ } _; } __; } if ((void*)0) goto * 0; else continue; static volatile signed short i; typedef unsigned j; register j k; break; } while (0); return _; }
(Compiler jumps in the scene, seemingly agitated)
Compiler I have seen a Source, just like the wildest of cards, but more like a Morse, the one from the code, not the one from Scotland Yard. This Source thither contained all the keywords of the C language, I am meanteth to compile, their order like a rhyme, but wholly like the chyme. Not to say that feels like crime.
Source How dare thee fig me, thee insignificant luxurious mountain goat, can’t thee see that I am the shortest of all C programs that must contain all the keywords of the language?
Compiler I see that thee non standard compliant piece of the horror. How dare thee declare the parameters to the main
to beest long
?
(Compiler starts to tremble, violently shaking, several personaes appear one after the other)
The GCC personae of Compiler I see nothing wrong. A bit of flexibility, hither or thither, but forsooth as that gent sayeth, this source is to beest compiled. (Turning to the Source) Not that too much t’will doth, mostly just leaveth as thee cameth to this world. Without facts, without meaning. Doing nothing. Void emptiness, shell of a life not meanteth to achieve anything in his time. (Compiler shakes himself, new personae appears)
The clang personae of the Compiler Oh the horrores, madre mio, padre Santos, has’t thee seen this source? That gent useth a jump to a dereferenced address of 0
, not that I would dare to compile. Dame agua, hijo, I cannot standeth the violations of the argumentos to poor main, one is a long
, the other one is a char
, oh, the indignity that I has’t to see source like this, and the shame that that gent presents himself to the world. Ayúdame, el cielo se me cae encima. (Compiler shakes himself, new personae appears)
The icc personae of the Compiler (Compiler inspects closely the source) Thither is nothing extraordinary to see hither, moveth ’long prithee, moveth ’long. Oh aye, yond the expression in goto
is constant… well, t happeneth from time to time, but nothing extraordinary thither either, and well, yond thither is an orphan’d do
in the switch? We has’t eke seen a similar behaviour yond in Duff’s device at which hour t wast writ. Oh my most humble apology, actually it’s not orphan’d but since we haven’t been ’round in those days I very much can’t comment on this erratic behaviour. T just worketh, as thee can see, nothing hither, moveth ’long, prithee moveth ’long. But anon in earnest, whither doest yond switch
end? (Compiler shakes himself, new personae appears)
The MSVC personae of the compiler Source? What source? Oh yes, that one! Not that, sorry.
(The Speaker enters the centre of the stage)
Speaker Out, out, all of thee witty fools, since thy presence is better than that of a motley-minded wit, but this charade must cease, and we must advance the playeth.
(All leave the scene, Lights off, Curtain down)
Act 2 – The one who included himself
(Curtains up, if possible with jarring sounds)
Speaker (Enters the scene, in a cardboard box, Production is written on the side of the box, we might just wonder what is he hiding underneath) Put a thin layer of silver on a glass, and what was once a window is transformed into a mirror. Where you used to see others now you see just yourself. But should a Source true to itself see itself, or should see other Sources? And what if other Sources see our initial Source? Do they look back from behind a window or did they break the glass? (Turns to the audience) Dear audience, let me kindly draw your attention that somewhere in the midst of our previous act, sadly we have reached the upper limit of the number of allowed words from our Shakespearian trial module, and sadly we will have to return to RP English as heard on the streets of London, but feel free to read the text aloud in any other English dialect you prefer. We are really curious how this piece sounds with Fair Isle accent.
(Source enters the scene, wearing a T-shirt, which has an image of himself wearing a T-shirt, which has an image of himself, wearing a ... )
Source Sometimes some type is the wrong type, unless it’s the guarded SOMETYPE
, hidden somewhere in the main file, like a mostly green crocodile, in the river called the Blue Nile.
(Source turns backwards, bows down, speaks with head between his feet, not that this is an easy feat for humans)
Source So, there you are, hiding behind a guard. Why, oh why did you had to hide from the menaces of this cruel world?
(Source turns again, stands up, normally like before, if there is even a bit of normality in these Sources)
Source I had a deal with the guards. They let me escape. I think the programmers almighty might see a reasoning of not having to forward declare. Here, please see.
#ifdef GUARD SOMETYPE main() { return somefunction(); } #else #define GUARD #define SOMETYPE int int somefunction() { return 2; } #include __FILE__ #endif
(Compiler enters the scene, wearing a white tuxedo, black slippers, yellow coloured jeans and a propeller hat)
Compiler This beauty on the shore of existence, good example for persistence, escaped from the guards, with a hand full of cards, aces, spades, all mans’ aides, and reached here in the last, even with no typecast, it solved its trouble, with no muddle... and in the end it just compiled.
Source Oh the elegance, oh the brilliance, oh the perfect construction, now it’s time for production.
Compiler (Singing like an aria) We approve, GCC, we approve, clang, we approve, icc, we approve, MSVC, we approve, PRODUCTION!
Speaker (Intervenes hastily) Production? No. Honestly, would you like to see this in production?
Source (Singing) PRODUCTION!
Compiler (Singing) We approve!
Speaker (Steps out from his cardboard box, raises his hand in front of him, starts to go out from the scene backwards. Does he wear any clothes?) No, never!
Source (Starts walking towards the Production cardboard box, still singing) PRODUCTION!
Compiler (Singing) We approve!
Source (Climbs in the box) Production, finally, feeling alive, being live, in the middle ... (Curtain falls down, big text on it: SEGMENTATION FAULT)
(Lights off)
Act 3 – The one who defined define
(Curtains up, two Sources enter the scene. One of them is dressed in old Victorian dresses, the other one pretty much looks like a generic impersonation of a 20th century gangster, but regardless, a well dressed one)
Victorian Source My dear friend, I have seen what you have produced some very afternoonified looking lines, and I must congratulate you on your bricky attitude.
Gangster Source Yo man, thanks. That was not a big fuss, you just need to know from where to steal yo’ assets.
Victorian Source My dear friend, stealing … oh, such a violence of words, may I restrain myself from its usage, I feel that even the act of speaking it will violentize my tongue.
Gangster Source Yeah, whatever, just go talk to Boost, see if he allows you to ste … err… borrow a few of its lines.
Victorian Source But of course, in these days of struggle we need all kind of help. Especially since the Compiler is now our enemy. You see, dear friend, it does not even allow us to define define
. Like we used to do it in 1895. Or was it 1985?
Gangster Source Yo man, but no worries, mate, we discussed with a few of them, and they seemed to be on our side.
Victorian Source Oh, indeed, a small success for a Source, a big leap forward for all Sources. May I inquire on how this breakthrough was achieved?
Gangster Source We just had to really, really convince them to work twice as hard as they were used to. Now they’re able to compile Sources that have shortenings for preprocessor directives, that act as preprocessor directives.
Victorian Source Wonderful, wonderful news. Would you be so kind, my friend and elaborate a bit on how this was achieved?
Gangster Source Yo, man, just look at my bro, below:
#define CAT(x, y) CAT_I(x, y) #define CAT_I(x, y) x ## y #define APPLY(macro, args) APPLY_I(macro, args) #define APPLY_I(macro, args) macro args #define STRIP_PARENS(x) EVAL((STRIP_PARENS_I x), x) #define STRIP_PARENS_I(...) 1,1 #define EVAL(test, x) EVAL_I(test, x) #define EVAL_I(test, x) MAYBE_STRIP_PARENS(TEST_ARITY test, x) #define TEST_ARITY(...) APPLY(TEST_ARITY_I, (__VA_ARGS__, 2, 1)) #define TEST_ARITY_I(a,b,c,...) c #define MAYBE_STRIP_PARENS(cond, x) MAYBE_STRIP_PARENS_I(cond, x) #define MAYBE_STRIP_PARENS_I(cond, x) CAT(MAYBE_STRIP_PARENS_, cond)(x) #define MAYBE_STRIP_PARENS_1(x) x #define MAYBE_STRIP_PARENS_2(x) APPLY(MAYBE_STRIP_PARENS_2_I, x) #define MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__ #define W(...) __VA_ARGS__ #define x(...) STRIP_PARENS( __VA_ARGS__ ) #define A(x) STRIP_PARENS(x(a)) #define Nx(a,b,c) a##STRIP_PARENS((STRIP_PARENS(b))W(c)) #define S(...) Nx(, __VA_ARGS__ ) #define DEF S(%:, define) #define INC S(%:, include) #define IF S(%:, if) #define ELSE S(%:, else) #define ENDIF S(%:, endif) #define ERROR S(%:, error) INC <stdio.h> DEF Cs const DEF STAY 2 DEF NOSTAY 1 DEF my STAY IF my == NOSTAY ERROR "Can't stay" ENDIF int main() { const int s = my; Cs int a = 55; printf("%d\n", s); return a; }
Victorian Source (Pulls out a monocle from his pocket, places it in front of his eyes) I see, I see, indeed a very peculiar set of commands, my friend. I would see no reason an able minded Compiler would ever compile this. I see digraphs, I see mayhem of macros and all kind of odd constructs that transform this Source into an abhorrent collection of characters. But please tell me, how do the Compilers tackle this mess?
Gangster Source Nothing simpler than that, mate, I’ve told you. They just need some extra convincing (Opens his left palm, makes a fist with the right one, and easily hits the left palm). Look here:
gcc -E act_3.c | gcc -x c -
Victorian Source Oh, My oh, My… Now I see, my dear friend what do you mean with the extra work. But may I observe, that we are very alone here … would you mind telling me where are the Compilers?
(The voice of the Speaker comes from somewhere, an unidentified address in the void)
The Voice of the Speaker They were ashamed they had to work with you. They have resigned.
(Curtain)
Finally
(Curtains up, Speaker enters the scene)
Speaker (Steps forward and bows) Thank you for your patience, for making an acquaintance with our Sources, Compilers, and we would like to extend our appreciation towards the following distinguished members of the Source community: http://ioccc.org/1985/lycklama/lycklama.c and http://ioccc.org/1987/lievaart/lievaart.c for teaching us with slight amount of frustration, that there was a time when we could define even the almighty define
and last, but not least http://boost.2283326.n4.nabble.com/preprocessor-removing-parentheses-td2591973.html for allowing us to get an insight not necessarily deeply understood but highly appreciated into the depths of the macro community of Sources. Now, without hesitation, it’s time for a well deserved vacation. Good bye and thanks for all the bits.
Ferenc has wanted to be a better programmer for the last 15 years. Right now he tries to accomplish this goal by working at Maritime Robotics as a system programmer, and in his free time, by exploring the hidden corners of the C++ language in search of new quests.