ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: CentOS 5.5 x86_64 (Desktop) & Linux Mint 9 (Netbook)
Posts: 71
Rep:
Ruby vs Perl vs Python
Hi,
Which language should I learn? This will be my first language. Right now I am leaning towards Perl. It seems like Perl is the most powerful and flexible of the three. Is this true? I would just like to know of others opinions before I settle though. What are your thoughts and opinions about both.
First of all, I prefer python and don't know ruby.
I like python because while you learn the language but also because you learn some good practices about programming (indentation, documentation...). And I love the "battery-included" philosophy.
I tried perl but did not like it: too much shortcuts and tricks. It's true that you can write very very short code but often it makes the code a nightmare to understand (unless you are a perl expert, I guess)
It's just my opinion and so a matter of taste.
You should also look at what you want to do with the language you will learn (perl is very good to parse text for instance)
As in most things, the best tool depends on the job. If you expect to be writing code that will become 'production' code in any sense, then Python might be a better choice. Perl is fantastic as a sysadmin's general purpose tool, and can be used to do almost anything. There are so many subjective aspects to factor into how you evaluate 'goodness', that only you can really decide. These include how you want to use your new skill, how easy/hard it may be to learn the new language, what resources you have at your disposal (books, mentors, computer system resources, prior knowledge & aptitude), and whether you want to achieve mastery of the language, or will be satisfied by simply being able to understand the basics.
To me, too much time is often spent debating which is better, rather than spending time doing actual learning. Once you've mastered one language, learning others is much easier; most of the basic concepts exist in all languages. For a lot of people, the first language can be challenging. You should be prepared to struggle and do a lot of unproductive work in the early going.
Distribution: CentOS 5.5 x86_64 (Desktop) & Linux Mint 9 (Netbook)
Posts: 71
Original Poster
Rep:
I am looking for a language that can do a mix of things. Like building cli applications to gui applications. Programming will be a hobby, it is not for a job. Is Perl good? It seems like Perl has a very large community. How does Ruby and Python compare? Also, Perl claims to have over 20,000 modules in CPAN. How does that compare to Ruby and Python? Also, is it just me or does Python and Ruby code look very similar.
Last edited by coolgreen1; 12-10-2010 at 01:40 PM.
The problem with python is backwards compatibility ... python 2 is no longer developed, even tho everyone still uses it, and python 3 is NOT backwards compatible. This is one thing I don't like.
It also depends on what you want to do, but you can hack almost anything in Perl.
Also, is it just me or does Python and Ruby code look very similar.
I've never seen you so, I don't know whether you look like a Python or a Ruby.
If you are programming for a hobby, then a major factor in your choice should probably be how much fun you get out of it. That probably involves the satisfaction of quick learning, and Python seems to have a reputation for this. However, if you do already have a strong background with a lot of traditional Unix tools like grep, awk, sed, shell scripting, etc., then Perl may be quicker to pick up.
If my guess is correct, you will have a hard time getting an objective opinion involving a contrast of Perl & Python & Ruby, since they are all substantially similar, and someone who has already mastered one of them will probably not bother to learn the others. I certainly fall into that category.
Perl is probably the most mature of the three languages. However, it was also one of the first of the Swiss-army-knife style of languages, so other languages may have done some things better with the benefit of seeing other implementations. As a hobbyist, you are unlikely to reach a point where you are limited by the language you are using. If you do reach that level, you will by that time have acquired enough knowledge that the choice of a better alternative will be clear.
Personally, I like Perl, because I already know it. I use it routinely for both system admin tasks, and for certain production-level purposes. I undertook to learn it because it seemed to turn a lot of special-purpose tools that I already understood reasonably well into one general purpose programming language. At the time, I'd never heard of Ruby, and only a little bit about Python. I've only briefly flirted with Ruby, and only in the context of Ruby-On-Rails, and it didn't look awful from the small amount I tried.
I'm not an experienced programmer. I came to Linux back in 1994 because I wanted to learn C++, I found Perl instead an learned it very well, but it was the ancient version of Perl-4, without Objects.
The problem with Perl is that if one doesn't use it continuously one cannot understand the code. When I use Perl, I don't understand my own code after a few weeks. Do not missunderstand me, Perl in fact is a great language!
Nowadays I do a little programming at project.euler and for most of the problems I've solved there I used Ruby. Ruby is very "readable" and I find it easy to learn. Since I don't program continuously, I find it very convenient that I can understand my own Rubycode even after one year.
I *hate* questions like "Which flavor is better: chocolate or vanilla?". There's usually no "one, simple answer" to a question like that.
But frankly, based on everything you've said, I honestly think Perl would probably be the best choice here.
IMHO...
PS:
Python would be my second choice. And my first choice if your interest were less "practical" and more "academic" (Python is by far the more "elegant" language). In any case ("practical" OR "academic"), Ruby would have been a distant 3rd.
I'd suggest to read the camelbook http://oreilly.com/catalog/9780596000271
It's written very well and gives a lot of insight into perl as well as Unix/Linux in general.
I personally think Vala is a good first compiled language, which has plenty of superiority over something that needs an interpreter, which hogs precious CPU and other resources. And Vala compiles directly to C as well, so it doesn't require bytecode or other odd ABIs.
There's also Genie which compiles like Vala but has a syntax similar to Python's.
Thank you all for your answers. I am going with Perl.
I'm not here to convince you to follow any one path. I want to give you my perspective on these two languages. I was in a similar situation (Ruby wasn't in the picture back then), and I tried both Perl and Python. Started learning the basics of both, and I found Python to be more intuitive to read and understand than Perl. Perl seemed more obscure IMO even though I had a fairly good programming experience in C and Java.
Ruby is newer and more up and coming, perl has been around for a long time, and will be around for a long time more, and perl will probably work better for shell scripts.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.