The difference between Perl and Python?

Could explain me the difference between Perl and Python?

Sure I can, but first you explain to me the difference between a flower and an airplane :wink:

My point is, they are two different scripting languages and cannot be directly compared. If you want to know the difference, read some material on both languages and see for yourself :slight_smile:

Perl is complex old language.

Python is new OO language designed to take the best from all languages.

I terms of cars:
Perl is old dirty Range Rover without one wheel when Python is new concept with anti-gravitation drive from exhibition.

Thanks for sharing information. I am so thankful.

Why do people say such ridiculous crap like that? I agree phthon is a great language, but perl is not a creaky old language chugging along on three wheels.

Phython is not all that new. Its only 4 years younger than perl, which appeared circa 1987, with python appearing circa 1991.

Perl and python have a lot in common. Automatic memory managment and dynamic data types make them very similar to write code for and think of in the same way. Both have a large library of modules.

Thanks for sharing this info! Very useful! I start leaning this scripts.

The differences are they are two different languages, and nothing more. Just like the differences between PHP and Python, Ruby and Python, C and Python and so on. There are always people that like one language or hear something about a language and believe what they hear, and use those feelings to act like one is better than the other. None of it is true. All of these languages are excellent. In fact, Perl is more mature than most and offers better reliability and security than most (comparing it to things like PHP, for example, and that’s not to say PHP is bad).

Perl also offers OO if you want to use it, it’s just not forced on you by design. Some people think that makes Perl a worse choice compared to Python. Again, that is not the case. That’s like saying C is not good because C++ exists and is OO. It doesn’t at all take anything away from C and it’s a standard and is excellent. Perl is very powerful and very flexible. If you understand the language well enough, you can have scripts be stable, secure and work bug free for many, many years. There are absolutely no drawbacks to Perl. The same is true of Python, if you know it well, then you’ll be set.

Perl has been widely used for decades and remains well used and powerful. It’s always growing, just like Python, PHP and Ruby. You can’t lose knowing any of them. Look into them and see what one’s you like best and excel it in, or just learn both. It truly gets tiring seeing people bash languages that they don’t understand at all, when they are excellent choices.

All of these languages are excellent.

It can’t be! If they are different then something must better and something is not so excellent.
If we have Hundai, Toyota and Jaguar. Can we say all these cars are excellent?

Programming language must be simple to read and easy to learn and write.
Perl and C are examples of most complex languages among popular languages.

I do not think it worth to invest in Perl coding if you are able to use different language.

To assume that some languages must be poor languages because of the “choice” is more than a little short sighted. This is like saying that one car is a better one than another because of the color options. Just because you like one car better than another because of the color, doesn’t mean it’s a better car, especially for someone else that doesn’t care about the color, but the use.

Clearly, some languages are better suited for certain tasks, but they can all perform mostly the tasks, and many just as well as the other, provided you compare one proficient programmer in one language to another in another language.

I’m sorry, but you’re just showing ignorance about programming if you claim that they “mist be simple to read and easy to learn”. The famous “C Programming Language” book by Kernighan and Ritchie is ~190 pages, without the attached reference manual, which only brings it to a total of 258 pages. It’s short, easy to understand and one of the most powerful and most used languages in the world for the last 30 years,

The Perl language is painfully easy to use and understand. Perl, like C, and like PHP, Ruby, Python, C++, and any other language, can certainly get involved and complex, but only if you make it complex. Nothing in any language is difficult to grasp. If you don’t have the mind for it, and thus think it’s too complex, then you don’t understand it, and you not understanding it doesn’t make it a poor choice for someone else.

In fact, for web applications and data processing, especially working with text (which 99% of the web related files are made of), it’s a superior choice. Again, simply because you don’t agree it’s easy or readable or non complex, doesn’t make it so. I should know, I’ve been coding in all of these languages for years, and I’d certainly know if one was that much more complex over another.

I don’t recommend anyone listen to this guy. It’s ludicrous to claim that Perl should be avoided. Notice I’m not bashing any language, because they are all worth learning, and Perl is certainly common and powerful enough to justify. Just knowing only Perl would provide you with the tools to do anything anyone could throw at you that can be done in any other interpreted language. It’s sad to see people making claims about programming languages, arguing and flaming about it, when they have no basis for doing so.

I can’t agree that web apps is all about text processing.

Does Perl is exactly easy to read and understand as Java or Python or even PHP?

I think it’s obvious that how “easy” a language is to read, depends on the person and what languages they know. You don’t know Perl, you claim to know Java and Python, so of course it’s going to look unfamiliar to you. If you had someone that just coded in PHP or Perl look at Python or Ruby code, there would be a lot of things they didn’t understand either. How can you actually argue that Perl is a poor language because you don’t know it? If you knew it, you’d therefore be able to understand it and it would be easy to read and use. If it WASN’T easy to read and use, then that shows that you don’t know it. You can’t have it both ways.

