时间:13-06-25 栏目:技术文章 作者:炫酷网站设计建设 评论:0 点击: 463 次
这篇趣文有一定历史了,应该至少有 10 年了。
PS:亮点总是在最后。:)
初中/高中(注:Basic)
1 |
10 PRINT "HELLO WORLD" |
2 |
20 END |
大一(注:Pascal)
1 |
program Hallo(output); |
2 |
begin |
3 |
writeln ( 'Hello, world!' ) |
4 |
end . |
大三/大四
1 |
(defun hello |
2 |
(print |
3 |
(cons 'Hello (list 'World)))) |
入职第一年
01 |
#include <stdio.h> |
02 |
void main( void ) |
03 |
{ |
04 |
char *message[] = { "Hello " , "World" }; |
05 |
int i; |
06 |
07 |
for (i = 0; i < 2; ++i) |
08 |
printf ( "%s" , message[i]); |
09 |
printf ( "\n" ); |
10 |
} |
入职干了几年
01 |
#include <iostream.h> |
02 |
#include <string.h> |
03 |
04 |
class string |
05 |
{ |
06 |
private : |
07 |
int size; |
08 |
char *ptr; |
09 |
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 |
} |
大师程序员
001 |
[ |
002 |
uuid (2573F8F4-CFEE-101A-9A9F-00AA00342820) |
003 |
] |
004 |
library LHello |
005 |
{ |
006 |
// bring in the master library |
007 |
importlib( "actimp.tlb" ); |
008 |
importlib( "actexp.tlb" ); |
009 |
010 |
// bring in my interfaces |
011 |
#include "pshlo.idl" |
012 |
013 |
[ |
014 |
uuid (2573F8F5-CFEE-101A-9A9F-00AA00342820) |
015 |
] |
016 |
cotype THello |
017 |
{ |
018 |
interface IHello; |
019 |
interface IPersistFile; |
020 |
}; |
021 |
}; |
022 |
023 |
[ |
024 |
exe, |
025 |
uuid (2573F890-CFEE-101A-9A9F-00AA00342820) |
026 |
] |
027 |
module CHelloLib |
028 |
{ |
029 |
030 |
// some code related header files |
031 |
importheader(<windows.h>); |
032 |
importheader(<ole2.h>); |
033 |
importheader(<except.hxx>); |
034 |
importheader( "pshlo.h" ); |
035 |
importheader( "shlo.hxx" ); |
036 |
importheader( "mycls.hxx" ); |
037 |
038 |
// needed typelibs |
039 |
importlib( "actimp.tlb" ); |
040 |
importlib( "actexp.tlb" ); |
041 |
importlib( "thlo.tlb" ); |
042 |
043 |
[ |
044 |
uuid (2573F891-CFEE-101A-9A9F-00AA00342820), |
045 |
aggregatable |
046 |
] |
047 |
coclass CHello |
048 |
{ |
049 |
cotype THello; |
050 |
}; |
051 |
}; |
052 |
053 |
#include "ipfix.hxx" |
054 |
055 |
extern HANDLE hEvent; |
056 |
057 |
class CHello : public CHelloBase |
058 |
{ |
059 |
public : |
060 |
IPFIX(CLSID_CHello); |
061 |
062 |
CHello(IUnknown *pUnk); |
063 |
~CHello(); |
064 |
065 |
HRESULT __stdcall PrintSz( LPWSTR pwszString); |
066 |
067 |
private : |
068 |
static int cObjRef; |
069 |
}; |
070 |
071 |
#include <windows.h> |
072 |
#include <ole2.h> |
073 |
#include <stdio.h> |
074 |
#include <stdlib.h> |
075 |
#include "thlo.h" |
076 |
#include "pshlo.h" |
077 |
#include "shlo.hxx" |
078 |
#include "mycls.hxx" |
079 |
080 |
int CHello::cObjRef = 0; |
081 |
082 |
CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk) |
083 |
{ |
084 |
cObjRef++; |
085 |
return ; |
086 |
} |
087 |
088 |
HRESULT __stdcall CHello::PrintSz( LPWSTR pwszString) |
089 |
{ |
090 |
printf ("%ws |
091 |
", pwszString); |
092 |
return (ResultFromScode(S_OK)); |
093 |
} |
094 |
095 |
CHello::~CHello( void ) |
096 |
{ |
097 |
098 |
// when the object count goes to zero, stop the server |
099 |
cObjRef--; |
100 |
if ( cObjRef == 0 ) |
101 |
PulseEvent(hEvent); |
102 |
103 |
return ; |
104 |
} |
105 |
106 |
#include <windows.h> |
107 |
#include <ole2.h> |
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 <windows.h> |
160 |
#include <ole2.h> |
161 |
#include <stdlib.h> |
162 |
#include <string.h> |
163 |
#include <stdio.h> |
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 |
} |
新手黑客
01 |
#!/usr/local/bin/perl |
02 |
$msg = "Hello, world.\n" ; |
03 |
if ($ #ARGV >= 0) { |
04 |
while ( defined ( $arg = shift ( @ARGV ))) { |
05 |
$outfilename = $arg ; |
06 |
open (FILE, ">" . $outfilename ) || die "Can't write $arg: $!\n" ; |
07 |
print (FILE $msg ); |
08 |
close (FILE) || die "Can't close $arg: $!\n" ; |
09 |
} |
10 |
} else { |
11 |
print ( $msg ); |
12 |
} |
13 |
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 |
声明: 本文由( 炫酷网站设计建设 )原创编译,转载请保留链接: 趣文:程序员的进化史