Monthly Archives: April 2011

ဆန္ဒနဲ့ ဘဝ

စာမျက်နှာ(၁) မူလတန်းကျောင်းသား

ဆန္ဒ = ဘဝ = ကစားချိန်မှာကစားမယ် အိပ်ချိန်မှာဝင်အိပ်မယ် အပူအပင်ကင်းတဲ့ ကလေးလေးဘဝ

စာမျက်နှာ(၂) အလယ်တန်းကျောင်းသား

ဆန္ဒ = ပန်းချီဆွဲတတ်ချင်တယ် စန္ဒယားတီးတတ်ချင်တယ်
ဘဝ = စာကျက်ချိန်မှာစာကျက်ရမယ် အားတဲ့အချိန်မှာ ကစားစရာအဖော်မရှိ ဖတ်စရာစာအုပ်တွေပဲရှိတဲ့ အိမ်လေးတစ်လုံး

စာမျက်နှာ(၃) အထက်တန်းကျောင်းသား

ဆန္ဒ = အဖေ့လိုဖြစ်ချင်တယ် အနည်းဆုံး အဖေ့ထက်မညံ့ပဲ အများဆုံး အဖေ့ထက်တော်ရမယ်
ဘဝ = အဖေ့လိုဖြစ်ချင်တဲ့ ဆန္ဒကိုဖျက်သိမ်းတယ် မတူညီတဲ့ဘဝကနေလဲ မညံ့အောင်ကြိုးစားနိုင်သလို ပိုတော်အောင်လည်း နေနိုင်တာပါပဲ မကျန်တော့တဲ့ အချိန်တစ်ခုအတွင်းမှာ အဝေးကိုထွက်မသွားနိုင်တော့ဘူး

စာမျက်နှာ(၄) တက္ကသိုလ်ကျောင်းသားဘဝ

ဆန္ဒ = ရွေးချယ်လိုက်တဲ့ နယ်ပယ်တစ်ခုမှာ တန်းတူကလွဲပြီး ငါ့ထက်တော်တဲ့လူမရှိတဲ့ အခြေအနေအထိ ရောက်ရမယ်
ဘဝ = ဆန္ဒတစ်ခုအတွက် ငယ်ရွယ်အချိန်၊ လွတ်လပ်မှု့၊ ပျော်ရွှင်မှု့ အားလုံးစွန့်လွှတ်လိုက်ရတယ် ထိပ်ဆုံးတော့ မရောက်ပေမယ့် အလယ်အလတ်တော့ကျော်ခဲ့တယ်။

စာမျက်နှာ(၅) လက်ရှိဘဝ

ဆန္ဒ = ဆန္ဒတစ်ခုတည်းအတွက် အရာရာရင်းနှီးခဲ့တဲ့ အချိန်တွေကိုပြန်ရချင်တယ် ဘယ်အရာမှ မထူးချွန်ချင်တော့ဘူး ဆန္ဒတွေအများကြီးနဲ့ မျှတတဲ့ဘဝကိုပဲ ပြန်တည်ဆောက်ခွင့် ရချင်မိတယ်
ဘဝ = ပျော်ချင်ပေမယ့် ပျော်ခွင့်ရချင်မှရမယ် နေချင်ပေမယ့် သွားချင်သွားရမယ် ကံအတိုင်းပဲ အဆင်သင့်သလို ဖြတ်သန်းနေတဲ့ဘဝ

မေကျော် Tag လုပ်သဖြင့်ရေးပါသည်။

Evolution of Programming Knowledge Level

