📜  Python与 Ruby

📅  最后修改于: 2022-05-13 01:55:07.655000             🧑  作者: Mango

Python与 Ruby

Python和 Ruby 编程语言之间存在许多差异和相似之处。

Ruby 是一种动态的、开源的、面向对象的反射式编程语言。 Ruby 被认为类似于 Perl 和 Smalltalk 编程语言。它可以在所有类型的平台上运行,例如 Windows、Mac OS 和所有版本的 UNIX。

Python是一种简单、易学、功能强大、高级且面向对象的编程语言。它也是一种解释性脚本语言。 Guido Van Rossum 被称为Python编程的创始人。

相似之处:

  1. 它们都是高级语言。
  2. 它们都是服务器端脚本语言。
  3. 两者都用于 Web 应用程序。
  4. 两者都适用于多个平台。
  5. 两者都具有简洁的语法并且易于阅读。
  6. 两者都使用称为 IRB 的交互式提示。
  7. 对象是强类型和动态类型的。
  8. 两者都使用嵌入式文档工具。
  9. GNU Debugger(gdb) 样式可用于每种语言。
  10. Emacs 模式支持这两种语言。

差异:

TermsPythonRuby
DefinitionPython is a high level programming language.Ruby is a general purpose programming language.
Object OrientedNot fully object oriented programming language.Fully object oriented programming language.
Developing Environmentmultiple IDEs are supported.EclipseIDE is supported.
MixinsMixins can’t be used.Mixins are used.
Web frameworksDjangoRuby on Rails
LibrariesHas larger range of libraries.It has smaller library than Python.
elseifelifelseif
DevelopersCreated 1991 by Guido Van Rossum.Created 1995 by Yukihiro “Matz” Matsumoto.
Unset a variableIt will be present in the symbol table as long as it is in scope.Once a variable is set you can’t unset it back.
Anonymous functionsSupport only lambdas.Support blocks, procs and lambdas.
lambda functionsIt support only single line lambda function.Its lambda functions are larger.
FunctionsIt has functions.It Doesn’t have functions.
CommunityFocused in academia and Linux.Mainly focused on web.
switch/case statementIt doesn’t support switch/case statement.It support switch/case statement.
yield keywordIt returns execution to the scope outside the function’s invocation. External code is responsible for resuming the function.It will execute another function that has been passed as the final argument, then immediately resume.
Built-in classesBuilt-in classes can’t be modifiedBuilt-in classes can be modified
InheritanceSupport multiple inheritance.Support single inheritance.
TuplesIt support tuples.It doesn’t support tuples.
UsageGoogle, Dropbox, Instagram, Mozilla, Yahoo, Venom, You TubesApple, GitHub, Twitter, Hulu, ZenDesk, Urban Dictionary