Python与 Ruby
Python和 Ruby 编程语言之间存在许多差异和相似之处。
Ruby 是一种动态的、开源的、面向对象的反射式编程语言。 Ruby 被认为类似于 Perl 和 Smalltalk 编程语言。它可以在所有类型的平台上运行,例如 Windows、Mac OS 和所有版本的 UNIX。
Python是一种简单、易学、功能强大、高级且面向对象的编程语言。它也是一种解释性脚本语言。 Guido Van Rossum 被称为Python编程的创始人。
相似之处:
- 它们都是高级语言。
- 它们都是服务器端脚本语言。
- 两者都用于 Web 应用程序。
- 两者都适用于多个平台。
- 两者都具有简洁的语法并且易于阅读。
- 两者都使用称为 IRB 的交互式提示。
- 对象是强类型和动态类型的。
- 两者都使用嵌入式文档工具。
- GNU Debugger(gdb) 样式可用于每种语言。
- Emacs 模式支持这两种语言。
差异:
Terms | Python | Ruby |
---|---|---|
Definition | Python is a high level programming language. | Ruby is a general purpose programming language. |
Object Oriented | Not fully object oriented programming language. | Fully object oriented programming language. |
Developing Environment | multiple IDEs are supported. | EclipseIDE is supported. |
Mixins | Mixins can’t be used. | Mixins are used. |
Web frameworks | Django | Ruby on Rails |
Libraries | Has larger range of libraries. | It has smaller library than Python. |
elseif | elif | elseif |
Developers | Created 1991 by Guido Van Rossum. | Created 1995 by Yukihiro “Matz” Matsumoto. |
Unset a variable | It 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 functions | Support only lambdas. | Support blocks, procs and lambdas. |
lambda functions | It support only single line lambda function. | Its lambda functions are larger. |
Functions | It has functions. | It Doesn’t have functions. |
Community | Focused in academia and Linux. | Mainly focused on web. |
switch/case statement | It doesn’t support switch/case statement. | It support switch/case statement. |
yield keyword | It 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 classes | Built-in classes can’t be modified | Built-in classes can be modified |
Inheritance | Support multiple inheritance. | Support single inheritance. |
Tuples | It support tuples. | It doesn’t support tuples. |
Usage | Google, Dropbox, Instagram, Mozilla, Yahoo, Venom, You Tubes | Apple, GitHub, Twitter, Hulu, ZenDesk, Urban Dictionary |