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.
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?
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...
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.
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.
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.
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..)
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.
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
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.
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...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.