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.
python, I haven't used as much, but my understanding is that it's more suited for object oriented programming and possibly web programming. (I'll let the python advocates speak more to this ).
it can be used to create OO programs using classes/inheritance and all that OO jazz. but there is also nothing stopping you to write programs in a "procedural" way, such as what you do in scripting. Python can be used to do a lot things besides the ones you mentioned. however, as a beginner language, its still better than Perl. The benefits are apparent especially when OP reaches the level when he needs to learn OO. Perl OO is, ermm, well.....
Quote:
Perl code can get ugly if the script gets too large.
at least you are not in denial. its commendable
Quote:
python may inherently be able to handle this situation better.
I have a 2000+ line perl script to manage gzipping and sending 18 virtual disks for 4 virtual machines to 6 different staging servers...all which have to be in different directory locations. It's all menu based using ANSI color modules, and generally pretty easy to use. But it sucks to the person who gets to maintain it after I'm gone. Such questions like, why are there 10 hashes all with the same key?, and why the **** is he using xor operators on these variables? I have comments where I can but still it's got to be quite daunting to figure out what was going through my mind at the time, especially if I'm not around to answer questions. It's one of those scripts that had to be done, and I just got so engrossed in it. But deep in development I had to think...hmm is this the situation where all of the python programmers are bragging that it's better for?
But to knock on python, indenting is the not way to indicate the next flow of logic...perl has 1UP on python in that regard
--Shaun
Last edited by binary_pearl; 01-23-2011 at 10:19 PM.
Reason: typos and other thoughts; yay for drinking and posting!
It really depends on the problem that you are trying to solve. I find learning a language for the sake of learning a language is not an effective way to remember it. It's more effective to use a language to solve a particular problem. If you don't have a specific problem...create one Maybe there are tasks you want to automate with getting input from a web site, or maybe you are looking to parse output to do something with it.
perl is my main weapon of choice, because my job is heavily based on local, server-side scripting. perl allows me to develop scripts rapidly; from configuring networking to watching VM's go down, to parsing output from many different commands. This is especially useful when only about 5% of my day can be spent on coding.
python, I haven't used as much, but my understanding is that it's more suited for object oriented programming and possibly web programming. (I'll let the python advocates speak more to this ). Perl code can get ugly if the script gets too large. python may inherently be able to handle this situation better.
Debating the subtle semantics of the languages though isn't going to help the original poster decide which language to use. The best thing is identify what the poster wanted to solve, and then give them suggestions on which language would be best to use. One that's determined, it's probably best to go to google and type "$language tutorial" and start following a tutorial to start learning the language in question.
--Shaun
The problem i want to solve is to validate a XML file for its syntax..so which language do you suggest.
But to knock on python, indenting is the not way to indicate the next flow of logic...perl has 1UP on python in that regard
indenting is a good habit, no matter which language. difference is, some (those who just beginning for example) don't indent whatsoever. Python just enforce that good habit, that's all.
Am confused now, after reading the responses i felt i will go for Python...Ruby???? am hearing it for the first time wot should i do???
forget about Ruby for a while (they are both similar, but Python is more "established"). Just go with Python. After that, you can play with Ruby all you like.
forget about Ruby for a while (they are both similar, but Python is more "established"). Just go with Python. After that, you can play with Ruby all you like.
indenting is a good habit, no matter which language. difference is, some (those who just beginning for example) don't indent whatsoever. Python just enforce that good habit, that's all.
Indenting need not be a syntax error. This reminds me of my mainframe days with cobol, where every line had to start at a specific column. Yay for punch card emulation.
For new programmers, teachers and tutorials should emphasize code style early on. It's not the language's responsibility to teach people correct form. It's the responsibility of those who have learned what to do and not to do to teach those what to do.
My environment may be different than a lot of people's because everything we do is ad-hoc and ultra fast paced. Sometimes I may only get 30 seconds here and there to try to code something before I get interrupted. So If I write a block a code, it has to work. I may not get a chance to fix it unless it breaks in production. I have to live by the motto: "Fire, forget and hope the hell nothing breaks". Not saying that it's the way it should be...but it is what it is. So the the more free-form the language is, the better chance I have of getting a script working in the very limited time I have.
I'm not so much knocking python (except for the indenting thing ), more of justifying the use case for perl. python has advantages, which have been basically summarized earlier is this tread. Each language has it's niche and purpose. Perl is part of what has kept me employed the last 4 years, and I have crafted some really cool, life saving, and amazing scripts with it.
The important thing though is that ajeesh.tr (original poster) was able to have his question answered. The overwhelming response is that python is the way to go. But there may be someone down the line who sees this thread several years later, and their use-case happens to be similar to what I have posted about. I have had several incidents where a post from lets say 2003 made the difference between a go or no-go decision on whether to convert 7000 servers or stop it completely.
If people can benefit from this thread, whether it be now or many years down the line, that's my goal. I hope that the next person asking about perl vs python can help make their decision based upon the information in this tread.
Indenting need not be a syntax error. This reminds me of my mainframe days with cobol, where every line had to start at a specific column. Yay for punch card emulation.
For new programmers, teachers and tutorials should emphasize code style early on. It's not the language's responsibility to teach people correct form. It's the responsibility of those who have learned what to do and not to do to teach those what to do.
sure, you can teach and tell people to indent, but still , some people don't. Or some does it another way , or some indents too much , or blah blah various other reasons. It is always a bonus if the language enforces such rules, there will not be any ambiguities.
Quote:
So the the more free-form the language is, the better chance I have of getting a script working in the very limited time I have.
the more free form you have, the more chances of people who are not used to those forms to get confused by your code.
Quote:
I'm not so much knocking python (except for the indenting thing ), more of justifying the use case for perl. python has advantages, which have been basically summarized earlier is this tread.
Both Perl and Python have their advantages , that's true i agree. However, Python's advantages outweigh Perl's
Quote:
Each language has it's niche and purpose. Perl is part of what has kept me employed the last 4 years, and I have crafted some really cool, life saving, and amazing scripts with it.
I am sure those can be crafted with Python, with much easier to read code, both for yourself and your successors
Quote:
I hope that the next person asking about perl vs python can help make their decision based upon the information in this tread.
The answer is always going to be the same ( which one is a better beginner language) , Python.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.