csdn ruby语言入门_Ruby编程语言入门指南

csdn ruby语言入门

Ruby is unique among object-oriented scripting languages. In a sense, it's a purist's language for those who love object-oriented languages. Everything, without exception, is automatically an object, whereas in other programming languages this isn't true.

面向对象的脚本语言中, Ruby是独一无二的。 从某种意义上说,对于那些喜欢面向对象语言的人来说,这是一种纯粹主义者的语言。 所有内容无一例外都会自动成为对象,而在其他编程语言中,情况并非如此。

What is an object? Well, in a sense you can think of it in terms of building a car. If you have a blueprint for it, then an object is what's built from that blueprint. It contains all the attributes that the object holds (i.e. make, model, color) and the actions it can perform. But, even as a pure object-oriented language, Ruby doesn't sacrifice any usability or flexibility by leaving out features that aren't expressly related to object-oriented programming.

什么是物体? 好吧,从某种意义上讲,您可以从制造汽车的角度来考虑它。 如果您有一个蓝图,那么一个对象就是根据该蓝图构建的。 它包含对象拥有的所有属性(即品牌,型号,颜色)以及它可以执行的操作。 但是,即使作为纯粹的面向对象的语言,Ruby也不会通过遗漏与面向对象的编程没有明确关系的功能而牺牲任何可用性或灵活性。

设计Ruby ( Designing Ruby )

Ruby's architect Yukihiro Matsumoto (known simply as "Matz" on the web) designed the language to be simple enough for beginning programmers to use while also powerful enough for experienced programmers to have all the tools they'd need. It sounds contradictory, but this dichotomy is owed to Ruby's pure object-oriented design and Matz's careful selection of features from other languages such as Perl, Smalltalk, and Lisp.

Ruby的建筑师Yukihiro Matsumoto(在网络上简称为“ Matz”)设计的语言足够简单,适合初学者使用,同时也足够强大,适合经验丰富的程序员使用所需的所有工具。 这听起来是矛盾的,但是这种二分法归因于Ruby的纯面向对象设计以及Matz从其他语言(如Perl ,Smalltalk和Lisp)中精心选择的功能。

There are libraries for building all types of applications with Ruby: XML parsers, GUI bindings, networking protocols, game libraries and more. Ruby programmers also have access to the powerful RubyGems program. Comparable to Perl's CPAN, RubyGems makes it easy to import other programmers' libraries into your own programs.

有一些库可以使用Ruby构建所有类型的应用程序:XML解析器,GUI绑定,网络协议,游戏库等。 Ruby程序员还可以访问功能强大的RubyGems程序。 与Perl的CPAN相比 ,RubyGems可以轻松地将其他程序员的库导入到您自己的程序中。

Ruby 不是什么? ( What Is Ruby Not? )

Like any programming language, Ruby has its downsides. It's not a high-performance programming language. In that regard, Python's virtual machine design has a huge advantage. Also, if you're not a fan of the object-oriented methodology then Ruby isn't for you.

像任何编程语言一样,Ruby也有缺点。 它不是一种高性能的编程语言。 在这方面, Python的虚拟机设计具有巨大的优势。 另外,如果您不喜欢面向对象方法,那么Ruby就不适合您。

Though Ruby does have some features that fall outside the realm of object-oriented languages, it's not possible to create a non-trivial Ruby program without using the object-oriented features. Ruby doesn't always perform as well as other similar scripting languages in raw computing tasks. That being said, future versions will address these problems and alternate implementations, such as JRuby, are available as a workaround for these issues.

尽管Ruby的某些功能确实超出了面向对象语言的范围,但如果不使用面向对象的功能,就不可能创建一个平凡的Ruby程序。 在原始计算任务中,Ruby并不总是像其他类似的脚本语言那样表现出色。 话虽这么说,将来的版本将解决这些问题,并且可以使用替代实现(例如JRuby)作为这些问题的解决方法。