တကယ်တော့ ပရိုဂရမ်ရေးတယ်ဆိုတာ လွယ်ပါတယ် သက်ဆိုင်ရာ Language ရဲ့ Syntax ကိုသိတာနဲ့ ရေးလို့ရပါပြီ တကယ်တည်ဆောက်ဖို့ လိုအပ်တာက ကိုယ်ပိုင်ဆိုင်တဲ့ Knowledge ပမာဏပါ။ ပရိုဂရမ်ရေးဆိုရင် များများရေးကြည့် များများတတ်တယ်လို့ ပြောတတ်ကြတယ် တစ်ကယ်တော့ အမြဲမမှန်ပါဘူး များများရေးတော့ Syntax ကိုပိုသိလာတယ် အဲဒါကြောင့် ရေးရလွယ်လာတယ် အဲဒါကိုခေါ်တာပါ။ ကိုယ်တိုင်တည်ဆောက်လို့မရတဲ့ Knowledge တွေအများကြီးရှိပါတယ် စပြီးလေ့လာကာစ လူတစ်ယောက်ကို if ကိုဘယ်လိုရေး for နဲ့ while ကိုဘယ်လိုသုံးဆိုပြီး အသုံးတတ်သွားအောင် လေ့ကျင့်ခိုင်းလို့ရပါတယ် ဒါပေမယ့် အဲဒါတွေထက် အဆင့်မြင့်တဲ့ Algorithm တွေကတော့ သက်ဆိုင်ရာ ဘာသာရပ်တွေကို လေ့လာမှသာ သိနိုင်ပါတယ် အရာအားလုံး ကိုယ်တိုင်တည်ဆောက်ယူဖို့ အချိန်မရှိသလို ဖြစ်လည်းမဖြစ်နိုင်ပါဘူး။ ပရိုဂရမ်စပြီးရေးတဲ့လူတိုင်း မြင်ဖူးတဲ့ Factorial ရှာတဲ့ ပရိုဂရမ်တစ်ခုကို မှတ်မိသလောက် ပြောင်းရေးထားပါတယ်။

Algorithm 1

1
2
3
4
5
6
7
8
#Prerequisites:
#What is factorial?
#!/usr/bin/python
def factorial1(num):
	fact = 1
	for x in range(2, num+1):
		fact = fact * x
	return fact

Algorithm 1 ကတော့အရှင်းလင်းဆုံးပါ ပရိုဂရမ်ရေးတာ စပြီးသင်တဲ့ ကျောင်းသားတွေကို Factorial ဆိုတာဘယ်လိုဆိုတာ ရှင်းပြပြီးတော့ တွက်တဲ့ပရိုဂရမ်ကို ရေးခိုင်းလေ့ရှိတယ် အခြေခံအနေနဲ့ operator, assign, loop အဲဒါတွေသိရင် ရေးလို့ရပါတယ် ရေးတဲ့လူဟာကိုယ်တိုင်ပဲ Logic ကို တည်ဆောက်ယူလို့ရပါတယ် အခြားလိုအပ်ချက်တွေမရှိပါဘူး။

Algorithm 2

1
2
3
4
5
6
7
8
#Prerequisites:
#1) Fundamental Data Structure
#2) Recursive Algorithm
#!/usr/bin/python
def factorial2(num):
	if num>2:
		return num * factorial2(num-1)
	return num

Algorithm 2 ကတော့ Factorial ဆိုတာဘာလဲသိရုံနဲ့ မလုံလောက်တော့ပါဘူး Algorithm ရေးပုံအမျိုးမျိုးနဲ့ သက်ဆိုင်တဲ့အရာတွေကို သိဖို့လိုအပ်ပါတယ်။ Recursive Algorithm Structure ဟာ အရေးပါပါတယ် အခြားခက်ခဲတဲ့ Algorithm တွေရဲ့အခြေခံလို့ ပြောလို့ရနိုင်ပါတယ်။ ဒီနေရာမှာ Recursive Algorithm အကြောင်းသိဖို့အတွက် သက်ဆိုင်ရာ ဘာသာရပ်ကိုမဖတ်ပဲ ကိုယ်တိုင်ပရိုဂရမ်ရေးရင်း တွေ့ရှိဖို့ဆိုတာမဖြစ်နိုင်ပါဘူး အဲဒါကြောင့် သက်ဆိုင်ရာ Fundamental Data Structure ဘာသာတွေကို ဖတ်ဖို့လိုအပ်ပါလိမ့်မယ်။

Algorithm 3

1
2
3
4
5
6
7
#Prerequisites:
#1) Need to read the manuals of specific language
#!/usr/bin/python
import math
 
def factorial3(num):
	return math.factorial(num)

