Roy's profile猪头锣锣PhotosBlogLists Tools Help

Blog


    August 24

    Ruby

    What's Ruby

    Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable.

    Oh, I need to mention, it's totally free, which means not only free of charge, but also freedom to use, copy, modify, and distribute it.

    Features of Ruby

    • Ruby has simple syntax, partially inspired by Eiffel and Ada.
    • Ruby has exception handling features, like Java or Python, to make it easy to handle errors.
    • Ruby's operators are syntax sugar for the methods. You can redefine them easily.
    • Ruby is a complete, full, pure object oriented language: OOL. This means all data in Ruby is an object, in the sense of Smalltalk: no exceptions. Example: In Ruby, the number 1 is an instance of class Fixnum.
    • Ruby's OO is carefully designed to be both complete and open for improvements. Example: Ruby has the ability to add methods to a class, or even to an instance during runtime. So, if needed, an instance of one class *can* behave differently from other instances of the same class.
    • Ruby features single inheritance only, *on purpose*. But Ruby knows the concept of modules (called Categories in Objective-C). Modules are collections of methods. Every class can import a module and so gets all its methods for free. Some of us think that this is a much clearer way than multiple inheritance, which is complex, and not used very often compared with single inheritance (don't count C++ here, as it has often no other choice due to strong type checking!).
    • Ruby features true closures. Not just unnamed function, but with present variable bindings.
    • Ruby features blocks in its syntax (code surrounded by '{' ... '}' or 'do' ... 'end'). These blocks can be passed to methods, or converted into closures.
    • Ruby features a true mark-and-sweep garbage collector. It works with all Ruby objects. You don't have to care about maintaining reference counts in extension libraries. This is better for your health. ;-)
    • Writing C extensions in Ruby is easier than in Perl or Python, due partly to the garbage collector, and partly to the fine extension API. SWIG interface is also available.
    • Integers in Ruby can (and should) be used without counting their internal representation. There *are* small integers (instances of class Fixnum) and large integers (Bignum), but you need not worry over which one is used currently. If a value is small enough, an integer is a Fixnum, otherwise it is a Bignum. Conversion occurs automatically.
    • Ruby needs no variable declarations. It uses simple naming conventions to denote the scope of variables. Examples: simple 'var' = local variable, '@var' = instance variable, '$var' = global variable. So it is also not necessary to use a tiresome 'self.' prepended to every instance member.
    • Ruby can load extension libraries dynamically if an OS allows.
    • Ruby features OS independent threading. Thus, for all platforms on which Ruby runs, you also have multithreading, regardless of if the OS supports it or not, even on MS-DOS! ;-)
    • Ruby is highly portable: it is developed mostly on Linux, but works on many types of UNIX, DOS, Windows 95/98/Me/NT/2000/XP, MacOS, BeOS, OS/2, etc.
    August 23

    翡翠岛

    一直想去北方的海看看,虽然很多人说海滩很差很小,但是还是想去看看,毕竟没有去过,之前去过香港西贡的海滩和南丫岛,还有深圳的海边,感觉很好,但是都是一个人,其实不值得回味。这次去翡翠岛,很兴奋,也值得期待,在沙滩上安营扎寨,晚上在帐篷边看星星,清晨去海里识贝壳,唯一可惜的是太过专心,当抬起头时太阳已经升起,没有领略到地平线上太阳升起的美景。 虽然这里的海的确不及香港的那般静泌和漂亮,不及深圳的那般干净,可是我还是很喜欢,因为有一大帮人一起开心的Happy,有沙滩足球,很喜欢在海里和同事们抢球的那个自创游戏,有夜色里自助烧烤,还有不算刺激但是好玩的滑沙。更喜欢跟老婆一起在清晨海边拾贝壳的感觉。
    回来三天了,皮肤晒得黝黑,衣服毛巾上面的沙子还没有弄干净,也许,我们需要为那点Happy买单,在现在的日子里,能有多少Happy可以重来呢?天知道!
    我真得很怀念海的声音。
    August 10

    除除草

    我终于不得不承认自己很懒了,时常会想起这里来,但是每次都在转瞬间忘记。也罢,随性也是一种不错的做人特质,暂且这么安慰自己吧,毕竟老婆早已把我定义成了截然相反的另一类人。
    刚刚参加了公司的career day,昏沉沉的在某酒店的会议大厅煎熬了4小时,当然也绝对谈不上所谓的收获,我向来觉得这种老板们的良苦用心其实收效甚微,中国人的某种说不出的民族特性早已决定了这一点。倒不是说这是劣根性,其实那句哪里都适用的中国特色最能说明这一点。
    对于career path,我希望自己能有所想法,也试图让自己明白一些东西,可是我却总是想不明白,所以,还是不要想了好,做最好的自己,开复同学其实说得很经典。