趣文:程序员的进化史

开发 项目管理
这篇趣文有一定历史了,应该至少有 10 年了。

这篇趣文有一定历史了,应该至少有 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 <stdio.h> 
  2. void main(void
  3.   char *message[] = {"Hello ""World"}; 
  4.   int i; 
  5.   
  6.   for(i = 0; i < 2; ++i) 
  7.     printf("%s", message[i]); 
  8.   printf("\n"); 

入职干了几年

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

 

大师程序员

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

#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. 1; 

 

有经验的黑客

  1. #include <stdio.h> 
  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://blog.jobbole.com/41944/

 

责任编辑:陈四芳 来源: 伯乐在线
相关推荐

2018-08-22 17:58:01

数据平台数据仓库架构

2013-04-17 10:28:40

程序员

2013-06-20 08:55:38

2016-02-04 09:17:59

2011-12-21 16:44:00

信息图手机进化史

2012-09-29 10:54:10

程序员谎话Quora

2013-07-15 14:11:13

程序员

2014-09-01 16:29:34

2011-09-01 09:34:21

架构

2011-11-29 09:54:20

Google进化史

2010-07-27 14:04:52

2011-11-03 15:25:07

Android

2010-10-09 14:46:20

2018-03-23 12:20:25

数据中心网络数据

2013-10-17 11:15:19

2010-04-07 14:54:20

Unix操作系统

2014-01-08 09:26:05

程序员招聘

2022-03-25 14:01:20

元宇宙虚拟世界进化

2023-11-27 09:23:19

2022-03-29 09:35:15

FirefoxUI浏览器
点赞
收藏

51CTO技术栈公众号