📜  Perl 和 Ruby 的区别

📅  最后修改于: 2021-09-11 04:08:47             🧑  作者: Mango

Perl是一种通用的、高级的解释型和动态编程语言。它是由 Larry Wall 于 1987 年开发的。Perl 最初是为文本处理而开发的,例如从指定的文本文件中提取所需的信息以及将文本文件转换为不同的格式。 Perl 支持面向过程和面向对象的编程。 Perl 在语法上与 C 非常相似,对于了解 C、C++ 的用户来说很容易。

Perl
# Simple Perl program
#!/usr/bin/perl
   
# Below line will print
# "Welcome to GeeksforGeeks!"
print "Welcome to GeeksforGeeks!\n";


Ruby
# Simple Ruby program
puts "Welcome to GeeksforGeeks!"


输出:

Welcome to GeeksforGeeks!

红宝石 是一种纯粹的面向对象语言,由 Yukihiro Matsumoto(在 Ruby 社区中也称为 Matz)于 1990 年代中期在日本开发。除了块之外,Ruby 中的所有东西都是对象,但也有替代品,即 procs 和 lambda。 Ruby 开发的目标是使其充当人类程序员和底层计算机之间的合理缓冲区。 Ruby 的语法与 C 和Java等许多编程语言的语法相似,因此Java和 C 程序员很容易学习。它主要支持所有平台,如 Windows、Mac、Linux。

红宝石

# Simple Ruby program
puts "Welcome to GeeksforGeeks!"

输出:

Welcome to GeeksforGeeks!

Perl 和 Ruby 的区别:

Perl

Ruby

Perl is a high level, general-purpose, interpreted, dynamic 

programming language.

Ruby is a dynamic, object-oriented, reflective, general-purpose programming language.
It is less Object-Oriented language. It is a pure and highly Object-Oriented language.
The number of libraries present in Perl is less than  Ruby. The number of libraries present in Ruby is more than comparing to Perl.
Its support for Unicode is much stronger than Ruby. Its support for Unicode is not as strong as Perl.
The file extension used for Perl is “.pl”. The file extension used for Ruby is.rb”.

It has a very good number of libraries when it comes to 

supporting regular expression.

Its support for regular expression is less when compared to Perl.
Framework for Perl is Catalyst. Framework for Ruby is Ruby on Rails.
It supports multiple variable types. It has only one variable type.
The performance of Perl in terms of execution is very fast. The execution speed of Ruby scripts decent enough.

Perl is most often used in CGI (Common Gateway Interface) 

scripting along with C for web servers and hence used widely in the world of server technology.

Ruby is strong in meta-programming, which allows creating a fabulous product like Vagrant.