五月 2007


I want to rest, but I cannot stop.
Is it the season?  Is it because I am tired?
Why can’t I stop?  I ask myself that question everyday.
Everyday I arrive at the same answer.

If I don’t continue, then I will stagnate.
Yet I feel idle everyday.
What is going on?  Why do I feel like this?
Such void I feel inside me, depletes me of all energy.
Long forgotten is the feeling of serenity, feeling of peace.

I no longer remember that feeling of anticipation,
That excitement for the future, what it may hold for me.
Replace instead is that sickening feeling of pessimism.

So many people worry the same, the uncertainty of one’s fate.
Can it be that this phenomenon grips only modern society?
Or did the ones before us scream for God to have mercy just the same?

So many questions, yet it seems no one has an answer for it.
I grow disgusted at these thoughts, no longer wishing to ponder.
And so I cease my complaints and ask only this:
When will this end?

廣告

It has just occurred to me that Python’s functional programming support may mean that polymorphism is unbelievably easier and powerful under Python.

Consider the following code:

func = getattr(class_name, ‘method_name’)
func(arguments)

You can dynamically obtain a “function object" and invoke it with arguments.

Not only do you not need to care what function you just got, you don’t even need the method names to be identical as long as you follow a convention!  You can say:

func = getattr(class_name, ‘get_%s_pie’, %fruit)
func(num_of_pies)

As long as you define the “fruit string", now my code won’t need to care what fruit your object is.  You can have get_apple_pie, get_banana_pie, get_strawberry_pie, and my code won’t care!  This is polymorphism at the function level, which for me is unheard of until now.  C/C++/C#/Java all require object level polymorphism, but do NOT support function/method level polymorphism.  With functional programming, this is now possible.

In Python, even Classes (object definitions) are “objects".  At first this was the weirdest thing I’ve heard in programming languages in a long while.  But now with the functional programming methodology, this makes factory methods stupidly simple.  Consider the following code:

object_class = getattr(module_name, ‘class_name’)
object = object_class(arguments)

Again, use getattr to dynamically get the “class object", and then invoke it and create a specific object instance.  This is object level polymorphism and this is unbelievably simple and elegant.  Compared to the C#/Java way of:

case ‘a’:
    return new a();
case ‘b’:
    return new b();

etc….

With python I only have to say:

object_class = getattr(module_name, ‘a’)
object = object_class()

AMAZING!!  At first I was skeptical at Python’s “elegance", with the no-semicolon and indented code blocks, I thought it was just “pretty" rather than practical.  Now I have discovered Python’s functional programming features, I am very impressed and beginning to believe the hype.

今天需要裝Ubuntu Linux,在學校跑去下載。 Ubuntu Linux 700MB左右,我從 Purdue University 的網站下載,下載之後看看要多久。平時在家裡最快是每秒200-300kb的速度,全部下載要差不多一個半小時到兩個小時左右。

我把下載的視窗打開後,檢查速度。

「每秒 1205 kb」。

乍看之下我還以為我眼睛花了。仔細一看竟然是真的!我驚呼老天!怎麼會這麼快?旁邊同學問我從那裡下載的,我說Purdue University。他跟我說,Purdue 跟 Ohio State 都有 Internet2 的連接,所以這種速度很正常。

不到10分鐘後,我整張CD下載完成。速度一度飆到每秒1300kb以上!天啊!~真是太快了…..我家甚麼時候才能裝Internet2呀?!

幾個月前的好消息,我大致上把手續弄妥了。沒錯,我暑假要去上海實習,將展開我回到亞洲的第一步。

看著剛拿回來的護照上的大陸三個月短期工作簽證,心中難免興奮,但同時也充滿疑問。在上海居住到底是甚麼樣子呢?會像我想的那樣嗎(大概不太可能),但是會像很多人說得很差?只有暑假去實習三個月後才能知道囉!

說起上海,今天接到我爸教授小女兒的電話。教授小女兒是個道道地地的ABC,對於大陸當然是不可能有好印象。今天接到他的電話,他劈頭就問我是不是以後要在大陸長期居住。我楞了一下,還以為他要勸我不要作傻事。我跟他說,目前暑假只是三個月,但是要是一切OK,我當然是不排斥在大陸長期居住。

「我最近也在考慮到大陸耶!我想換工作,到紐約找律師方面的工作,但是他們要求我去中國發展」。

我當場傻了

他解釋著說,現在紐約公司那邊在大陸生意大,可是缺人(因為很少有人願意去),所以新來的律師公司都希望能夠去大陸分公司,為了吸引人還願意以紐約薪水派他們去亞洲。新加坡,香港,上海,北京,東京,5 個城市選一個。他在考慮新加坡,上海,跟北京。

他接著問我上海的環境(我也只是去觀光過…)跟北京的差異,文化差異,禮節差異等。聽他的詢問,好像真的是很認真的在考慮朝上海發展,我真的很震撼。想說10年前,連去上海轉個機恐怕他都會抱怨半天(畢竟,他小時候可是跟別人指正說他不是中國人,他是美國人),如今竟然認真的在考慮去大陸工作,學中文。這個世界變成了甚麼樣子??

這個世界正在改變。不,大陸正在改變,連帶牽動了這個世界。看來21世紀真的會是中國人的世紀,而我很幸運的成為這個大改變中的一部份,這點讓我興奮。