Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comparison between Perl and Ksh

by bizzach (Beadle)
on Mar 06, 2002 at 19:07 UTC ( #149795=perlquestion: print w/replies, xml ) Need Help??

bizzach has asked for the wisdom of the Perl Monks concerning the following question:

My manager wants a document on the difference between Perl and Shell. Also, he is concerned that we are using a technology unsupported by Sun. He suggested that maybe we should do everything in Ksh. I didn't even know how to respond. I googled around but couldn't find anything. I'm hoping someone could point me toward documentation on the benefits of Perl. It needs to be a simple buy decisive document (for my manager).

Replies are listed 'Best First'.
Re: Comparison between Perl and Ksh
by data64 (Chaplain) on Mar 07, 2002 at 04:24 UTC

    Just calling managers stupid does not solve any problem. They just have different priorities then us programmers and it is actually a legitimate question from his point of view. (why use tool x v/s tool y) especially when he is under the impression that tool x is supported by Sun but tool y is not.

    Yes, I know that most of us know that Perl is obviously better than ksh scripts. But it needs to be presented in a rational, and convincing manner. Remember that he is probably not a manager for his technical prowess but for other qualities such as knowledge about the business, managing people, etc.

    Below are some arguments that I would put forward:

    • Perl ships with a debugger. This significantly reduces time spent in troubleshooting issues, tracking down bugs. Benefit is reduced development time and maintenance time
    • since perl is compiled first and then interpreted, it provides much better error checking. Especially when you use strict and warnings, a lot of problems are detected and the exact line of offending code is provided. This significantly reduces development time.
    • Since a lot of common utilities such as for sorting, searching, counting are build into perl, we do not need to keep starting a new process for each function. This tends to make perl scripts more efficient in term of system resources as compared to ksh scripts.
    • CPAN. There is a wealth of already implemented and rigorously tested functionality available. This can cut down development time by a large factor and allows your development staff to concentrate on the business logic rather than having to implement networking logic or algorithms, etc.
    • Persistent storage. Perl can connect to databases, Berkley db, text files, etc. AFAIK, ksh is limited to dealing with flat files. (This depends on what the project/application is.)
    • Complex data structures. Perl makes it very easy to create highly complicated data structures. These can model the business situation and provide a much more intutive approach to the programming task. This makes the problem easier to solve hence reduced development time. Also it is easier for a new team member to understand the system hence a new employee can be productive much sooner.AFAIK, ksh is limited to simple environment variables.
    • Concurrent processing is very simple in perl since we can fork, use IPC to synchronize, get status, etc. With ksh you can launch background process, but your scripts do not tend to have as much control on them (or atleast it is much more difficult AFAIK).
    • Object Oriented. Perl has pretty good support for OO, this makes application extensible and easier to maintain. They are also easier to understand.
    • Thanks to TK, gui developement (for admin tools) is a piece of cake. You can also do curses-like non X development. It just isn't that easy with ksh. Also, with perl you have the option of making the admin tools web-based since CGI and other modules make it very easy to put web interfaces together. And since its all in the same language it will interface well with other code/system/application.
    • If speed is of great importance, you have the option of compiling perl scripts into a binary executable. This will make it faster than any ksh scripts. (Before you flame me on this, just note that it makes a good argument)

    In my experience having some numbers to back up above can go a long way. So, for example if you can take a small representative task and record the time it took to do in perl and then in ksh. (Assuming perl will take less time) That could convince your manager like nothing else. BTW, quoting benchmark numbers from someone else is not as effective.

    You would also probably want to explain to your manager that the ksh support that sun provides is for fixing bugs in ksh not your scripts. And if vendor support is a major issue then it can be obtained from ActiveState. ActiveState does support perl on solaris.

    Just adding my 2 cents

    <cite>Just a tongue-tied, twisted, earth-bound misfit. -- Pink Floyd</cite>

Re: Comparison between Perl and Ksh
by Jerry (Scribe) on Mar 06, 2002 at 20:41 UTC
    I ran into similar feelings from my manager while working for UtiliCorp United, Inc (was Enron's main competitor). In a nutshell, perl has many advantages over shell, even a supported shell.

  • 1. Massive User Base - if the job isn't getting done with current staff, there are (literally) thousands upon thousands of programmers who CHOOSE perl on a daily basis and can come up to speed on any perl project in no time. (This makes recruitment far easier - there are more potential perl coding staff already available than most any rapid development language)
  • 2. High Presence on servers - stock setups of most any Unix-like OS come with perl preinstalled, even companies like Sun who wish to squelch open sourcers choose perl as a vital component of their systems.
  • 3. Rapid development with a wide variety of API's - Perl's easy integration, rapid development times, and support for a VERY wide variety of other software and hardware make it second to none. A Perl module can be quickly found or built to create a simple, useful API for most any need.
  • These are just a few examples summarized from comments already posted. Perl is fast, compatible, easy to use, widely supported, and very reliable - all the core needs of an enterprise rapid development environment.

    "In my line of work, I don't invent many wheels. I just custom fit wheels already in place."

Re: Comparison between Perl and Ksh
by traveler (Parson) on Mar 06, 2002 at 20:43 UTC
    While it depends greatly on the task at hand, some reasons I have not used ksh or bash for development are (in no particular order):
    1. If you have a situation requiring lots of operations where the shell would fork a simple program (e.g. date, rm, ln) and where perl would do it directly, the fork overhead may be very high.
    2. Perl code can be easier to maintain. Some shell-only programmers may disagree, but I tend to forget why I did certian "tricks" in shell scripts. But I can generally figure out my old perl scripts.
    3. Perl has better support for functions.
    4. CPAN
    5. Perl expressions are generally easier to follow than calls to expr/sed/grep.
    6. It is probably easier to find new good Perl programmers to add to a team than to find new good ksh programmers.
    I am in the process of converting most of my non-trivial shell scripts to perl. I recently tried to explain two large scripts, one perl one shell, to a group of inexperienced programmers. They could follow the perl, but not the shell, and the shell was much simpler code, honestly. The issue in that case was that the shell required verboseness and tricks that were not necessary in perl.

    HTH, --traveler

•Re: Comparison between Perl and Ksh
by merlyn (Sage) on Mar 06, 2002 at 19:48 UTC
    Also, he is concerned that we are using a technology unsupported by Sun.
    Whether or not it is supported by Sun, it's supported by a group that is far larger than the total number of employees that work for Sun, and will cost far less than a Sun support contract.

    -- Randal L. Schwartz, Perl hacker

Re: Comparison between Perl and Ksh
by thunders (Priest) on Mar 06, 2002 at 22:00 UTC
    Perl has all of the following going for it over ksh.
    1. It is a real programming launguage, you can write complete console, GUI, Web-based, heck any kind of software application in perl.
    2. Portable to Linux/Unix and Win32 and many others OS's
    3. Object Oriented capabilities
    4. Shells launguages generally just call other programs, perl can do this as well, and does this in a very flexible way.
    5. Support Modules for all three-letter buzzwords, XML, SQL, DDE, OLE, CGI, FTP, this may impress the boss, they all LOVE acronyms
    6. oh heck go ahead and use Shell; in your perl programs.
    7. all of this will go over your bosses head, so just focus on Buzzwords
Re: Comparison between Perl and Ksh
by jplindstrom (Monsignor) on Mar 06, 2002 at 19:30 UTC
    Also, he is concerned that we are using a technology unsupported by Sun.

    Perl is shipped with Solaris 8 (and 7 I think).

    Not that it's supported by Sun, but you don't have to phrase it just like that...

    Perl is supported by it's huge user base, in a quite excellent way. But you don't have to phrase it just like that :)


      My manager also had a problem with my use of Perl. I came up with a small presentation to show the advantages of perl over the current languages we were using for our tools, KSH and C. That really impressed her. I also made references to the sites I mentioned above to show her the vast support network Perl's users, and authors had created. She was humbly convinced, and very impressed.

      -- Yes, I am a criminal. My crime is that of defyance.
Re: Comparison between Perl and Ksh
by Anonymous Monk on Mar 06, 2002 at 20:48 UTC
    Perl is supported by Sun Microsystems Inc. Other posters here have mentioned that Perl ships with Solaris 2.8 and 2.9. In addition you could ask your manager to use a web browser thingy to follow this link to "Created and Sponsored by Sun Microsystems" for an update to Perl 5.6.1 for Solaris. Or perhaps your manager might like to follow recent discussions of Perl development for Solaris 9 held by Alan Burlison a Sun employee on the perl development list. Do note that on Solaris you can build Perl (and XS extensions) either using gcc or the Sun licensed Forte compiler. For better performance on SPARC try to build and install perl using the Forte compiler.
Re: Comparison between Perl and Ksh
by JSchmitz (Canon) on Mar 06, 2002 at 20:01 UTC
    Well you are is a tough spot that is for sure. I would try and put it to him like this. First of all Solaris 8 ships with perl. As far as it being supported well that just does not make any sense. If you write a script in Ksh or Perl even if you have a support contract does he think they are gonna debug it for you? I can tell you for sure they are not. Sun does however support it enough to ship it with their OS (finally) Also Randal makes a great point about a community that will be faster and more adept at helping you. Sun support covers things like bad controllers and bent pins on a scsi connector. They are not in the habit of debugging scripts. Tell him to go to a meeting and leave the programming to the programmers. = )
