400-028-6601
建站资讯

网站建设资讯

为你提供网站建设行业资讯、网站优化知识、主机域名邮箱、网站开发常见问题等。

趣文:程序员的进化史

这篇趣文有一定历史了,应该至少有 10 年了。

公司主营业务:成都做网站、网站建设、外贸营销网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出莲花免费做网站回馈大家。

PS:亮点总是在最后。:)

初中/高中(注:Basic)

 
 
 
  1. 10 PRINT "HELLO WORLD" 
  2. 20 END 

大一(注:Pascal)

 
 
 
  1. (defun hello 
  2.   (print 
  3.     (cons 'Hello (list 'World)))) 

大三/大四

 
 
 
  1. program Hallo(output);   
  2.  
  3. begin   
  4.  
  5.     writeln('Hello, world!')   
  6.  
  7. end.  

入职第一年

 
 
 
  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. } 

入职干了几年

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

大师程序员

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

#p#

新手黑客

 
 
 
  1. #!/usr/local/bin/perl 
  2. $msg="Hello, world.\n"; 
  3. if ($#ARGV >= 0) { 
  4.   while(defined($arg=shift(@ARGV))) { 
  5.     $outfilename = $arg; 
  6.     open(FILE, ">" . $outfilename) || die "Can't write $arg: $!\n"; 
  7.     print (FILE $msg); 
  8.     close(FILE) || die "Can't close $arg: $!\n"; 
  9.   } 
  10. } else { 
  11.   print ($msg); 
  12. } 
  13. 1; 

有经验的黑客

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

入行干过好些年的黑客

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

黑客大师

 
 
 
  1. % echo "Hello, world." 

新手经理

 
 
 
  1. 10 PRINT "HELLO WORLD" 
  2. 20 END 

中级经理

 
 
 
  1. mail -s "Hello, world." bob@b12 
  2. 鲍勃,你能帮我写个输出“Hello, world.”的程序么? 
  3. 我明天就要。 
  4. 谢谢~ 

高级经理

 
 
 
  1. % zmail jim 
  2. Jim,我今天下午就要输出 “Hello, world.” 的程序! 

CEO/首席执行官

 
 
 
  1. % letter 
  2. letter: Command not found. 
  3. % mail 
  4. To: ^X ^F ^C 
  5. % help mail 
  6. help: Command not found. 
  7. % damn! 
  8. !: Event unrecognized 
  9. % logout 

本文标题:趣文:程序员的进化史
文章出自:http://hnjierui.cn/article/dhpcpoo.html

其他资讯