- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Performance issues -- Perl vs. ksh-93.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 07:57 AM
тАО11-13-2002 07:57 AM
We all know about the joys of Perl but I have to defend the following argument:
"For my money ksh-93 beats Perl for performance, readability, and usability."
I believe that this person is not a Perl expert. Nevertheless, he is highly intelligent and I need some help to convince him(and myself:).
Thanks,
Leslie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 08:09 AM
тАО11-13-2002 08:09 AM
Solutionperl seldom wins in actual execution time, unless you do highly advanced stuff in connecting different databases and such in which perl is virtuously unbeatable. Execution time should not be the issue. Development time should.
One *HUGE* advantage of perl over ksh is that you can chage (long running) scripts *while* they run, because perl reads the script before it executes. Try that with ksh, and you get a nasty surprise.
FWIW, I think that perl beats ksh in readability, usability, and documentability
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 08:16 AM
тАО11-13-2002 08:16 AM
Re: Performance issues -- Perl vs. ksh-93.
This is really not a fair comparison because to do this comparison you really have to change your statement to something like: "For my money ksh + awk + sed + tr + cut ... beats Perl."
I will concede that Perl can be written to appear to be almost gibberish and still function well. Some Perl programmers consider this a wonderful trait; I do not. There is nothing like coming back to some code written six months ago and trying to figure out what this incredibly cute and powerful one-liner does. Perl does not have to be obscure. I tend to write very clear code because I know I might have to change it someday.
You are also ignoring one extremely good feature of Perl - portability. Many of my Perl scripts can run completely unchanged on Windows as well as other platforms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-13-2002 11:03 AM
тАО11-13-2002 11:03 AM
Re: Performance issues -- Perl vs. ksh-93.
I feel this is undeserved. Any language can be
abused. How about this common nugget of ksh:
export FILE=$HOME/.envfile
export ENV='${FILE[(_$-=1)+(_=0)-(_$-!=_${-%%*i*})]}'
When I write Perl the code is virtually
indistinguishable from C code. I also avoid some
of the shortcuts that often cause unreadability
in Perl.
As for usability, I concede that Perl is not a very
good interactive shell (base Perl anyway, there's
probably an extension module that provides an
interactive shell). However, Perl has an excellent
debugger, while AFAIK ksh only has kshdb, which
is rather primitive and is a user-contributed item
from the O'Reilly ksh book (Rosenblatt). For
complex programs printf just isn't enough for
debugging.
As for performance, I suspect Perl will be faster
because it is essentially a compiled language
rather than an interpreted one. It also goes
through an optimization phase before it is
run.
Also, for complex operations ksh will probably
have to spawn external programs like awk, grep,
etc. while these can often be done internally in
Perl, which will be much faster.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2002 12:14 AM
тАО11-14-2002 12:14 AM
Re: Performance issues -- Perl vs. ksh-93.
The readability might not always be easy to grasp for someone who is not used to perl. But that is just a side effect of being a beginner. just like for a beginner it's hard to understand every shell script. the message is always the same, you can make things as complicated as you want/can.
Perl is also capable of doing advanced stuff which you can not possibly do with shell scripting (most of which you don't need for system maintenance tasks, but still...)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2002 07:14 AM
тАО11-14-2002 07:14 AM
Re: Performance issues -- Perl vs. ksh-93.
1) Understand the implicit contexts.
2) Get a strong grip on Perl's concise data structure handling. (Hash, array, refs, and all possible combinations)
3) Master regex -- the Perl way. There's a lot to be fitted here, I believe that this is the most important step.
What are your thoughts?
BTW, and let's try to argue for the sake this 'guy'...:) What are the situations where you *should* use the Shell?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2002 08:13 AM
тАО11-14-2002 08:13 AM
Re: Performance issues -- Perl vs. ksh-93.
?? When it can be done in two lines of less than 78 characters
?? When perl is not available
?? When the script is short and is to be called from cron or at
?? When there is a lot of simple interactivity (though very easy to do in perl, it is most likely that (beginner) scripters read things easier in shell
For perl
?? Understand perldoc
?? Understand CPAN (and *use* it)
. Understand basic flow control. I mean that perl has some control structures that other languages lack:
if ($expression) { action () }
$expression and action ();
action () if ($expression);
are all the same
And for long(term) projects:
?? Understand modules
?? Understand POD
Don't be afraid to use the perl newsgroups and forums. Perl people tend to be very helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-14-2002 10:45 AM
тАО11-14-2002 10:45 AM
Re: Performance issues -- Perl vs. ksh-93.
existing commands. For example, if
you have to set environment variables
before you run a program, a wrapper is
the perfect way to do it. You could tell
users they have to set up the env vars
in their .profile or .login files, but I prefer
to do it automatically because users
can't be trusted. You could also set the
vars up globally, but I don't want to pollute
everybody's environment with stuff they
don't need. Another reason for wrapper
scripts is to do clean up after the process
completes. For example, the version of
Matlab we have here doesn't exit cleanly
on HP-UX, so after you quit you
sometimes have to kill leftover processes.
(Actually, the other admin wrote that script
in Perl; if it were me I'd have written it in
ksh.)
Critical admin scripts should probably be
written in ksh or POSIX sh (and use the
version of those shells on the root filesystem).
Perl is probably in the /usr or /opt filesystems,
so if you're in single user or LV maintenance
modes Perl may not be available. (I prefer not
to install Perl in /.) The same is true for scripts
in the startup and shutdown sequences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 12:13 PM
тАО12-10-2002 12:13 PM
Re: Performance issues -- Perl vs. ksh-93.
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=13&t=000575
And some nice words from one of the Moderators of that forum.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 03:47 PM
тАО12-10-2002 03:47 PM
Re: Performance issues -- Perl vs. ksh-93.
FWIW I'll stick to perl if you don't mind :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2002 04:51 PM
тАО12-10-2002 04:51 PM
Re: Performance issues -- Perl vs. ksh-93.
Some questions for DK or ME:
(1) How would one "extend" KSH-93? Would it be as simple as perl :-?
(2) Can a shell script in ksh be compiled into a run time program :-?
(3) Is there an awk to ksh converter :-?
(4) And what does one do without Data::Dumper ??
Of course, my favorite feature in perl is: hash of hashes.
I have converted hundreds of ksh scripts to perl, and I have NEVER found a single case where ksh was faster than perl. I have seen ksh scripts literally beat the crap out of machines, and when converted to perl they behave very well. Now, if someone has an example of where ksh is faster than perl, I'd like to see the two pieces of code!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-11-2002 10:50 AM
тАО12-11-2002 10:50 AM
Re: Performance issues -- Perl vs. ksh-93.
Harry, Harry, Harry, Harry:)
I could not have done it better myself, and there are plenty of uses for Perl before we go to "hash of hashes". The regex flavor and the command line interface is just mind-boggling.
There is one thing where awk has the edge over Perl, (unless this was changed in 5.8, please let me know if it did): The -F switch and the $/ (RS variable), awk allows a full fledged regex and Perl doesn't:(
BTW, I recently came across this link:
http://perl.plover.com/qotw/
You may want to subscribe, I did.
The most amazing quizzes that you can think of in Perl. I challenge anyone to take any Perl solution and re-write it in C or (horrors) Java.
Thanks Harry!