The Evolution of a Programmer
2009-03-28 14:09
477 查看
HighSchool/Jr.High(BASIC语言)
10PRINT"HELLOWORLD" 20END
FirstyearinCollege(pascal语言)
programHello(input,output) begin writeln('HelloWorld') end.
SenioryearinCollege(lisp语言)
(defunhello (print (cons'Hello(list'World))))
Newprofessional(如果你不知道这是什么语言,掌嘴!)
#include<stdio.h> voidmain(void) { char*message[]={"Hello","World"}; inti; for(i=0;i<2;++i) printf("%s",message[i]); printf("/n"); }
Seasonedprofessional(C++)
#include<iostream.h>
#include<string.h>
classstring
{
private:
intsize;
char*ptr;
string():size(0),ptr(newchar[1]){ptr[0]=0;}
string(conststring&s):size(s.size)
{
ptr=newchar[size+1];
strcpy(ptr,s.ptr);
}
~string()
{
delete[]ptr;
}
friendostream&operator<<(ostream&,conststring&);
string&operator=(constchar*);
};
ostream&operator<<(ostream&stream,conststring&s)
{
return(stream<<s.ptr);
}
string&string::operator=(constchar*chrs)
{
if(this!=&chrs)
{
delete[]ptr;
size=strlen(chrs);
ptr=newchar[size+1];
strcpy(ptr,chrs);
}
return(*this);
}
intmain()
{
stringstr;
str="HelloWorld";
cout<<str<<endl;
return(0);
}
MasterProgrammer(用C++调用COM技术)
[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
libraryLHello
{
//bringinthemasterlibrary
importlib("actimp.tlb");
importlib("actexp.tlb");
//bringinmyinterfaces
#include"pshlo.idl"
[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotypeTHello
{
interfaceIHello;
interfaceIPersistFile;
};
};
[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
moduleCHelloLib
{
//somecoderelatedheaderfiles
importheader(<windows.h>);
importheader(<ole2.h>);
importheader(<except.hxx>);
importheader("pshlo.h");
importheader("shlo.hxx");
importheader("mycls.hxx");
//neededtypelibs
importlib("actimp.tlb");
importlib("actexp.tlb");
importlib("thlo.tlb");
[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclassCHello
{
cotypeTHello;
};
};
#include"ipfix.hxx"
externHANDLEhEvent;
classCHello:publicCHelloBase
{
public:
IPFIX(CLSID_CHello);
CHello(IUnknown*pUnk);
~CHello();
HRESULT__stdcallPrintSz(LPWSTRpwszString);
private:
staticintcObjRef;
};
#include<windows.h>
#include<ole2.h>
#include<stdio.h>
#include<stdlib.h>
#include"thlo.h"
#include"pshlo.h"
#include"shlo.hxx"
#include"mycls.hxx"
intCHello::cObjRef=0;
CHello::CHello(IUnknown*pUnk):CHelloBase(pUnk)
{
cObjRef++;
return;
}
HRESULT__stdcallCHello::PrintSz(LPWSTRpwszString)
{
printf("%ws
",pwszString);
return(ResultFromScode(S_OK));
}
CHello::~CHello(void)
{
//whentheobjectcountgoestozero,stoptheserver
cObjRef--;
if(cObjRef==0)
PulseEvent(hEvent);
return;
}
#include<windows.h>
#include<ole2.h>
#include"pshlo.h"
#include"shlo.hxx"
#include"mycls.hxx"
HANDLEhEvent;
int_cdeclmain(
intargc,
char*argv[]
){
ULONGulRef;
DWORDdwRegistration;
CHelloCF*pCF=newCHelloCF();
hEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
//InitializetheOLElibraries
CoInitializeEx(NULL,COINIT_MULTITHREADED);
CoRegisterClassObject(CLSID_CHello,pCF,CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE,&dwRegistration);
//waitonaneventtostop
WaitForSingleObject(hEvent,INFINITE);
//revokeandreleasetheclassobject
CoRevokeClassObject(dwRegistration);
ulRef=pCF->Release();
//TellOLEwearegoingaway.
CoUninitialize();
return(0);}
externCLSIDCLSID_CHello;
externUUIDLIBID_CHelloLib;
CLSIDCLSID_CHello={/*2573F891-CFEE-101A-9A9F-00AA00342820*/
0x2573F891,
0xCFEE,
0x101A,
{0x9A,0x9F,0x00,0xAA,0x00,0x34,0x28,0x20}
};
UUIDLIBID_CHelloLib={/*2573F890-CFEE-101A-9A9F-00AA00342820*/
0x2573F890,
0xCFEE,
0x101A,
{0x9A,0x9F,0x00,0xAA,0x00,0x34,0x28,0x20}
};
#include<windows.h>
#include<ole2.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include"pshlo.h"
#include"shlo.hxx"
#include"clsid.h"
int_cdeclmain(
intargc,
char*argv[]
){
HRESULThRslt;
IHello*pHello;
ULONGulCnt;
IMoniker*pmk;
WCHARwcsT[_MAX_PATH];
WCHARwcsPath[2*_MAX_PATH];
//getobjectpath
wcsPath[0]='/0';
wcsT[0]='/0';
if(argc>1){
mbstowcs(wcsPath,argv[1],strlen(argv[1])+1);
wcsupr(wcsPath);
}
else{
fprintf(stderr,"Objectpathmustbespecified/n");
return(1);
}
//getprintstring
if(argc>2)
mbstowcs(wcsT,argv[2],strlen(argv[2])+1);
else
wcscpy(wcsT,L"HelloWorld");
printf("Linkingtoobject%ws/n",wcsPath);
printf("TextString%ws/n",wcsT);
//InitializetheOLElibraries
hRslt=CoInitializeEx(NULL,COINIT_MULTITHREADED);
if(SUCCEEDED(hRslt)){
hRslt=CreateFileMoniker(wcsPath,&pmk);
if(SUCCEEDED(hRslt))
hRslt=BindMoniker(pmk,0,IID_IHello,(void**)&pHello);
if(SUCCEEDED(hRslt)){
//printastringout
pHello->PrintSz(wcsT);
Sleep(2000);
ulCnt=pHello->Release();
}
else
printf("Failuretoconnect,status:%lx",hRslt);
//TellOLEwearegoingaway.
CoUninitialize();
}
return(0);
}
ApprenticeHacker(perl语言)
#!/usr/local/bin/perl
$msg="Hello,world./n";
if($#ARGV>=0){
while(defined($arg=shift(@ARGV))){
$outfilename=$arg;
open(FILE,">".$outfilename)||die"Can'twrite$arg:$!/n";
print(FILE$msg);
close(FILE)||die"Can'tclose$arg:$!/n";
}
}else{
print($msg);
}
1;
ExperiencedHacker(你应该能看懂这个程序)
#include<stdio.h>
#defineS"Hello,World/n"
main(){exit(printf(S)==strlen(S)?0:1);}
SeasonedHacker(cc是一个古老但仍有生命力的C语言编译器,语法和gcc相像(cc说:是gcc学的我!))
%cc-oa.out~/src/misc/hw/hw.c
%a.out
GuruHacker(echo是一个UnixShell脚本命令)
%echo"Hello,world."
NewManager(前面说了)
10PRINT"HELLOWORLD" 20END
MiddleManager(mail可能是Unix下最难用的EMail程序,但是最随处可见的)
mail-s"Hello,world."bob@b12
Bob,couldyoupleasewritemeaprogramthatprints"Hello,world."?
Ineeditbytomorrow.
^D
SeniorManager(zmail是比mail简单一些的EMail程序)
%zmailjim
Ineeda"Hello,world."programbythisafternoon.
ChiefExecutive(它在Unix的命令行下...)
%letter
letter:Commandnotfound.
To:^X^F^C
%helpmail
help:Commandnotfound.
%damn!
!:Eventunrecognized
%logout
相关文章推荐
- a joke---The Evolution of a Programmer
- The Evolution of a Programmer
- 一位程序员的演变历程(The Evolution of a Programmer)
- The Evolution of a Programmer
- The Evolution of a Programmer
- The Evolution of a Programmer
- The Evolution of a Programmer
- The joy of being a programmer
- [读书笔记]C++语言的设计与演化[The Design and Evolution of C++]
- The Symbian OS Architecture Sourcebook: Design and Evolution of a Mobile Phone OS
- Stability of the C++ ABI: Evolution of a Programming Language
- ON THE EVOLUTION OF MACHINE LEARNING: FROM LINEAR MODELS TO NEURAL NETWORKS
- The Evolution Of LINQ And Its Impact On The Design Of C#
- The evolution of cluster scheduler architectures--转
- What are some of the most basic things every programmer should know?
- 《The Evolution of Lua》翻译part 2
- 《The Evolution of Lua》读书笔记 1
- The Singular Secret of the Rockstar Programmer[成为编程巨星的唯一秘诀]
- The demise of the low level Programmer
- The evolution of self-defense technologies in malware