📄 00000001.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: kafa (staring at the sun), 信区: Linux <BR>标 题: Ruby与其他语言的比较 <BR>发信站: BBS 水木清华站 (Tue Nov 21 21:28:43 2000) WWW-POST <BR> <BR>呵呵,凑个热闹。
<BR>这是www.ruby-lang.org自己网站上的比较。
<BR>---------------------------
<BR> Contrast Ruby and Other Languages Ruby Search
<BR>
<BR>-----------------------------------------------------------------------
<BR>
<BR>Let's compare other languages with Ruby. We take up Perl, Python, Tcl, Java, <BR>Eiffel and C++. This is based on our own judgment and biased view, however, <BR>it does not intend to spread fibs.
<BR>
<BR>Please tell me about mistakes, correction or supplementation for this page.
<BR>
<BR>Perl
<BR>Ruby owes a lot of ideas Perl. Now, let's compare Perl with Ruby:
<BR>
<BR>
<BR>Ruby was a genuine easy-to-use object-oriented language from the beginning; <BR>whereas Perl's OOP features were added to non-OO Perl, so that these features <BR>are (unlike the rest of Perl) very clumsy and hard to use correctly and <BR>effectively. For many people and purposes, Ruby is a better OO Perl than <BR>Perl.
<BR>
<BR>
<BR>Ruby uses less punctuation ($,@,%, etc.) Ruby uses ($,@) prefixes to denote <BR>variable scope, not data type.
<BR>
<BR>
<BR>Ruby scripts tend to be less cryptic.
<BR>
<BR>
<BR>The default variable scope rules for Ruby (default: local) are much better <BR>suited for medium-to-large scale programming tasks; no "my, my, my" <BR>proliferation is needed for safe Ruby programming.
<BR>
<BR>
<BR>Ruby is easier to learn than Perl, easier to maintain than Perl, yet Ruby <BR>compares well to Perl in terms of overall convenience and power.
<BR>
<BR>
<BR>Ruby copies many good capabilities of Perl, ranging from $_ short cuts to <BR>extended regular expressions.
<BR>
<BR>
<BR>Perl is statically typed language except for references. The only types in <BR>Perl are scalar, array, hash and type glob. :-)
<BR>
<BR>Python
<BR>Python and Ruby deal with similar problem areas. Now, let's compare Python <BR>with Ruby:
<BR>
<BR>
<BR>Ruby uses conservative statement structure, using `end'.
<BR>You don't have to say `self.' to access attribute of the object.
<BR>All data (including Integer, String, List, etc.) in Ruby are class instances. <BR>
<BR>Ruby has a better (or real) closure feature.
<BR>Object attributes are not accessible by default in Ruby.
<BR>Ruby's functions (methods) are not first class objects.
<BR> ~~~~~~~~~~~请教什么意思?
<BR>Ruby converts small integers and long integers automatically.
<BR>Ruby does not have tuples.
<BR>呵呵,我到现在也搞不清楚python为什么要搞个不能修改的tuple类型?
<BR>Statements in Ruby have values; you can say
<BR>
<BR>
<BR>def max(a,b)
<BR> if a>b then a else b end
<BR>end
<BR>
<BR>
<BR>Ruby has assignment syntax sugar such as +=, -=, etc.
<BR>Ruby has more natural operator overloading; e.g. you can define
<BR>
<BR>
<BR>def +(x)
<BR> self.to_i + x
<BR>end
<BR>
<BR>
<BR>Ruby has real garbage collector, not ref-counting. So that:
<BR>(这个很爽,能够省不少事,其他的到没觉得怎么样。象把integer也作为类不知道会有什 <BR>么好处?如果不能有特别的过人之处,想超越那些发展很久的“老语言”而流行起来不太 <BR>可能吧?)
<BR>Not subject to memory leaks like ref-counting is.
<BR>No INCREF, DECREF are required for extensions.
<BR>Extensions for Ruby written in C/C++ can easily define Ruby classes.
<BR>Ruby has a loop abstraction using block; e.g.
<BR>
<BR>
<BR>10.times do
<BR> ...
<BR>end
<BR>
<BR>You can define your own arbitrary iterator.
<BR>
<BR>Ruby's block for method can be used more than iterator; e.g.
<BR>
<BR>
<BR>mutex.synchronize do
<BR> .. critical process ..
<BR>end
<BR>
<BR>
<BR>Ruby provides method combination using `super'.
<BR>Ruby is often faster than Python.
<BR>
<BR>Tcl
<BR>Tcl is well-known as a scripting and glue language, but much simpler than <BR>Perl. Now, let's compare Tcl with Ruby:
<BR>
<BR>
<BR>Ruby is a genuine object-oriented language.
<BR>Ruby is often far faster than Tcl.
<BR>Ruby can handle various data types.
<BR>Ruby has various GUI toolkits, of cource including Tk.
<BR>
<BR>Java
<BR>Java is the language in the news one way or another. Now, let's compare Java <BR>with Ruby:
<BR>
<BR>
<BR>Ruby is an intepreted language.
<BR>All data (including Integer, String, etc.) in Ruby are class instances.
<BR>Ruby's module can be used to share implementation among classes.
<BR>Ruby's variable and expressions are not statically typed.
<BR>
<BR>Eiffel
<BR>An veteran would know the OOPL Eiffel. Now, let's compare Eiffel with Ruby:
<BR>
<BR>Too much difference in target (Why do I list it here ;-)
<BR>
<BR>C++
<BR>C++ is famous OOPL in many places. Now, let's compare C++ with Ruby:
<BR>Ruby is too good to compare ;-)
<BR>----------------------------------------------------------------------
<BR>----------------------------------------------------------------------
<BR>Written by <A HREF="mailto:webmaster@ruby-lang.org
">webmaster@ruby-lang.org
</A> <BR>---------------------------
<BR>我觉得,理想的脚本语言本身应该具有简单清晰的语法,少用特殊标点符号;应该具有真 <BR>正的oo特性,这是现代语言的标志;本身只提供基本的逻辑流程功能,通过提供简单方便 <BR>的extension&embedding特性来利用其他语言写的“产品级的库”,这一点非常关键。
<BR>最后,当然要在设计时就考虑国际化啦,呵呵。 <BR> <BR>-- <BR>※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.160.183] <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -