LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2006, 07:40 PM   #1
drdroid
Member
 
Registered: Oct 2003
Location: Here
Distribution: Redhat 9.0
Posts: 124

Rep: Reputation: 15
Python or Perl


I have some pretty good c++, basic, fortran, javascript/html under my belt. I want to learn linux scripting that can eventually be used for networking, systems anything. What do you suggest? And by your opinion, which is best? Perl or Python?
 
Old 01-22-2006, 01:19 AM   #2
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
If you search the forum, you'll find lots of threads about this very topic.
 
Old 10-25-2006, 10:00 AM   #3
Jack Deth
LQ Newbie
 
Registered: Oct 2006
Location: Toronto, ON Canada
Posts: 7

Rep: Reputation: 0
Quote:
Originally Posted by drdroid
I have some pretty good c++, basic, fortran, javascript/html under my belt. I want to learn linux scripting that can eventually be used for networking, systems anything. What do you suggest? And by your opinion, which is best? Perl or Python?
You know alot of people try out the WebAPP Script which is perl based, and from there I have seen them get into perl big time seeing how its one of the easiest to learn but hardest to master languages out there...

check it out at http://www.web-app.net and see if it does what you want... can be used for web portals or internal portals...

Last edited by Jack Deth; 10-25-2006 at 11:22 PM.
 
Old 10-25-2006, 10:26 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
answer yes,
they are both lovely languages,
see the big post on this very forum (lots of bored people out there)
 
Old 10-25-2006, 06:33 PM   #5
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
if you have time, i would suggest learn both. A lot depends on your taste/preferences, as well as the problem to be solved at hand.
Personally, i use Python alot. My "taste" is i like its readability and i don't like those extra ";{}" in most other languages. And i also don't care about speed as my problems to be solved does not require speed. Like i said, these are my own preferences, so you have to find your own.
 
Old 10-26-2006, 02:12 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
good advice ghostdog.

python slow?
at the risk of sort of hijacking the thread how do you find python speedwise?

I use perl a lot and have found it almost as fast as a bit of C code
for text and file processing type stuff (bulk of my work). So much so
that i don't bother with C anymore.

I did a quick test python v. perl, just slurping /usr/dict/words, randomising and printing out and found python slightly faster, which
surprised me.
 
Old 10-26-2006, 03:29 AM   #7
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Perl has some of these bizzare, secret handshakes almost.
 
Old 10-26-2006, 08:30 AM   #8
Jaqui
Member
 
Registered: Jan 2006
Location: Vancouver BC
Distribution: LFS, SLak, Gentoo, Debian
Posts: 291

Rep: Reputation: 36
as ghostdog said, it's personal preference that determines which is best.

perl, fantastic tools for text manipulation.
python, not so much with the text.
[ python is far younger and does't have the same library availablity as perl ]

but any language is a valid option for use as a bash script, including compiled languages. You have c++ skills, write your script as a cli c++ app and compile it, then you can call it like any other script.
heck, even php can be used for a bash script.


bigbearsbilly,
I bet python is faster because of the number of modules you have installed for perl

The more capable a language is the slower it will perform, simply because the interpreter has to scan a larger database of available functions to make sure it has the ones needed for the script. This is why interpreted languages are slower in performance than compiled languages usually.
[ use c or c++ to go through your little test, I don't think they will be as fast as either perl or python ]

I would use whichever language I know has the best toolset available for the task that needs to be accomplished. This means any particular script can be written in any language I'm capable of writing in, not just one language only. This has the benefit of using the best tool for any particular job, instead of a single multitool for every job.

Last edited by Jaqui; 10-26-2006 at 08:32 AM.
 
Old 10-26-2006, 08:52 AM   #9
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
Quote:
Originally Posted by drdroid
I have some pretty good c++, basic, fortran, javascript/html under my belt. I want to learn linux scripting that can eventually be used for networking, systems anything. What do you suggest? And by your opinion, which is best? Perl or Python?
imo, perl. but i have barely used python (does hello world count?).. so i guess im not qualified to answer this question at all.. im leaving..

(seriously though, i find Perl to be lots of fun and would definately reccommend learning it sometime.. whether you should do that before or after python i cant say..)
 
Old 10-26-2006, 09:19 AM   #10
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 547

Rep: Reputation: 30
I've been writing Perl scripts in the last year and a half to do some fairly complex tasks. But now, I am going to re-teach myself Python and switch to that language because I am fed up with Perl. Writing Perl code has to be one of the most frusterating programming tasks I've ever done. I just think that syntatically speaking, the language is poorly defined (I know this is intentional, but still) and reading Perl code is not intuitive so I often have no clue what a snippet of code does. The only thing I dislike about Python is the forced indentation (I feel that's not the job of a programming language), but its much more sane than Perl IMHO.
 
Old 10-26-2006, 08:49 PM   #11
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by R00ts
The only thing I dislike about Python is the forced indentation (I feel that's not the job of a programming language), but its much more sane than Perl IMHO.
Welcome to Python
and you shouldn't have to dislike it because of the indentation. After a while you will get used to it. Sometimes when i switch back to writing Perl or other languages, my fingers automatically will press the tab key to indent every time i reach a new line..haha
 
Old 10-27-2006, 02:59 AM   #12
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,848

Rep: Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584Reputation: 2584
Interpreted langs a much slower because they re-compile each statemnt on the fly, every time it is used.
Also, in bash you are often calling other progs eg sed, awk etc... This means creating a new process each time.
Compiled langs already have everything they need in binary format before they start.
Perl is more of an 'executable environment' (see http://www.perl.com/doc/FMTEYEWTK/comp-vs-interp.html )
As mentioned in another thread, it's pretty quick, say 90 % speed of C.
 
Old 10-27-2006, 04:18 AM   #13
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
the indentation is a fabulous idea. simple and saves typing braces and such
 
Old 10-27-2006, 06:43 AM   #14
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
I have written a Java application which is using connecting to OpenOffice to perform some macro and export the document as Docbook XML(may be one day Open Source).

The problem is that I have a lot of code which I have not time to refractor or improve a lot. It is difficult for a novice/junior programmer to understand my code(SpringFramework, Java Reflection, Interfaces, MVC, Swing, XML, XSLT). I used advanced concepts and patterns to design and program the application.

I took a look at Python, Ruby and Perl. I decided to evaluate Python. I can code faster and performance is not really an issue.
All I need to be able to do is to make the application evolve and maintain it.
If I have no time, then someone else should be able to work on the application without spending time training, reading or asking me all kind of questions.
I learn basics of Python in 4 days and I have almost the same application with less lines of code. Using the MVC pattern is not that difficult in Python. I didn't take a look at data bindings framework for Python(class model --> GUI). I don't intend to write such a framework for now...
It seems that Python will fullfill my needs.
------
Pros
------
* Lots of libraries
* Python is simpler than C, C++, perl, Java and some other languages.
* Clean code(indentation required)
* Object orient aspects(classes, packages, inheritance). With zope interfaces it is better.
* IDE support
* GUI designer support for wxWidgets, Gtk and Qt using wxglade, glade, xcred or any other commercial tool. The tools support XML resources or they can generate Python Code directly. I prefer to have the XML using XrCed and bind the GUI controls to events.
* Can do console programs, gui(wxpython, tkinter, pygtk, pyQt, fxpy, etc.) or web programs(Django, turbogears, etc.)
* Lots of libraries available
------
Cons
------
* Slower than Java
* Require "an abusive use" of self for classes' members
* Not that many good IDES except SPE, DrPython or PyScripter
* You often have to check the version of your libraries all the time to see if there are compatible with your version of python or any other dependencies that your program requires
* Python is not that used in the entreprise compared to Java, C#, Perl in that order.
* I miss Java Web Start because I release often and many users use my application.
I could use python twisted and write an updater...
 
Old 10-27-2006, 07:33 AM   #15
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by mrcheeks
* Slower than Java
May i know what are you comparing the speed against?
If its development time, then defintely Java is slower.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python or Perl? Boby Programming 2 06-12-2005 10:54 AM
bash, perl, or python? s_siouris Linux - Software 11 05-13-2005 03:15 PM
Perl or Python JJX Programming 6 10-27-2004 03:58 AM
Perl or Python ! linuxlover1 Programming 13 04-19-2004 07:33 AM
Perl vs PHP, PYTHON shebang Programming 5 02-14-2004 12:13 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration