|
<pre><u><b>High School/Jr.High</b></u></pre>
<pre>10 PRINT «HELLO WORLD»
20 END</pre>
<pre><u><b>First year in College</b></u>
</pre>
<pre>program Hello(input, output)
begin
writeln('Hello World')
end.</pre>
<pre><u><b>Senior year in College</b></u></pre>
<pre>(defun hello
(print
(cons 'Hello (list 'World))))</pre>
<pre><u><b>New professional</b></u></pre>
<pre>#include <stdio>
void main(void)
{
char *message[] = {«Hello «, «World»};
int i;</pre>
<pre> for(i = 0; i < 2; ++i)
printf(«%s», message[i]);
printf(«\n»);
}</pre>
<pre><u><b>Seasoned professional</b></u></pre>
<pre>#include <iostream>
#include <string></pre>
<pre>class string
{
private:
int size;
char *ptr;</pre>
<pre>public:
string() : size(0), ptr(new char('\0')) {}</pre>
<pre> string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}</pre>
<pre> ~string()
{
delete [] ptr;
}</pre>
<pre> friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);
};</pre>
<pre>ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}</pre>
<pre>string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}</pre>
<pre>int main()
{
string str;</pre>
<pre> str = «Hello World»;
cout << str << endl;</pre>
<pre> return(0);
}</pre>
<pre><u><b>Master Programmer</b></u></pre>
<pre>[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
{
// bring in the master library
importlib(«actimp.tlb»);
importlib(«actexp.tlb»);</pre>
<pre> // bring in my interfaces
#include «pshlo.idl»</pre>
<pre> [
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};</pre>
<pre>[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{</pre>
<pre> // some code related header files
importheader(<windows>);
importheader(<ole2>);
importheader(<except>);
importheader(«pshlo.h»);
importheader(«shlo.hxx»);
importheader(«mycls.hxx»);</pre>
<pre> // needed typelibs
importlib(«actimp.tlb»);
importlib(«actexp.tlb»);
importlib(«thlo.tlb»);</pre>
<pre> [
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclass CHello
{
cotype THello;
};
};
</pre>
<pre>#include «ipfix.hxx»</pre>
<pre>extern HANDLE hEvent;</pre>
<pre>class CHello : public CHelloBase
{
public:
IPFIX(CLSID_CHello);</pre>
<pre> CHello(IUnknown *pUnk);
~CHello();</pre>
<pre> HRESULT __stdcall PrintSz(LPWSTR pwszString);</pre>
<pre>private:
static int cObjRef;
};
</pre>
<pre>#include <windows>
#include <ole2>
#include <stdio>
#include <stdlib>
#include «thlo.h»
#include «pshlo.h»
#include «shlo.hxx»
#include «mycls.hxx»</pre>
<pre>int CHello::cObjRef = 0;</pre>
<pre>CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
{
cObjRef++;
return;
}</pre>
<pre>HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
{
printf(«%ws\n», pwszString);
return(ResultFromScode(S_OK));
}
</pre>
<pre>CHello::~CHello(void)
{</pre>
<pre>// when the object count goes to zero, stop the server
cObjRef--;
if( cObjRef == 0 )
PulseEvent(hEvent);</pre>
<pre>return;
}</pre>
<pre>#include <windows>
#include <ole2>
#include «pshlo.h»
#include «shlo.hxx»
#include «mycls.hxx»</pre>
<pre>HANDLE hEvent;</pre>
<pre> int _cdecl main(
int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();</pre>
<pre>hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);</pre>
<pre>// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);</pre>
<pre>CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);</pre>
<pre>// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);</pre>
<pre>// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF->Release();</pre>
<pre>// Tell OLE we are going away.
CoUninitialize();</pre>
<pre>return(0);
}</pre>
<pre>extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;</pre>
<pre>CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};</pre>
<pre>UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};</pre>
<pre>#include <windows>
#include <ole2>
#include <stdlib>
#include <string>
#include <stdio>
#include «pshlo.h»
#include «shlo.hxx»
#include «clsid.h»</pre>
<pre>int _cdecl main(
int argc,
char * argv[]
) {
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];</pre>
<pre>// get object path
wcsPath[0] = '\0';
wcsT[0] = '\0';
if( argc > 1) {
mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, «Object path must be specified\n»);
return(1);
}</pre>
<pre>// get print string
if(argc > 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
else
wcscpy(wcsT, L»Hello World»);</pre>
<pre>printf(«Linking to object %ws\n», wcsPath);
printf(«Text String %ws\n», wcsT);</pre>
<pre>// Initialize the OLE libraries
hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);</pre>
<pre>if(SUCCEEDED(hRslt)) {
</pre>
<pre> hRslt = CreateFileMoniker(wcsPath, &pmk);
if(SUCCEEDED(hRslt))
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);</pre>
<pre> if(SUCCEEDED(hRslt)) {</pre>
<pre> // print a string out
pHello->PrintSz(wcsT);</pre>
<pre> Sleep(2000);
ulCnt = pHello->Release();
}
else
printf(«Failure to connect, status: %lx», hRslt);</pre>
<pre> // Tell OLE we are going away.
CoUninitialize();
}</pre>
<pre>return(0);
}</pre>
<pre><u><b>Apprentice Hacker</b></u></pre>
<pre> #!/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;</pre>
<pre><u><b>Experienced Hacker</b></u></pre>
<pre> #include <stdio>
#define S «Hello, World\n»
main(){exit(printf(S) == strlen(S) ? 0 : 1);}</pre>
<pre><u><b>Seasoned Hacker</b></u></pre>
<pre> % cc -o a.out ~/src/misc/hw/hw.c
% a.out</pre>
<pre><u><b>Guru Hacker</b></u></pre>
<pre> % echo «Hello, world.»</pre>
<pre><u><b>New Manager</b></u></pre>
<pre> 10 PRINT «HELLO WORLD»
20 END</pre>
<pre><u><b>Middle Manager</b></u></pre>
<pre> mail -s «Hello, world.» bob@b12
Bob, could you please write me a program that prints «Hello, world.»?
I need it by tomorrow.
^D</pre>
<pre><u><b>Senior Manager</b></u></pre>
<pre> % zmail jim
I need a «Hello, world.» program by this afternoon. </pre>
<pre><u><b>Chief Executive</b></u></pre>
<pre> % letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout</pre>
|