为什么Ruby有这么多冗余? [英] Why Ruby has so many redundancies?

查看:95
本文介绍了为什么Ruby有这么多冗余?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我爱Ruby,在过去的几年中,这是我的选择语言.

I love Ruby, for past couple of years it is my language of choice.

但是,即使我开始学习它,我也被这样的事实所吸引,那就是经常有几种方法可以完成相同(或等效)的事情.我举几个例子:

But even since I started learning it, I was repelled with the fact that so often there are several ways to do the same (or equivalent) thing. I'll give couple of examples:

  • 方法通常具有别名,因此您总是不得不选择最合适,最受欢迎或普遍接受的替代方法
  • andor,除了&&||-只需查看它们之间造成多少混淆优先级差异
  • for关键字,几乎完全由没有经验的非本机Ruby开发人员使用
  • methods often have aliases, so you always have to bother to choose the most adequate, popular or commonly accepted alternative
  • and and or, besides && and || - just look at how much confusion precedence difference among them causes
  • for keyword, used almost exclusively by inexperienced non-native Ruby developers

这种设计决策背后的原理是什么?他们(Matz吗?)相信该语言会更易于采用,因此更流行吗?

What was the rationale behind such design decisions? Did they (Matz?) believe that the language will be easier to adopt, and therefore more popular that way?

推荐答案

Ruby受到Perl的启发,Perl的一项重要哲学是有不止一种方法可以做到这一点",也就是说,冗余可以使程序员受益更大的自由度(并增加了他们想要的功能以其提供的名称提供的机会-不仅只有一种).您的决定是否真的是一件好事.

Ruby is inspired by Perl, and one important Perl philosophy is "There is more than one way to do it", i.e. redunancies are fine since they give the programmer more freedom (and increases the odds that the functionality they want is available under the name they'd give it - not only under one). Your decision whether that's actually a good thing.

这篇关于为什么Ruby有这么多冗余?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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