That’s like saying that a spoken language (French, for example) is more complicated and not as good of a language as Russian. Well, if you KNEW Russian and not French, then clearly French is going to appear to be more difficult to read and understand. That doesn’t mean one is better than the other, unless you happen to be living in Russia or France. For example, it’s clear that English isn’t your first language, so maybe you’re just not understanding it, and maybe it makes you angry? Quick, what is the best spoken language in your opinion and what one is a bad choice to learn if you wanted to learn a foreign language?

Actually, never mind, I see your problem. You’re one of those people that bashes languages you don’t understand. I just read over this thread: http://www.sitepoint.com/forums/showthread.php?t=573113 and after seeing you actually blame the PHP language because of how poorly a web host decides to set it up or fail to secure the server, I don’t think debating about languages with you will get either of us anywhere. For your information, there are plenty of exploited scripts/programs that are insecure which are written in a lot of languages and use a lot of different API’s/interfaces.

The fact you continue to yell about how PHP is bad because someone decides to run it insecurely and in the Apache API as a module and without any real security settings, shows you know nothing about the most basic things regarding the languages and how they are ran. The user PHP scripts run as have nothing to do with the language. For your information, Ruby and Python can run as the global web server user (nobody) as well, and on a poorly set up server, you can still read other user’s files. That’s not the language’s fault, it’s the server admin’s fault for not setting up a secure web server environment.

A poorly coded script doesn’t mean the language is poor. An insecure script doesn’t mean the language is insecure. An insecure server setup doesn’t mean the language is insecure. For example, we run PHP with the suPHP wrapper and PHP scripts run as the user’s own ID, not the global web server user (nobody). We implement many things to run it securely, but it’s not the language, it’s the interface and how it runs in the web service. I’m not going to get into a debate, especially if it’s not based on anything legitimate. I’m not upset that you feel the way you do about Perl, but for God’s sake, man, have a rational and valid reason to argue that a language is bad.

Offtopic: PHP for me is not just language but how it is used. When I spoke about PHP I mean how it is used usually. (I think php thread is closed if you wish to reopen it then we will talk in different thread not here)

I have programmed multi-process daemon many years ago in Perls + many cron tab scripts.
I remember that default Perl build does not support threads and many perl modules are not thread safe.

I think Python has a better threads support.

What is important for me is that Perl is hard to read. It is hard to read perl code.
When I firstly read Python code I understood it.

Please don’t formulate your opinion as a fact. I’m sure there are people out there that find Python hard to read, and Perl easy.

Like The Greer tried to explain to you several times, its a matter of opinion. It’s okay to express that opinion, but right now you’re only using the authority argument to try and win some argument that can’t be won, because there is no “good” and “bad” in this matter.

Ok. That is my opinion but we are sharing our opinions about Perl vs Python

Let wait when someone will tell that python is harder to read or more complex to learn.

The problem was your first “opinion” was so one sided and not correct (although it is an opinion so there might not be a correct or incorrect) there is no way to want to agree with anything you said. My experience is that perl is harder to learn, not by much, python is easier to read, but not by much.

Does one outperform the other? Depends on the application. Perl makes writing real world applications fast and easy, python might too but I don’t have enough experience to say with any authority.

That ends my participation in this thread.

Okay, how about this then; I was using Perl back before Python was created. A few years after Python was more popular, I looked into it and attempted to browse over some code. It was more difficult to read and understand. Why? Because it was new to me and I knew Perl well. Does that somehow mean that Python wasn’t as good as Perl? Of course not. So, at that time, Python was indeed more difficult to read. As for how “complex” a language is, I suppose if you don’t know it at all and try and understand it, it’ll appear to be complex. Anything will be complex in appearance if you don’t know it. I really don’t see any room for debate here, and continuing this conversation would be a waste of time better spent on other things.

Probably the biggest difference off the bat is that Python uses whitespace (ie, indentation) as syntax, in that it is required. I don’t know of any other language that does this.

Python’s OO implementation is probably better than Perl’s (or at least a bit more intuitive). I love Perl but I’m not a fan of writing OO code in it. On the other hand, Perl’s regular expression implementation is a lot more intuitive than Python’s (and just about every other language as well). Regexes are a bit of an arcane tool, but incredibly useful once you get familiar with them.

Perl and Python are pretty ubiquitous too. Perl comes with just about every modern Linux/BSD distro (I think Python does too) and both are available on Win32 platforms as well.

I don’t know nearly as much about Python as I do about Perl, but I think you’d be fine doing either. I think Perl is falling into disuse as a web language in recent years, but it’s still arguably the most useful sysadmin’s scripting language.

Cheers,
D.

Python didn’t come in the box with my Debian 4 (Etch) installation, had to add it manually.
I believe Perl came in the box :slight_smile:

Well, you could stretch that buy saying that there are official packages for it for about any distribution without having to otherwise configure or leave apt-get :slight_smile:

Yes, it’s probably just a single shell command away on any distro.

Cheers,
D.