Ruby如何与Python相比?与Python相比,Ruby的设计有多好? [英] How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python?

查看:65
本文介绍了Ruby如何与Python相比?与Python相比,Ruby的设计有多好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ruby如何与Python相比?与Python相比,Ruby的设计有多好?


Python的设计是敬虔的。我想知道Ruby也是虔诚的。


我听说它有坚实的OOP设计但是我也听说过有


很多奇怪的方法做一些像Perl这样的事情对我不好。


还有其他想法吗?


谢谢!


Chris

How does Ruby compare to Python?? How good is DESIGN of Ruby compared to Python?

Python''s design is godly. I''m wondering if Ruby''s is godly too.

I''ve heard it has solid OOP design but then I''ve also heard there are

lots of weird ways to do some things kinda like Perl which is bad for me.

Any other ideas?

Thanks!

Chris

推荐答案

Christian Seberino写道:
Christian Seberino wrote:
Python的设计是敬虔的。我想知道Ruby's是否也是虔诚的。


实际上,Python的设计是Guidoly,在实践中几乎同样好看。


至于Ruby - 如果是的话,日本的神似乎在语言设计上有一些不同的口味。


就个人而言,我更喜欢Python。你可能会从大多数人那里得到相同的答案,因为这是一个Python新闻组...

我听说它有坚实的OOP设计


从某种意义上来说,没有独立的

函数,只有方法,这是更严格的OO。但那只是一个表面问题。至于

,我可以看到,Python的基础与任何可以得到的东西一样坚固OO,并且不亚于Ruby的。

然后我也听说有很多奇怪的方法可以做一些像Perl这样对我不好的事情。
Python''s design is godly. I''m wondering if Ruby''s is godly too.
Actually, Python''s design is Guidoly, which seems to be
almost as good in practice.

As for Ruby -- if it is, Japanese gods seem to have somewhat
different tastes in language design.

Personally I much prefer Python. You''ll probably get the same
answer from most people here, since this is a Python newsgroup...
I''ve heard it has solid OOP design
It''s more rigidly OO in the sense that there are no stand-alone
functions, only methods. But that''s just a surface issue. As far
as I can see, Python''s foundation is as solidly OO as anything
can get, no less so than Ruby''s.
but then I''ve also heard there are
lots of weird ways to do some things kinda like Perl which is bad for me.




Ruby代码随意散布着@ -signs,这往往会让它看起来有点像Perl-ish。但这又是一个表面问题,并且Ruby实际上并不像Perl那样,而不是Python。


我能做的一些真正重要的区别看看是:


* Ruby大量使用传递代码块作为

参数,实现迭代结构等等。

Ruby在这方面非常像Smalltalk。 Python

使用不同的机制(迭代协议)来实现

这些东西。与Ruby相比,Python的方式越来越强大了。
。 Ruby可以很容易地定义新的控件

结构,它们看起来就像内置的那样,你不能用Python做什么。另一方面,Python有其功能强大的生成器,其中没有

直接相当于Ruby。


*在Python中,函数是一流的,并且

方法是根据函数实现的。在Ruby中,

方法是基本概念,并且没有

一等函数。结果是Python让你从一个对象获得一个绑定方法,并使用它像

任何其他函数。你不能用Ruby做到这一点。你可以用
在Ruby中获取一个方法对象,但你不能用

正常的调用语法来调用它。


-

Greg Ewing,计算机科学系,

坎特伯雷大学,

新西兰基督城
http://www.cosc.canterbury.ac.nz/~greg



Ruby code is liberally sprinkled with @-signs, which tends to
make it look slightly Perl-ish. But again that''s a surface
issue, and Ruby is really no more like Perl than Python is.

Some areas of real, important differences I can see are:

* Ruby makes heavy use of passing code blocks around as
parameters, to implement iteration constructs and so forth.
Ruby is very much like Smalltalk in this respect. Python
uses a different mechanism (the iteration protocol) to achieve
these things. Python''s way is both more and less powerful
than Ruby''s. Ruby makes it easy to define new control
structures which look just like the built-in ones, which
you can''t do with Python. On the other hand, Python has
its amazingly powerful generators, for which there is no
direct equivalent in Ruby.

