幽默:程序员的进化 | 酷壳 - CoolShell.cn

来源:百度文库 编辑:神马文学网 时间:2024/04/28 16:30:39

幽默:程序员的进化

2009年3月14日2,049 次点击 阅读评论 发表评论

高中时期

view plaincopy to clipboardprint?
  1. 10 PRINT "HELLO WORLD"  
  2. 20 END  

大学新生

view plaincopy to clipboardprint?
  1. program Hello(input, output)   
  2.   begin  
  3.     writeln(\'Hello World\')   
  4.   end.  


高年级大学生

view plaincopy to clipboardprint?
  1. #include    
  2.   
  3. int main(void)   
  4. {   
  5.    printf("Hello, world!\\n");   
  6.    return 0;   
  7. }  

职业新手

view plaincopy to clipboardprint?
  1. #include    
  2. void main(void)   
  3. {   
  4.   char *message[] = {"Hello ", "World"};   
  5.   int i;   
  6.   
  7.   for(i = 0; i < 2; ++i)   
  8.     printf("%s", message[i]);   
  9.   printf("\\n");   
  10. }  

职业老手

view plaincopy to clipboardprint?
  1.  #include    
  2.  #include    
  3. using namespace std;   
  4.   
  5.  class string   
  6.  {   
  7.  private:   
  8.    int size;   
  9.    char *ptr;   
  10.   
  11.  string() : size(0), ptr(new char[1]) { ptr[0] = 0; }   
  12.   
  13.    string(const string &s) : size(s.size)   
  14.    {   
  15.      ptr = new char[size + 1];   
  16.      strcpy(ptr, s.ptr);   
  17.    }   
  18.   
  19.    ~string()   
  20.    {   
  21.      delete [] ptr;   
  22.    }   
  23.   
  24.    friend ostream &operator <<(ostream &, const string &);   
  25.    string &operator=(const char *);   
  26.  };   
  27.   
  28.  ostream &operator<<(ostream &stream, const string &s)   
  29.  {   
  30.    return(stream << s.ptr);   
  31.  }   
  32.   
  33.  string &string::operator=(const char *chrs)   
  34.  {   
  35.    if (this != &chrs)   
  36.    {   
  37.      delete [] ptr;   
  38.     size = strlen(chrs);   
  39.      ptr = new char[size + 1];   
  40.      strcpy(ptr, chrs);   
  41.    }   
  42.    return(*this);   
  43.  }   
  44.   
  45.  int main()   
  46.  {   
  47.    string str;   
  48.   
  49.    str = "Hello World";   
  50.    cout << str << endl;   
  51.   
  52.    return(0);   
  53.  }  

大师级

view plaincopy to clipboardprint?
  1.   [   
  2.   uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)   
  3.   ]   
  4.   library LHello   
  5.   {   
  6.       // bring in the master library   
  7.       importlib("actimp.tlb");   
  8.       importlib("actexp.tlb");   
  9.   
  10.       // bring in my interfaces   
  11.       #include "pshlo.idl"   
  12.   
  13.       [   
  14.       uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)   
  15.       ]   
  16.       cotype THello   
  17.    {   
  18.    interface IHello;   
  19.    interface IPersistFile;   
  20.    };   
  21.   };   
  22.   
  23.   [   
  24.   exe,   
  25.   uuid(2573F890-CFEE-101A-9A9F-00AA00342820)   
  26.   ]   
  27.   module CHelloLib   
  28.   {   
  29.   
  30.       // some code related header files   
  31.       importheader();   
  32.       importheader(   
  33. );   
  34.       importheader();   
  35.       importheader("pshlo.h");   
  36.       importheader("shlo.hxx");   
  37.       importheader("mycls.hxx");   
  38.   
  39.       // needed typelibs   
  40.       importlib("actimp.tlb");   
  41.       importlib("actexp.tlb");   
  42.       importlib("thlo.tlb");   
  43.   
  44.       [   
  45.       uuid(2573F891-CFEE-101A-9A9F-00AA00342820),   
  46.       aggregatable   
  47.       ]   
  48.       coclass CHello   
  49.    {   
  50.    cotype THello;   
  51.    };   
  52.   };   
  53.   
  54.   #include "ipfix.hxx"   
  55.   
  56.   extern HANDLE hEvent;   
  57.   
  58.   class CHello : public CHelloBase   
  59.   {   
  60.   public:   
  61.       IPFIX(CLSID_CHello);   
  62.   
  63.       CHello(IUnknown *pUnk);   
  64.       ~CHello();   
  65.   
  66.       HRESULT  __stdcall PrintSz(LPWSTR pwszString);   
  67.   
  68.   private:   
  69.       static int cObjRef;   
  70.   };   
  71.   
  72.   #include    
  73.   #include   
  74.   
  75.   #include    
  76.   #include    
  77.   #include "thlo.h"   
  78.   #include "pshlo.h"   
  79.   #include "shlo.hxx"   
  80.   #include "mycls.hxx"   
  81.   
  82.   int CHello::cObjRef = 0;   
  83.   
  84.   CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)   
  85.   {   
  86.       cObjRef++;   
  87.       return;   
  88.   }   
  89.   
  90.   HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)   
  91.   {   
  92.       printf("%ws  
  93. ", pwszString);   
  94.       return(ResultFromScode(S_OK));   
  95.   }   
  96.   
  97.   CHello::~CHello(void)   
  98.   {   
  99.   
  100.   // when the object count goes to zero, stop the server   
  101.   cObjRef--;   
  102.   if( cObjRef == 0 )   
  103.       PulseEvent(hEvent);   
  104.   
  105.   return;   
  106.   }   
  107.   
  108.   #include    
  109.   #include   
  110.   
  111.   #include "pshlo.h"   
  112.   #include "shlo.hxx"   
  113.   #include "mycls.hxx"   
  114.   
  115.   HANDLE hEvent;   
  116.   
  117.    int _cdecl main(   
  118.   int argc,   
  119.   char * argv[]   
  120.   ) {   
  121.   ULONG ulRef;   
  122.   DWORD dwRegistration;   
  123.   CHelloCF *pCF = new CHelloCF();   
  124.   
  125.   hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);   
  126.   
  127.   // Initialize the OLE libraries   
  128.   CoInitializeEx(NULL, COINIT_MULTITHREADED);   
  129.   
  130.   CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,   
  131.       REGCLS_MULTIPLEUSE, &dwRegistration);   
  132.   
  133.   // wait on an event to stop   
  134.   WaitForSingleObject(hEvent, INFINITE);   
  135.   
  136.   // revoke and release the class object   
  137.   CoRevokeClassObject(dwRegistration);   
  138.   ulRef = pCF->Release();   
  139.   
  140.   // Tell OLE we are going away.   
  141.   CoUninitialize();   
  142.   
  143.   return(0); }   
  144.   
  145.   extern CLSID CLSID_CHello;   
  146.   extern UUID LIBID_CHelloLib;   
  147.   
  148.   CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */  
  149.       0x2573F891,   
  150.       0xCFEE,   
  151.       0x101A,   
  152.       { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }   
  153.   };   
  154.   
  155.   UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */  
  156.       0x2573F890,   
  157.       0xCFEE,   
  158.       0x101A,   
  159.       { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }   
  160.   };   
  161.   
  162.   #include    
  163.   #include   
  164.   
  165.   #include    
  166.   #include    
  167.   #include    
  168.   #include "pshlo.h"   
  169.   #include "shlo.hxx"   
  170.   #include "clsid.h"   
  171.   
  172.   int _cdecl main(   
  173.   int argc,   
  174.   char * argv[]   
  175.   ) {   
  176.   HRESULT  hRslt;   
  177.   IHello        *pHello;   
  178.   ULONG  ulCnt;   
  179.   IMoniker * pmk;   
  180.   WCHAR  wcsT[_MAX_PATH];   
  181.   WCHAR  wcsPath[2 * _MAX_PATH];   
  182.   
  183.   // get object path   
  184.   wcsPath[0] = \'\\0\';  
  185.   wcsT[0] = \'\\0\';   
  186.   if( argc > 1) {   
  187.       mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);   
  188.       wcsupr(wcsPath);   
  189.       }   
  190.   else {   
  191.       fprintf(stderr, "Object path must be specified\\n");   
  192.       return(1);   
  193.       }   
  194.   
  195.   // get print string   
  196.   if(argc > 2)   
  197.       mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);   
  198.   else  
  199.       wcscpy(wcsT, L"Hello World");   
  200.   
  201.   printf("Linking to object %ws\\n", wcsPath);   
  202.   printf("Text String %ws\\n", wcsT);   
  203.   
  204.   // Initialize the OLE libraries   
  205.   hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);   
  206.   
  207.   if(SUCCEEDED(hRslt)) {   
  208.   
  209.       hRslt = CreateFileMoniker(wcsPath, &pmk);   
  210.       if(SUCCEEDED(hRslt))   
  211.    hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);   
  212.   
  213.       if(SUCCEEDED(hRslt)) {   
  214.   
  215.    // print a string out   
  216.    pHello->PrintSz(wcsT);   
  217.   
  218.    Sleep(2000);   
  219.    ulCnt = pHello->Release();   
  220.    }   
  221.       else  
  222.    printf("Failure to connect, status: %lx", hRslt);   
  223.   
  224.       // Tell OLE we are going away.   
  225.       CoUninitialize();   
  226.       }   
  227.   
  228.   return(0);   
  229.   }  

黑客学徒

  #!/usr/local/bin/perl$msg="Hello, world.\\n";if ($#ARGV >= 0) {while(defined($arg=shift(@ARGV))) {$outfilename = $arg;open(FILE, ">" . $outfilename) || die "Can\'t write $arg: $!\\n";print (FILE $msg);close(FILE) || die "Can\'t close $arg: $!\\n";}} else {print ($msg);}1;

有经验的黑客

view plaincopy to clipboardprint?
  1. #include    
  2. #define S "Hello, World\\n"   
  3. main(){exit(printf(S) == strlen(S) ? 0 : 1);}  

老练的黑客

  % cc -o a.out ~/src/misc/hw/hw.c% a.out

超级黑客

  % echo "Hello, world."

一线经理

view plaincopy to clipboardprint?
  1. 10 PRINT "HELLO WORLD"  
  2. 20 END  

中层经理

  mail -s "Hello, world." bob@b12Bob, could you please write me a program that prints "Hello, world."?I need it by tomorrow.^D

高级经理

  % zmail jimI need a "Hello, world." program by this afternoon.

首席执行官

  % letterletter: Command not found.% mailTo: ^X ^F ^C% help mailhelp: Command not found.% damn!!: Event unrecognized% logout