Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Google   


C Humor

Humor Chronicle Programming Language Humor Top 10 Classic Unix Humor Softpanorama Humor Archive Larry Wall & Perl RMS Linus Torvalds
 C  C++ Assembler Perl Shell Java Debugging
Admin Algorithms  Networking Solaris Scripting Linux Editors
skeptical humor OFM Humor   SE   vi Viruses Eric Raymond GPL

Check out this program

It's a small C program. I know, I know, it doesn't look like it's gonna get compiled, but believe me, it does. Try to guess this program's output, then try to run it. You'll be amazed to see what it does!

Here's the program in a normal text file .

#include <stdio.h>
main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_,
main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13?
main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l+,/n{n+,/+#n+,/#\
;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \
q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# \
){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \
iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \
;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \
}'+}##(!!/")
:t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1)
  :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a,
"!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}

How to Program in C/The Ten Commandments for C Programmers

  1. Thou shalt run lint frequently and study its pronouncements with care, for verily its perception and judgement oft exceed thine.
  2. Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end.
  3. Thou shalt cast all function arguments to the expected type if they are not of that type already, even when thou art convinced that this is unnecessary, lest they take cruel vengeance upon thee when thou least expect it.
  4. If thy header files fail to declare the return types of thy library functions, thou shalt declare them thyself with the most meticulous care, lest grievous harm befall thy program.
  5. Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
  6. If a function be advertised to return an error code in the event of difficulties, thou shalt check for that code, yea, even though the checks triple the size of thy code and produce aches in thy typing fingers, for if thou thinkest ``it cannot happen to me'', the gods shall surely punish thee for thy arrogance.
  7. Thou shalt study thy libraries and strive not to reinvent them without cause, that thy code may be short and readable and thy days pleasant and productive.
  8. Thou shalt make thy program's purpose and structure clear to thy fellow man by using the One True Brace Style, even if thou likest it not, for thy creativity is better used in solving problems than in creating beautiful new impediments to understanding.
  9. Thy external identifiers shall be unique in the first six characters, though this harsh discipline be irksome and the years of its necessity stretch before thee seemingly without end, lest thou tear thy hair out and go mad on that fateful day when thou desirest to make thy program run on an old system.
  10. Thou shalt foreswear, renounce, and abjure the vile heresy which claimeth that ``All the world's a VAX'', and have no commerce with the benighted heathens who cling to this barbarous belief, that the days of thy program may be long even though the days of thy current machine be short.

Addendum - How to write in C


Addendum - How to debug C code

 

Another version of "Write in C"

 

The Real Programmer Stories

COMPUTERWORLD 1 April

                     CREATORS ADMIT UNIX, C HOAX

    In an announcement that has stunned the computer industry, Ken Thompson,
    Dennis Ritchie and Brian Kernighan admitted that the Unix operating
    system and C programming language created by them is an elaborate April
    Fools prank kept alive for over 20 years.  Speaking at the recent
    UnixWorld Software Development Forum, Thompson revealed the following:

    "In 1969, AT&T had just terminated their work with the GE/Honeywell/AT&T
    Multics project. Brian and I had just started working with an early
    release of Pascal from Professor Nichlaus Wirth's ETH labs in
    Switzerland and we were impressed with its elegant simplicity and
    power. Dennis had just finished reading 'Bored of the Rings', a
    hilarious National Lampoon parody of the great Tolkien 'Lord of the
    Rings' trilogy. As a lark, we decided to do parodies of the Multics
    environment and Pascal. Dennis and I were responsible for the operating
    environment. We looked at Multics and designed the new system to be as
    complex and cryptic as possible to maximize casual users' frustration
    levels, calling it Unix as a parody of Multics, as well as other more
    risque allusions. Then Dennis and Brian worked on a truly warped
    version of Pascal, called 'A'. When we found others were actually
    trying to create real programs with A, we quickly added additional
    cryptic features and evolved into B, BCPL and finally C. We stopped
    when we got a clean compile on the following syntax:

    for(;P("\n"),R-;P("|"))for(e=C;e-;P("_"+(*u++/8)%2))P("| "+(*u/4)%2);

    To think that modern programmers would try to use a language that
    allowed such a statement was beyond our comprehension!  We actually
    thought of selling this to the Soviets to set their computer science
    progress back 20 or more years. Imagine our surprise when AT&T and
    other US corporations actually began trying to use Unix and C!  It has
    taken them 20 years to develop enough expertise to generate even
    marginally useful applications using this 1960's technological parody,
    but we are impressed with the tenacity (if not common sense) of the
    general Unix and C programmer.  In any event, Brian, Dennis and I have
    been working exclusively in Pascal on the Apple Macintosh for the past
    few years and feel really guilty about the chaos, confusion and truly
    bad programming that have resulted from our silly prank so long ago."

    Major Unix and C vendors and customers, including AT&T, Microsoft,
    Hewlett-Packard, GTE, NCR, and DEC have refused comment at this time.
    Borland International, a leading vendor of Pascal and C tools,
    including the popular Turbo Pascal, Turbo C and Turbo C++, stated they
    had suspected this for a number of years and would continue to enhance
    their Pascal products and halt further efforts to develop C.  An IBM
    spokesman broke into uncontrolled laughter and had to postpone a
    hastily convened news conference concerning the fate of the RS-6000,
    merely stating 'VM will be available Real Soon Now'.  In a cryptic
    statement, Professor Wirth of the ETH institute and father of the
    Pascal, Modula 2 and Oberon structured languages, merely stated that P.
    T. Barnum was correct.

    In a related late-breaking story, usually reliable sources are stating
    that a similar confession may be forthcoming from William Gates
    concerning the MS-DOS and Windows operating environments.  And IBM
    spokesman have begun denying that the Virtual Machine (VM) product is
    an internal prank gone awry.
    {COMPUTERWORLD 1 April}
    {contributed by Bernard L. Hayes}

 

Computer songs and poems C Hacker in Paradise

Tried to amend my low-level habits
started learning Ada last fall
Writing tasks with conditional rendez-vous calls
Raising lots'a exceptions and handling them all
But at night I had these wonderful dreams
some kind of sensuous treat
Not of subtypes or generics or packages
but of function pointers and binary trees

( I was a...)
C hacker in paradise
putting my flags in an integer slice
Using K&R to be more precise
I'm just a C hacker in paradise

Heard about some of our managers
they want to do everything with a tool
Classes you browse by clicking with the mouse
Well it reminds me of some stuff I saw in primary school!
But I am not so easy to break;
When I'm at work I keep fighting back
Not with methods, drag-and-drop or a Hypercard stack
But with that miracle language in which I hack!

C hacker in paradise
writing code that's already optimized
putting my flags in an integer slice
I'm just a C hacker in paradise

I write all my functions with recursion
using implicit pointer conversion
Back with a longjmp and then a goto
Oh, good God almighty which way should I go

to be a
C hacker in paradise
Making all operations bitwise
Writing right onto the raw device
Yes, I'm a
C hacker in paradise
I'll be a
C hacker in paradise
I'm just a
C hacker in paradise

I write all ...

C hacker in paradise ....

Computer songs and poems Coding In C

I'd like to be coding in C
In the Sun Computer lab in the shade
Stay up all night, program it right
In a Sun Computer lab in the shade

I'd ask my friends to program C
in the computer lab with me
I'd like to be coding in C
In a Sun Computer lab in the shade.

We've never done using the Sun
In our little hideaway making lots of fun.
banking our head until we're dead.
In a Sun Computer lab in the shade


Copyright © 1996-2007 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: February 28, 2008