* In Python, functions are first-class, and
methods are implemented in terms of functions. In Ruby,
methods are the fundamental concept, and there are no
first-class functions. The result is that Python lets
you obtain a bound method from an object and use it like
any other function. You can''t do that in Ruby. You can
get a method object in Ruby, but you can''t call it using
normal calling syntax.

--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg


在文章< c1 ************* @ ID-169208.news.uni-berlin.de> ;,格雷格Ewing(使用news.cis.dfn.de)写道:
In article <c1*************@ID-169208.news.uni-berlin.de>, Greg Ewing (using news.cis.dfn.de) wrote:
* Ruby大量使用传递代码块作为
参数,实现迭代结构等等。
Ruby在这方面非常像Smalltalk。 Python
使用不同的机制(迭代协议)来实现这些东西。 Python的方式比Ruby的方式更强大。 Ruby可以很容易地定义新的控件结构,这些结构看起来就像内置的那样,而你不能用Python做。另一方面,Python拥有其惊人强大的生成器,在Ruby中没有直接的等价物。


不是内置的,但你可以使用continuation在Ruby中实现它们

非常容易。请参阅 http://www.rubygarden.org/ruby?RubyFromPython

例子。我能看到的唯一问题可能是性能问题,但

这些语言的性能特征差别很大

除此之外我还是假设。

*在Python中,函数是一流的,
方法是根据函数实现的。在Ruby中,
方法是基本概念,并且没有一流的功能。结果是Python允许您从对象获取绑定方法并像使用任何其他函数一样使用它。你不能用Ruby做到这一点。你可以在Ruby中获取一个方法对象,但你不能使用
普通的调用语法来调用它。
* Ruby makes heavy use of passing code blocks around as
parameters, to implement iteration constructs and so forth.
Ruby is very much like Smalltalk in this respect. Python
uses a different mechanism (the iteration protocol) to achieve
these things. Python''s way is both more and less powerful
than Ruby''s. Ruby makes it easy to define new control
structures which look just like the built-in ones, which
you can''t do with Python. On the other hand, Python has
its amazingly powerful generators, for which there is no
direct equivalent in Ruby.
Not built in, but you can implement them in Ruby using continuations
pretty easily. See http://www.rubygarden.org/ruby?RubyFromPython for an
example. The only problem I can see is maybe performance issues, but
the performance characteristics of the languages are pretty different
apart from that, I''d assume.
* In Python, functions are first-class, and
methods are implemented in terms of functions. In Ruby,
methods are the fundamental concept, and there are no
first-class functions. The result is that Python lets
you obtain a bound method from an object and use it like
any other function. You can''t do that in Ruby. You can
get a method object in Ruby, but you can''t call it using
normal calling syntax.




我不喜欢看到区别。 正常呼叫语法在ruby中涉及

一个对象,所以unbound function这不是一个有意义的概念。我的意思是,如果

你得到一个以self参数开头的方法,你还需要一个

对象来调用它,对吗?即使你把它称为foo(obj,

params)而不是obj.foo(params)。我不知道使用其他语法能够使用其他语法的能力是什么,除了能够传递函数

独立于对象之外,我很漂亮确定你无论如何都可以使用Ruby中的

方法。


Joe



I don''t see the distinction. "normal calling syntax" in ruby involves
an object, so "unbound function" isn''t a meaningful concept. I mean, if
you get a method the begins with the self parameter, you still need an
object to call it, right? Even if you''re calling it as "foo(obj,
params)" instead of "obj.foo(params)". I don''t see what the ability to
use the other syntax gets you, except the ability to pass functions
around independantly of objects, which I''m pretty sure you can do with
methods in Ruby anyway.

Joe


Ruby很容易学习。

我建议下载它。

该发行版附带ProgrammingRuby.chm,这是ProgrammingRuby书籍的在线

版本。 />
您可以在几天内阅读大部分内容。

然后自行决定。


Ruby是一门优秀的语言,但社区规模较小,外部库的绑定较小,额外包的数量较小。
Ruby is easy to learn.
I suggest downloading it.
The distribution comes with ProgrammingRuby.chm which is the online
version of the ProgrammingRuby book.
You can read most of what you need in a couple days.
Then decide for yourself.

Ruby is a fine language, but the community is smaller, the bindings to
external libraries are smaller and the number of extra packages are
smaller.


这篇关于Ruby如何与Python相比?与Python相比,Ruby的设计有多好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