Algorithm 3 ကတော့ရှင်းလင်းပါတယ် အရာအားလုံးကိုယ်တိုင် ရေးဖို့လိုအပ်ချင်မှ လိုအပ်ပါတယ် ကိုယ်အသုံးပြုနေတဲ့ Language မှာဘာတွေ အသုံးပြုလို့ရတယ်ဆိုတာ သိဖို့အရေးကြီးပါတယ် အဲဒီတော့ ကိုယ်စီးတဲ့မြင်းတော့ အထီးမှန်းအမမှန်းသိဖို့ သက်ဆိုင်ရာ Manuals တွေကိုဖတ်ရပါလိမ့်မယ် အဲလိုမသိခဲ့ရင်တော့ ဘီးကိုအသစ်တီထွင်နေသလို အချိန်ကုန်လူပန်း ဖြစ်ပါလိမ့်မယ်။

Algorithm 4

1
2
3
4
5
6
7
#Prerequisites:
#1) Divide and Conquer
#2) Map and Reduce
#3) Language specific reduce method
#!/usr/bin/python
def factorial4(num):
	return reduce(long.__mul__, [long(x) for x in range(2, num + 1)])

Algorithm 4 ကတော့ အဆင့်မြင့် Algorithm Structure တစ်ခုဖြစ်တဲ့ Divide and Conquer ကိုအခြေခံပါတယ်။ Divide and Conquer Algorithm တိုင်းမှာ Recursive ပါဝင်တဲ့အတွက် Recursive ကိုနားလည်ရပါမယ်။ Distirbuted Algorithm တစ်ခုဖြစ်တဲ့ Map and Reduce သဘောတရားကိုလည်း အသုံးပြုထားပါတယ် ဒီနေရာမှာ Distirbuted မဟုတ်ပဲ Serial ဖြစ်နေတာရယ် ရှုပ်ထွေးတဲ့ တွက်ချက်မှု့မပါတဲ့အတွက် Map လုပ်ဖို့မလိုအပ်လို့ Reduce သာအသုံးပြုထားပါတယ်။ ဒီနေရာမှာလည်း Map and Reduce ကိုအသုံးပြုပေမယ် အရာအားလုံး ကိုယ်တိုင်မရေးသားပါဘူး သက်ဆိုင်ရာ Language ကထောက်ပံ့ပေးထားတဲ့ Map and Reduce ကိုသင့်လျော်သလို အသုံးပြုထားပါတယ်။

Algorithm 5

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Prerequisites:
#1) Divide and Conquer
#2) Map and Reduce
#3) Processor Architecture
#4) Multiprocessing
#5) Thread Pool
#6) Language specific multiprocess map
#!/usr/bin/python
import multiprocessing
 
def mul_x2y((x, y)):
	if(x!=y):
		return x * mul_x2y((x+1,y))
	else:
		return x
 
def factorial5(num):
	cpu_count = multiprocessing.cpu_count()
	job_list = [(x,x+cpu_count-1) for x in range(1, (num/cpu_count)*cpu_count, cpu_count)]
	if num%cpu_count>0:
		job_list = job_list + [((num/cpu_count)*cpu_count+1,num)]
	pool = multiprocessing.Pool(cpu_count)
	return reduce(long.__mul__, [long(x) for x in pool.map(mul_x2y,job_list)])

Algorithm 5 ကတော့ Algorithm 4 ကိုအဆင့်မြင့်ထားတာပါ Algorithm 4 မှာ Map and Reduce ကိုသုံးတယ်ဆိုပေမယ့် အပြည့်အဝအသုံးမချသလို Parallel Processing အတွက်လည်း မရည်ရွယ်ထားပါဘူး အခုအချိန်မှာ Computer တွေဟာ အများအားဖြင့် Multi-core, Multi-proecessor တွေနဲ့ဖြစ်လာလို့ အဲဒါတွေကိုလည်း အကျိုးရှိရှိ အသုံးချဖို့လိုပါတယ်။ Algorithm 5 မှာတော့ Processor တစ်လုံးချင်းစီအတွက် အလုပ်ကိုခွဲဝေပြီး Map လုပ်ပြီးတွက်ချက်လိုက်ပါတယ် ပြန်လာတဲ့ Partial Result တွေကို Reduce လုပ်ခြင်းအားဖြင့် နောက်ဆုံးအဖြေကို တွက်ယူလိုက်ပါတယ်။

