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.
Sorry, I really can't help you with that. I don't know perl at all.
But I suspect "readable code" would be one.
As I wrote elsewhere - learn the alphabet first.
My other examples:
Code:
foreach my $element(@elements)
{
# do something
}
unless($condition_is_met)
{
# do something
}
- the point is that due to notation I can simply read
foreach my $element(@elements)
as
for each my element at elements;
I can read
unless($condition_is_met)
as
unless condition is met
and so on.
So, what's the problem with readability ? Does Python have "unless"
("unless($condition_is_met)" means if(!$condition_is_met), which can be better said if(not condition_is_met) ?
Does Python have "or", "and", "not" keywords which help readability ?
foreach my $element(@elements)
{
# do something
}
unless($condition_is_met)
{
# do something
}
- the point is that due to notation I can simply read
foreach my $element(@elements)
as
for each my element at elements;
I can read
unless($condition_is_met)
as
unless condition is met
and so on.
So, what's the problem with readability ? Does Python have "unless"
("unless($condition_is_met)" means if(!$condition_is_met), which can be better said if(not condition_is_met) ?
Does Python have "or", "and", "not" keywords which help readability ?
That's why i said you have to really learn about Python to use how its used.
Code:
for i in a_list:
print i
the above is your equivalent to your foreach() Perl construct. No pesky open and close brackets, no semicolons to denote end of statement. definitely easier on the eye. If Python don't have unless construct, it means it doesn't need one. Normal while loop with condition is enough to implement it.
the Python "not":
Code:
b=[1,2,3]
a=4
if a not in b:
#do something
the Python "or"
Code:
if a in b or c in d:
# blah blah
Last edited by ghostdog74; 02-17-2009 at 05:39 AM.
If Python don't have unless construct, it means it doesn't need one.
Actually, this strikes me as true by design - to twist a phrase. As I understand it, Python's guiding principle is that there should be one (and only) one way to do things. Thus, you don't get both if-not and unless - just one. Perl's guiding principle (or one of them) is that there should be lots of ways to do things. Thus, you get if-not and unless, while-not and until, etc.
For whatever it's worth, Damian Conway recommends never using unless or until in his Perl Best Practices book.
We now return you to your regularly scheduled holy way - already in progress...
Actually, this strikes me as true by design - to twist a phrase. As I understand it, Python's guiding principle is that there should be one (and only) one way to do things.
Actually, this strikes me as true by design - to twist a phrase. As I understand it, Python's guiding principle is that there should be one (and only) one way to do things. Thus, you don't get both if-not and unless - just one. Perl's guiding principle (or one of them) is that there should be lots of ways to do things. Thus, you get if-not and unless, while-not and until, etc.
For whatever it's worth, Damian Conway recommends never using unless or until in his Perl Best Practices book.
We now return you to your regularly scheduled holy way - already in progress...
Well, even in "C"
Code:
#define UNLESS(cond) if(!(cond))
- any language with macros allows such a trick.
And syntax sugar, well, sometimes is really sweet.
But my point is different - languages evolve, so a claim that if a language doesn't a feature it means it doesn't need it is funny.
...
Well, in our comparison of features we haven't elaborated on data/code export/import yet.
I have done extensive work in PERL, Python, PHP, LUA, and many compiled languages.
It is all a matter of what suits your needs. Any programmer that pigeon holes their beliefs into a single language is fit into one thing, A BAD PROGRAMMER! No one language is going to fill all needs.
If I have to write a fast web app, I use php. If I have to write a fast text or log parser I use PERL. If I have to write a fast multi-control script that can be extended, I use Python. If I am writing data interpreters for MySQL or tight embedded data controls, I use LUA. It is all about solving a problem with the most appropriate means.
A program to parse an apache log to an easy to read format in PERL might be 20 lines of code, while it is 100 in Python, while a script to control the flow of the start of a daemon or string of daemons on a node in a computer cluster can be done with PERL, the script would be much shorter and easier to manage in Python, AGAIN IT IS ALL ABOUT THE PROBLEM YOU ARE SOLVING.
So stop the 2 year old argument that makes you all look like horrid programmers.
This is funny, after 3 pages of bickering, the question hasn't really been answered-
Quote:
I just saw that Python is "the programming language of the year".
I study Java (for 2 weeks now) at my school and I think its good enough.
What makes python so good and popular?? Can it do all the thinks Java and C++ can??
No, Nesrail, Python cannot do all the things that C++ and Java can do. They compile into binaries that you can take and put where ever and Python compiles on the fly and dumps the binary after it's run. It's like comparing boats to cars, both are vehicles but they serve different purposes.
EXAMPLE: If you want to write a game, use C++. If you want a program to make sure databases stay clean, use Python (or Perl).
Now, as for the "programming language of the year", don't read much into that. Basically more Python guys wanted it to win so they voted en masse.
As for the Perl vs. Python argument, After reading all these pages, What I got out of it was:
1) Perl sucks because it can be hard to read.
2) Python sucks because it can be hard to read.
3) Perl sucks because it is too backwards compatible.
4) Python sucks because it's not backwards compatible enough.
5) Perl sucks because it's old and has too many features.
6) Python sucks because it's not old and doesn't have many features.
As for the Perl vs. Python argument, After reading all these pages, What I got out of it was:
1) Perl sucks because it can be hard to read.
2) Python sucks because it can be hard to read.
3) Perl sucks because it is too back-wards compatible.
4) Python sucks because it's not backwards compatible enough.
5) Perl sucks because it's old and has too many features.
6) Python sucks because it's not old and doesn't have many features.
Did I miss any of the Perl vs Python points?
A suggestion for you. Learn Perl for 1 week. Then Learn Python for another. See and judge for yourself. That's the only answer. As for the above 6 points, you are joking right?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.