Re: Comparison between Perl and Ksh
by perrin (Chancellor) on Mar 06, 2002 at 20:24 UTC
    Does your manager know that the rest of us have electric lights and horseless carriages now? Maybe this article about Perl versus Tcl is relevant. It talks about Tcl as having typical drawbacks of shell languages. (Note that Tcl has actually improved dramatically since then, but Ksh probably has not.)

    UPDATE: This is another article, with more direct discussion of korn shell.

Re: Comparison between Perl and Ksh
by defyance (Curate) on Mar 06, 2002 at 19:13 UTC
    Try here PerlDoc

    Also Perl.Com

    And Last but not least in my list of suggestions: PerlMonks Tutorials

    Also IMHO I don't think that KSH can hold a candle to perl's functionality, wide array of uses, and portability. Thats just what I have found since I started using it a few months ago. Keep in mind, I started programming in KSH.

    -- Yes, I am a criminal. My crime is that of defyance.
Re: Comparison between Perl and Ksh
by mandog (Curate) on Mar 07, 2002 at 01:32 UTC

    Well your manager may be a moron, but I'm not sure "all the guys that like perl a lot say that it is better." will be very convincing....

    Maybe it would be convincing to post to a shell scripting group so you can say. "The guys on the shell group say if you ***must*** pick one, perl is better."

    It sounds kinda empirical to say stuff like:

    CPAN has __ hundred thousand modules and libraries, all with search able on line, documentation and the biggest shell script repository has ___ hundred scripts.

    Perl is more secure it has sandboxes like java and taint mode, and only interpolates once.

    There are ____ books on perl at O'Relly and ___ books on shell

    It takes ___ human (manager) readable lines of perl to do task ____ x and ____ lines of funky shell to do the same task

    email: mandog
      Another good manager-oriented comparison is:

      There are ____ (517) listings for Perl programmers on (or wherever), ____ (24) listings for ksh programmers. More people are using Perl these days than ksh, and longer term, it'll be easier and probably cheaper to find a Perl programmer to maintain the code than a ksh programmer.

      Managers like hearing that 'other people are doing it.'