Algorithm 5 ကိုလည်းထပ်ပြီးတော့ အဆင့်မြင့်မယ်ဆိုရင် ရနိုင်ပါသေးတယ် Algorithm 5 ဟာ Multiprocessing အတွက်ရည်ရွယ်ပေမယ့် Computer တစ်လုံးတည်းအတွက်ပဲ ရည်ရွယ်ထားပါတယ် အကယ်၍ Computer တစ်လုံးထက်ပိုခဲ့မယ်ဆိုရင် Distributed Processing လုပ်လို့ရပါတယ် အဲဒါကြောင့် ကိုယ်ပိုင်ဆိုင်တဲ့ Knowledge ဘယ်လောက်ရှိမလဲဟာ အင်မတန်အရေးကြီးပါတယ် ဒါကြောင့် သက်ဆိုင်ရာ ဘာသာရပ်တွေကို လေ့လာနေဖို့လိုအပ်ပါတယ်။ အဲဒါတွေကိုအခြေခံပြီး သင့်လျော်တဲ့နေရာတွေမှာ အသုံးချယူရတာပါ ခက်ခဲတဲ့ Algorithm ဟာလည်း နေရာတိုင်းမှာ သင့်လျော်ချင်မှ သင့်လျော်ပါတယ် အလွယ်ဆုံး Algorithm ဟာလည်း အကောင်းဆုံးဖြစ်တတ်ပါတယ်။ အောက်မှာပြထားတဲ့ Performance Results တွေကိုကြည့်ပါ။

1000 to 9000
Algorithm ငါးခုလုံးဟာ ပုံမှန်အားဖြင့် ကောင်းကောင်းအလုပ်လုပ်ပါတယ် ကိန်းဂဏန်းသေးရင် တွက်ချက်ချိန်ကို မှန်းလို့မရပါဘူး အဲဒါကြောင့် ၁၀၀၀ ကနေ ၉၀၀၀ အထိကိန်းဂဏန်းတွေကို Algorithm တစ်ခုစီနဲ့တွက်ချက်ပြီး ကြာချိန်ကိုတိုင်းတာလိုက်ပါတယ်။ အဖြေတွေကိုကြည့်လိုက်တော့ ခက်ခက်ခဲခဲရေးထားတဲ့ Algorithm 5 ဟာအကြာဆုံးဖြစ်နေပြီး Recursive သုံးထားတဲ့ Algorithm 2 ဟာဒုတိယ အနှေးဆုံးဖြစ်ပါတယ်။ Built-in Function ကိုယူသုံးထားတဲ့ Algorithm 3 ဟာအမြန်ဆုံးဖြစ်နေပြီး Algorithm 1 and Algorithm 4 ကတော့ တူညီသလောက်ဖြစ်ပါတယ်။
10000 to 90000
နောက်တစ်ြကိမ် စမ်းသပ်တဲ့အနေနဲ့ ၁၀၀၀၀ ကနေ ၉၀၀၀၀ အထိကိန်းတွေကို တစ်ခေါက်တွက်ချက်ပြီး ကြာချိန်တွေကိုပြန်ပြီး တိုင်းတာကြည့်ပါတယ်။ ဒီအချိန်မှာတော့ ရလဒ်တွေဟာ ပထမတိုင်းတာချက်နဲ့ ကွဲပြားသွားပါတယ်။ ပထမတိုင်းတာချက်မှာ အနှေးဆုံးဖြစ်တဲ့ Algorithm 5 ဟာကိန်းဂဏန်းကြီးလာတာနဲ့အမျှ အခြားသော Algorithm တွေထက် ကြာချိန်သိသိသာသာ လျော့နည်းသွားတာ တွေ့ရပါတယ်။ ပထမအကြိမ်မှာ ကြာချိန်အနည်းဆုံးဖြစ်တဲ့ Algorithm 3 ဟာ ကိန်းဂဏန်းကြီးလာတာနဲ့အမျှ ကြာမြင့်ချိန်အများဆုံး Algorithm ဖြစ်လာပါတယ်။ Algorithm 1 and Algorithm 4 ကတော့ ပထမတိုင်းတာချက်အတိုင်းပဲ ကွာခြားချက်သိပ်များပဲ တူညီသလောက်ရှိပါတယ်။ ဒီတစ်ြကိမ်မှာတော့ Algorithm 2 ဟာ Stack Space မလုံလောက်တဲ့အတွက် တွက်ချက်ခြင်း မပြုနိုင်တော့ပါဘူး။