Ruby是如何使用的? ( How Is Ruby Used? )

Ruby is used in typical scripting language applications such as text processing and "glue" or middleware programs. It's suitable for small, ad-hoc scripting tasks that, in the past, may have been solved with Perl. Writing small programs with Ruby is as easy as importing the modules you need and writing an almost BASIC-like "sequence of events" type of program.

Ruby用于典型的脚本语言应用程序,例如文本处理和“胶水”或中间件程序。 它适用于过去可能已经用Perl解决的小型临时脚本任务。 使用Ruby编写小型程序就像导入所需的模块并编写几乎类似于BASIC的“事件序列”类型的程序一样容易。

Like Perl, Ruby also has first-class regular expressions, which makes text processing scripts a snap to write. The flexible syntax also aides in small scripts. With some object-oriented languages, you can get bogged down with verbose and bulky code, but Ruby leaves you free to simply worry about your script.

像Perl一样,Ruby也具有一流的正则表达式,这使得文本处理脚本易于编写。 灵活的语法还可以辅助小型脚本。 使用某些面向对象的语言,您可能会陷入冗长而笨拙的代码中,但是Ruby让您可以随意担心脚本。

Ruby is also suitable for larger software systems. Its most successful application is in the Ruby on Rails web framework, software which has five major subsystems, numerous minor pieces and a plethora of support scripts, database backends, and libraries.

Ruby也适用于大型软件系统。 它最成功的应用程序在Ruby on Rails Web框架中 ,该软件具有五个主要子系统,许多次要部分以及过多的支持脚本,数据库后端和库。

To aid the creation of larger systems, Ruby offers several layers of compartmentalization, including the class and module. Its lack of superfluous features allows programmers to write and use large software systems without any surprises.

为了帮助创建更大的系统,Ruby提供了几层分隔,包括和模块。 它缺乏多余的功能,使程序员可以编写和使用大型软件系统而不会感到惊讶。

哪些技能对学习Ruby有帮助? ( What Skills Would Be Helpful for Learning Ruby? )

  • A solid understanding of object-oriented concepts. Ruby is an object-oriented language and the object-oriented features are used throughout. Without this critical skill, you'll be struggling as a Ruby programmer.

    对面向对象的概念有扎实的理解。 Ruby是一种面向对象的语言,并且始终使用面向对象的功能。 没有这项关键技能,您将很难成为一名Ruby程序员。

  • A bit of functional programming knowledge. This is a plus as Ruby uses the block or "closure" extensively. Not having this ability isn't insurmountable, though. Creating blocks is a feature that can be learned easily enough while learning Ruby.

    有点函数式编程知识。 这是一个加号,因为Ruby广泛使用块或“闭包”。 但是,没有这种能力并不是无法克服的。 创建块是一项在学习Ruby时可以很容易地学习的功能。

  • A bit of navigational know-how. The primary way of running a Ruby script is from the command-line. Knowing how to navigate directories, run scripts and redirect input and output are essential skills to Ruby programmers.

    一点导航知识。 运行Ruby脚本的主要方法是从命令行开始。 知道如何导航目录,运行脚本以及重定向输入和输出是Ruby程序员的基本技能。

Ruby所需的应用程序和工具 ( Applications and Tools Needed for Ruby )

  • The Ruby interpreter

    Ruby 解释器

  • A text editor such as Notepad++, Scite, or Vim. Word processors such as Wordpad or Microsoft Word are not suitable.

    文本编辑器,例如Notepad ++Scite或Vim。 不适合使用写字板或Microsoft Word等文字处理器。

  • Command-line access. Though the details of this differ from platform to platform, Linux, Windows, and OSX all have this available without any extra downloads or software installation.

    命令行访问。 尽管各个平台的详细信息有所不同,但Linux,Windows和OSX都可以使用此功能,而无需任何额外的下载或安装软件。

翻译自: https://www.thoughtco.com/what-is-ruby-2907828

csdn ruby语言入门

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值