Re: Comparison between Perl and Ksh
by cjf (Parson) on Mar 06, 2002 at 23:18 UTC
      Things are in fact changing at Sun. Take a look at this and this and this. Sun has been oscilating a great deal on Linux, but since the acquisition of Cobalt networks, they have been leaning more and more towards Linux. Business is Business, you know. People are realizing the value of Linux, and waking up to it. And, If I were to make a prediction, since the StarOffice license is changing to be free on only OSs that Sun makes, they probably will change it again to include Linux at some point down the road.

      We may in fact see a return to the "hacker" mentality that prevailed throughout the company through much of its early years.

      Just my 2 cents on the issue.
      Tempora Mutantur Nos et Mutamur in Illis
      "The Times are Changed Even as We are Changed in Them"
        Business is Business, you know.

        Consider the first article you linked to titled "Sun Broadens Support for Linux" and dated February 7th, 2002. Now read this dated February 20th, 2002. What's wrong with that picture? They're "broadening" their support for Linux alright, but as soon as there's the slightest hint its expanding into areas that could hurt their bottom line, they try to bash it back down.

        Sun wants to be seen as a nice open source friendly company, but in reality they are very far from it. As the article I previously linked to says:

        Sun loves to have Kodak moments with some parts of the open source community -- most notably, Apache -- who increasingly feel used and abused

        Apache's stance on the JSPA states "The JSPA must require that a JSR spec license cannot prohibit a compatible independent open source (Apache-style license minimum) implementation of a JSR." Which I fully agree with. Their current license is most likely legally indefensible, and definately is not what I would call "supporting open source."