စမ်းသပ်ချက်တွေက 4 Core CPU and 6 GB RAM ရှိတဲ့စက်မှာ စမ်းသပ်ထားတာပါ အခြားစက်မှာဆိုရင် အချိန်ကွာခြားမှု့ရှိနိုင်ပါတယ်။ အပေါ်မှာပြထားတဲ့ တိုင်းတာချက်တွေကို နမူနာကြည့်ချင်းအားဖြင့် Algorithm ခက်ခဲတိုင်းလည်း ထွက်လာတဲ့အဖြေဟာ တွက်ချက်မယ့် အခြေအနေများအပေါ်မှာ မှိခိုပါတယ်။ နမူနာအားဖြင့် Algorithm 5 ဟာကောင်းပေမယ့် ကိန်းဂဏန်းငယ်တဲ့အချိန်မှာ Processor တွေကိုအလုပ်ခွဲဝေတဲ့ အလုပ်တွေက တွက်ချက်ချိန်ထက် ပိုပြီးကြာမြင့်တဲ့အတွက် အခြားရိုးစင်းတဲ့ Algorithm တွေထက်နှေးသွားပါတယ် ဒါပေမယ့် ကိန်းဂဏန်းကြီးလာတာနဲ့အမျှ ရလဒ်တွေဟာ ကောင်းလာတာကို တွေ့နိုင်ပါတယ်။ ဒီနေရာမှာ Recursive ဟာ Logic မှန်ပေမယ့် Language ရဲ့ကန့်သတ်ချက်ကြောင့် အလုပ်မလုပ်နိုင်တာတွေ တွေ့ရပါတယ်။

နှိုင်းယှဉ်ပြထားတွေကို နောက်ဆုံးချုပ်ပြောရရင် Knowledge Building အတွက်ကတော့ သက်ဆိုင်ရာ ဘာသာရပ်တွေကို လေ့လာရပါလိမ့်မယ် စာမဖတ်ပဲတော့ ဘာမှဖြစ်မလာနိုင်ပါဘူး နောက်ထပ်လေ့လာဖို့ အခွင့်အရေးဆိုတာက ကျောင်းတက်နေတုံးမှာ အများဆုံးရနိုင်ပါတယ် ကျောင်းတွေမှာပဲ သင်လို့ရနိုင်တဲ့ ဘာသာရပ်တွေ အများကြီးရှိတယ် ကျောင်းမှာသင်သမျှ ကိုယ့်အတွက် အသုံးမတည့်ပေမယ့် တကယ်လေ့လာခဲ့ရင် တစ်သက်လုံးအကျိုးရှိနိုင်မယ့် ဘာသာရပ်တွေအများကြီးပါ။ ပိုင်ဆိုင်လာတဲ့ Knowledge တွေကို သင့်လျော်ရာကို ဘယ်လိုသုံးမလဲဆိုတာကတော့ ကိုယ်ဘယ်လောက် အသုံးချဖို့ကြိုးစားဖူးသလဲဆိုတဲ့ အမှားတွေ အများကြီးဖြစ်ခဲ့တဲ့ အတွေ့အကြုံက အလိုလိုသင်သွားပါလိမ့်မယ်။

The Evolution of a Programmer

High School

10 PRINT “HELLO WORLD”
20 END

First year in College

program Hello(input, output)

begin
writeln(‘Hello World’)
end.

Senior year in College

(defun hello
(print
(cons ‘Hello (list ‘World))))

New professional

#include
void main(void)
{
char *message[] = {“Hello “, “World”};
int i;

for(i = 0; i < 2; ++i)
printf(“%s”, message[i]);
printf(“n”);
}

Seasoned professional

