"Funny" Observations From (PERL) Programming Docs...

  • Thread starter Thread starter sbrothy
  • Start date Start date
  • Tags Tags
    Funny Programming
Click For Summary

Discussion Overview

The discussion revolves around humorous and peculiar observations from programming documentation, particularly focusing on Perl and the concept of obfuscated code in various programming languages. Participants share examples and anecdotes related to the quirks of programming languages and documentation, as well as contests that celebrate obfuscation in code.

Discussion Character

  • Exploratory
  • Debate/contested
  • Technical explanation

Main Points Raised

  • One participant humorously notes the irony of Perl documentation suggesting optimization flags that may introduce bugs instead.
  • Another participant mentions the International Obfuscated C Code Contest, highlighting its brain-melting entries and the existence of extremely compact chess engines like Toledo Nanochess.
  • Some participants express surprise at the existence of unusual programming languages, such as Brainfuck, and the concept of obfuscated code.
  • A participant shares their own experience with contributing to an unofficial obfuscated C++ contest, indicating a personal connection to the topic.
  • There is mention of a humorous link to "Writing Unmaintainable Code," which is intended to caution against poor coding practices while being written in a light-hearted manner.

Areas of Agreement / Disagreement

Participants share a general amusement regarding the quirks of programming documentation and obfuscated code, but there is no explicit consensus on the implications or value of these observations. Multiple competing views on the nature of obfuscation and its reception exist.

Contextual Notes

Participants reference specific examples and contests without resolving the broader implications of obfuscation in programming practices. The discussion includes personal anecdotes that may not be universally applicable.

Who May Find This Useful

This discussion may be of interest to programmers, computer science students, and those who enjoy exploring the humorous side of coding and programming languages.

sbrothy
Gold Member
Messages
1,427
Reaction score
1,290
So here I am slaving over Perl documentation (For my own pleasure I'm sad to say. I regard programming as LEGO for grownups) and I'm finding weird and funny things like:

o - pretend to optimize your code, but actually introduce bugs

I mean what is that about?

And perhaps less obvious:

[making] classes more readable:

Code:
/ [d-e g-i 3-7]/xx
/[ ! @ " # $ % ^ & * () = ? <> ' ]/xx

may be easier to grasp than the squashed equivalents:

Code:
/[d-eg-i3-7]/
/[!@"#$%^&*()=?<>']/

Well yes, it might :)

You have any even more crazy or funny examples from the amount of information I'm sure you people plow through on a daily basis? No matter the language.

Regards.
 
Technology news on Phys.org
sbrothy said:
You have any even more crazy or funny examples from the amount of information I'm sure you people plow through on a daily basis? No matter the language.
Ha! There is a whole contest called "The International Obfuscated C Code Contest"
https://www.ioccc.org/ Reading the winning entries can melt your brain.

You can also find examples on Wikipedia.
https://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest
Here's one.

Toledo Nanochess is a chess engine developed by Mexican Oscar Toledo Gutiérrez, a five-time winner of the IOCCC. In accordance with IOCCC rules, it is 1255 characters long. The author claims that it is the world's smallest chess program written in C.

The source code for Toledo Nanochess and other engines is available.[13] Because Toledo Nanochess is based on Toledo's winning entry from the 18th IOCCC (Best Game[14]), it is heavily obfuscated.[15]

On February 2, 2014, the author published the book Toledo Nanochess: The commented source code, which contains the fully commented source code.[16]

As of February 7, 2010, it appears to be one of only two chess engines written in less than 2 kilobytes of C that are able to play full legal chess moves, along with Micro-Max by Dutch physicist H. G. Muller. In 2014 the 1 kilobyte barrier was broken by Super Micro Chess[17] – a derivative of Micro-Max – totaling 760 characters (spaces and newlines included).[18] There is also a smaller version of Toledo's engine, the Toledo Picochess, consisting of 944 non-blank characters.
Source code excerpt

B,i,y,u,b,I[411],*G=I,x=10,z=15,M=1e4;X(w,c,h,e,S,s){int t,o,L,E,d,O=e,N=-M*M,K
=78-h<<x,p,*g,n,*m,A,q,r,C,J,a=y?-x:x;y^=8;G++;d=w||s&&s>=h&&v 0,0)>M;do{_ o=I[
p=O]){q=o&z^y _ q<7){A=q--&2?8:4;C=o-9&z?q["& .$ "]:42;do{r=I[p+=C[l]-64]_!w|p
==w){g=q|p+a-S?0:I+S _!r&(q|A<3||g)||(r+1&z^y)>9&&q|A>2){_ m=!(r-2&7))P G[1]=O,
K;J=n=o&z;E=I[p-a]&z;t=q|E-7?n:(n+=2,6^y);Z n<=t){L=r?l[r&7]*9-189-h-q:0 _ s)L
+=(1-q?l[p/x+5]-l[O/x+5]+l[p%x+6]*-~!q-l[O%x+6]+o/16*8:!m*9)+(q?0:!(I[p-1]^n)+
!(I[p+1]^n)+l[n&7]*9-386+!g*99+(A<2))+!(E^y^9)_ s>h||1<s&s==h&&L>z|d){p=n,O
=m?*g=*m,*m=0:g?*g=0:0;L-=X(s>h|d?0:p,L-N,h+1,G[1],J=q|A>1?0:p,s)_!(h||s-1|B
-O|i-n|p-b|L<-M))P y^=8,u=J;J=q-1|A<7||m||!s|d|r|o<z||v 0,0)>M;O=o;p=r;m?
*m=*g,*g=0:g?*g=9^y:0;}_ L>N){*G=O _ s>1){_ h&&c-L<0)P L _!h)i=n,B=O,b=p;}N=L;}
n+=J||(g=I+p,m=p<O?g-3:g+2,*m<z|m[O-p]||I[p+=p-O]);}}}}Z!r&q>2||(p=O,q|A>2|o>z&
!r&&++C*--A));}}}Z++O>98?O=20:e-O);P N+M*M&&N>-K+1924|d?N:0;}main(){Z++B<121)*G
++=B/x%x<2|B%x<2?7:B/x&4?0:*l++&31;Z B=19){Z B++<99)putchar(B%x?l[B|16]:x)_
x-(B=F)){i=I[B+=(x-F)*x]&z;b=F;b+=(x-F)*x;Z x-(*G=F))i=*G^8^y;}else v u,5);v u,
1);}}
 
  • Like
Likes   Reactions: sbrothy
I knew about the obfuscated C contest. I think I even made a meager contribution to an unofficial obfuscated C++ contest once. The chess thingy is new to me though. There are a lot of weird programing languages out there. Like brainfuck .

I was more nonplussed by (PERL) documentation admitting that it has a flag for optimizing your code which admittedly does the opposite!
 
sbrothy said:
I think I even made a meager contribution to an unofficial obfuscated C++ contest once.
My co-workers often enter my code to that contest.
 
  • Haha
  • Wow
Likes   Reactions: anorlunda, berkeman and sbrothy
Vanadium 50 said:
My co-workers often enter my code to that contest.

I actually found the thread:

C++ fun: obfuscated "Hello world!"

Mine is #59. Not exactly genius material but then again it was written on company time. :)

BTW: I found a link to Writing Unmaintainable Code in my footer. Off course it's purpose is to make people avoid these pitfalls. It's written, as the author says upfront, "tongue in cheek".
 
  • Like
Likes   Reactions: anorlunda