Re: Comparison between Perl and Ksh
by steves (Curate) on Mar 06, 2002 at 19:19 UTC

    You have to be frightened that people like this are managing. This seems like a no-win. If he's asking that sort of question, chances are he won't understand anything you write up anyway.

Which ksh Are You Talking About? - Re: Comparison between Perl and Ksh
by metadoktor (Hermit) on Mar 06, 2002 at 23:39 UTC
    The latest Korn Shell might be of interest. I've heard that it is rather different (i.e. more powerful) than the ksh that ships with most UNIX systems.


    "The doktor is in."

      I know a handful of Korn advocators that boast that the Korn Shell does everything Perl can do, or at least has similar functionality.

      Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a (from-home) job
      s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Re: Comparison between Perl and Ksh
by quikwit (Beadle) on Mar 07, 2002 at 15:02 UTC
    Of course, shell scripts spend most of their time running other commands. Commands like echo, awk, and cut are no more a part of ksh than perl is.

    So go ahead and use ksh:

    #!/bin/ksh /usr/bin/perl -we ' for(1..10) { print "Perl and ksh can work together\n"; }'

    At least the manager isn't considering doing things in the shell which Sun helped popularize: csh!

      At least the manager isn't considering doing things in the shell which Sun helped popularize: csh!
      Uh, not really Sun's fault. It was part of BSD before Sun even existed.

      -- Randal L. Schwartz, Perl hacker

Re: Comparison between Perl and Ksh
by Marza (Vicar) on Mar 06, 2002 at 21:40 UTC
    Finding help on the Net. It has not been mentioned but I found it easier to get help at sites like perlmonks! ;-) for Perl issues. I didn't always find answers for shell scripting questions....
Re: Comparison between Perl and Ksh
by Anonymous Monk on Mar 07, 2002 at 22:39 UTC
    he is concerned that we are using a technology unsupported by Sun.

    Here are some more URLs for your boss to ponder:

    The Basic Perl course that Sun Microsystems Inc. teaches
    The Advanced Perl Programming Course that Sun teaches

    Yes indeed Sun Microsystems makes money off of Perl the same way that O'Reilly and Associates and several other well known consultancies do (quality of instruction?). They also sell an "Operating Environment" that comes complete with Perl pre-installed. To assert that Sun does not support Perl is equivalent to asserting that Sun does not support C, C++, or Fortran. They do in fact support all of those programming languages (as well as ksh and another one that is quite highly hyped).