#include
#include

class string
{

private:
int size;
char *ptr;

public:
string() : size(0), ptr(new char(‘′)) {}

string(const string &amp;s) : size(s.size)

{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}

~string()

{
delete [] ptr;
}

friend ostream &amp;operator <<(ostream &amp;, const string &amp;);

string &amp;operator=(const char *);
};

ostream &amp;operator<<(ostream &amp;stream, const string &amp;s)
{

return(stream << s.ptr);
}

string &amp;string::operator=(const char *chrs)
{
if (this != &amp;chrs)

{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);

}
return(*this);
}

int main()
{
string str;

str = “Hello World”;
cout << str << endl;

return(0);
}

Master Programmer

[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]

library LHello
{
// bring in the master library
importlib(“actimp.tlb”);
importlib(“actexp.tlb”);

// bring in my interfaces
#include “pshlo.idl”

[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)

]
cotype THello
{
interface IHello;
interface IPersistFile;

};
};

[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]

module CHelloLib
{

// some code related header files
importheader(
importheader(

importheader();
importheader(“pshlo.h”);

importheader(“shlo.hxx”);
importheader(“mycls.hxx”);

// needed typelibs
importlib(“actimp.tlb”);

importlib(“actexp.tlb”);
importlib(“thlo.tlb”);

[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),

aggregatable
]
coclass CHello
{
cotype THello;

};
};

#include “ipfix.hxx”

extern HANDLE hEvent;

class CHello : public CHelloBase

{
public:
IPFIX(CLSID_CHello);

CHello(IUnknown *pUnk);
~CHello();

HRESULT __stdcall PrintSz(LPWSTR pwszString);

private:
static int cObjRef;
};

#include

#include #include
#include
#include “thlo.h”

#include “pshlo.h”
#include “shlo.hxx”
#include “mycls.hxx”

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)

{
cObjRef++;
return;
}

HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)

{
printf(“%wsn”, pwszString);
return(ResultFromScode(S_OK));
}

CHello::~CHello(void)

{

// when the object count goes to zero, stop the server
cObjRef–;
if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include
#include

#include “pshlo.h”
#include “shlo.hxx”
#include “mycls.hxx”

HANDLE hEvent;

int _cdecl main(

int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);

CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &amp;dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF->Release();

// Tell OLE we are going away.
CoUninitialize();

return(0);
}

extern CLSID CLSID_CHello;

extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,

{ 0x9A, 0x9F, 0×00, 0xAA, 0×00, 0×34, 0×28, 0×20 }
};

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,

0x101A,
{ 0x9A, 0x9F, 0×00, 0xAA, 0×00, 0×34, 0×28, 0×20 }
};

#include

#include #include
#include
#include

#include “pshlo.h”
#include “shlo.hxx”
#include “clsid.h”

int _cdecl main(
int argc,
char * argv[]

) {
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];

WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = ‘′;
wcsT[0] = ‘′;
if( argc > 1) {

mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, “Object path must be specifiedn”);

return(1);
}

// get print string
if(argc > 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);

else
wcscpy(wcsT, L”Hello World”);

printf(“Linking to object %wsn”, wcsPath);
printf(“Text String %wsn”, wcsT);

// Initialize the OLE libraries

hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath, &amp;pmk);
if(SUCCEEDED(hRslt))

hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&amp;pHello);

if(SUCCEEDED(hRslt)) {

// print a string out
pHello->PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello->Release();
}
else
printf(“Failure to connect, status: %lx”, hRslt);

// Tell OLE we are going away.
CoUninitialize();
}

return(0);

}

Apprentice Hacker

#!/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;

Experienced Hacker

#include
#define S “Hello, Worldn”
main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Seasoned Hacker

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

Guru Hacker

% cat
Hello, world.
^D

New Manager

10 PRINT “HELLO WORLD”
20 END

Middle Manager

mail -s “Hello, world.” bob@b12

Bob, could you please write me a program that prints “Hello, world.”?
I need it by tomorrow.
^D

Senior Manager

% zmail jim

I need a “Hello, world.” program by this afternoon.

Chief Executive

% letter
letter: Command not found.

% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized

% logout