Re: Comparison between Perl and Ksh
by kiat (Vicar) on Mar 07, 2002 at 10:26 UTC
    I've programmed in Perl for over a year and I've fallen in love with it - I've some experience in Java and C++ but they don't give me the same kick (but they are useful and fun in their own ways).
    Back to Perl, just the other day, I wrote a ten-liner to manipulate some 500 lines of text spread over a few files - deleting some part of the text and moving some other parts to the end of each line. With a one-line regular-expression, I was able to accomplish the task in less than 5 mins. It was just amazing how simple and powerful perl can be.
    I also use perl to write CGIs and I like it just as much.
    Allow me to quote this from Larry Wall's Perl Programming (3rd Edition, p. 4):
    At every level, perl is about helping you get from here to there with +minimum fuss and maximum enjoyment. That's why so many Perl programme +rs go around with a silly grin on their face.
    - kiat
Re: Comparison between Perl and Ksh
by donaldm314 (Pilgrim) on Mar 07, 2002 at 03:49 UTC

    Are you working in Calgary? I think I may have worked at your company in 2001. After only 5 months I moved on to infinitely greener pastures.

    My current employer has mandated that we use Perl for all scripting; no bash/csh/ksh/etc. allowed. We're also using it for everything from CGI to database access to a fully automated build system. Life is good!

Re: Comparison between Perl and Ksh
by jmcnamara (Monsignor) on Mar 08, 2002 at 10:56 UTC

    Also, he is concerned that we are using a technology unsupported by Sun.

    I wouldn't say that it isn't supported. Solaris 8 has Perl 5.005_03 as standard and Solaris 9 has Perl 5.6.1.

    Also, the Solaris 8 kstat(1) utility is written in Perl.


Re: Comparison between Perl and Ksh
by LupoX (Pilgrim) on Mar 07, 2002 at 04:21 UTC

    Perhaps you win the battle telling him perl also runs on Windows 8-)

Re: Comparison between Perl and Ksh
by greenFox (Vicar) on Mar 08, 2002 at 04:48 UTC
    I would also be asking just exactly what support Sun provide for ksh. ksh and perl are both standard packages on newer versions of Solaris, you may find that Sun "support" is identical for both.

    my $chainsaw = 'Perl';

Re: Comparison between Perl and Ksh
by juo (Curate) on Mar 08, 2002 at 10:42 UTC

    I think the use of Hash tables is one of the strongest points in Perl compared to Ksh. Also the wide free support of Perl is a very strong point. The possibility to use GUI TK module and many other modules is an advantage and many many more......

      Hashes, references, modules (and the huge number of modules that are available for free), speed, documentation, etcetera etcetera.
      What _technical_ reason would there be to use Ksh?

      ++ vs lbh qrpbqrq guvf hfvat n ge va Crey :)
      Nabgure bar vs lbh qvq fb jvgubhg ernqvat n znahny svefg.
      -- vs lbh hfrq OFQ pnrfne ;)
          - Whreq

Re: Comparison between Perl and Ksh
by Stegalex (Chaplain) on Mar 07, 2002 at 01:52 UTC
    Since when has anyone had difficulty running Perl on Sun? I like chicken.
Re: Comparison between Perl and Ksh
by dru145 (Friar) on Mar 08, 2002 at 17:58 UTC

    CPAN, CGI, CPAN, DBI, did I mention CPAN : )

    Another satisfied monk.
Re: Comparison between Perl and Ksh
by brentmaier (Initiate) on Mar 08, 2002 at 17:05 UTC
    Keeping this answer short and sweet... Perl is going to give you much more flexabiliity than Ksh. Complex programs will be more easily understood in Perl than they will in Ksh. I've seen some pretty complex and hard to read Ksh scripts. My two cents are don't go there unless Ksh offers something that Perl absolutely can't do.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://149795]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2021-03-05 04:41 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (109 votes). Check out past polls.