http://www.perlmonks.org?node_id=483216

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

Fellow monks

I work as a System Administrator, and I extensively use Perl every time that this means that it can help me to accomplish my job faster, automatically or more easily, that means: often.

Of course, I know how to make some shell scripting and I know how to mix grep, awk, sed together but...

...but I feel that it would be a good thing to know another programming language besides Perl, too.

I tried to think about it, but there is too much noise around (Java! Java!, or use Python!, or why not PHP?)... so much noise that I can't understand what is the good answer to the question:

What language would be more useful for a System Administrator that already knows Perl and wants to learn a second programming language?

Any good advice?

Thanks a lot

Ciao!
--bronto


In theory, there is no difference between theory and practice. In practice, there is.

Replies are listed 'Best First'.
Re: Learning ***** as a second language
by gellyfish (Monsignor) on Aug 12, 2005 at 09:40 UTC

    I would recommend C if you are working on Unix-like systems being the language that most stuff (including Perl) is written in. At the very least knowing C means you can tweak programs that you might want to use. I guess if you are using Windows you might want to consider learning C# which is likely to become the default "Scripting language" in forthcoming versions of WIndows.

    /J\

Re: Learning ***** as a second language
by neniro (Priest) on Aug 12, 2005 at 09:26 UTC
Re: Learning ***** as a second language
by Taulmarill (Deacon) on Aug 12, 2005 at 09:37 UTC
    coming from a shell scripting background where i used bash, awk, egrep and all those nice tools, i can give you the advice that you don't need another scripting language besides Perl.
    the intention behind Perl was to build a scripting language that could do what bash, awk, sed and all the other tools could do, which wore around about 20 years ago. so learning php, phyton or ruby is not a bad idea, but i don't think it will give you mutch benefit over Perl. maybe it would be a good idea to learn something different, which can do things you can't with Perl. let's say JavaScript for browser scripting or C for compiled stand alone programs which are way faster that Perl scripts. also you could benefit from C by using Inline::C in your Perl scripts.
      so learning php, phyton or ruby is not a bad idea, but i don't think it will give you mutch benefit over Perl.

      You're right on this, but learning another scripting-language helps to get another perspective. I started using anonym functions after I learned about lambdas in python and I learned about Mixins after I saw them in ruby - so it can be a benefit to learn other languages, even if their possibilities aren't much different to those of perl.

Re: Learning ***** as a second language
by hatter (Pilgrim) on Aug 12, 2005 at 10:27 UTC
    Depends where your job focus and interests are. If you're working on webby systems, then figuring out python or ruby might be useful for your next job - a lot of the background knowledge is the same, but you need the language knowledge to be able to apply it. If you're really all about the systems, the a good knowledge of C would help when you need to change the bigger tools you're using for your own needs. Or for large system automation/integration stuff, look at make, no doubt you use it regularly, but I suspect you have little idea of what it does, how it does it, what it can be used for aside from making compiling C programs easier. Or there are plenty of other aspects that come from sysadminning, whether it's db development, db admin, networking, all can grow quite easily out of the same role.


    the hatter
Re: Learning ***** as a second language
by xdg (Monsignor) on Aug 12, 2005 at 10:31 UTC

    I think it depends, in part, on where the scope of your responsibilities lie and what kinds of tools are already in use on your system and in what languages they are written. The rationale for this is that if you have to go beyond scripting administration tasks to debugging administration tools, you'll want to be familar with whatever language those are written in. For example, a lot of the system configuration tools on a Fedora/Redhat system are coded in Python, so knowing that might help debug those tools if you encounter a problem. On the other hand, if you're maintaining a Horde/IMP installation (or other PHP-based web interfaces), then knowing PHP will come in handy.

    I wouldn't get too caught up in what language are "cool" -- I'd focus on what other languages are in use around you every day.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re: Learning ***** as a second language
by jhourcle (Prior) on Aug 12, 2005 at 12:33 UTC

    You didn't mention what type of system administrator you are, or what languages you may know other than Perl, but from the mention of grep/awk/sed, I'll assume you maintain some form of posix system.

    If you're maintaining 'older' systems (any OS that doesn't ship w/ perl by default), I'd highly recommend that you learn to script in the appropriate shell for your system. Although they're all a little bit different, learning the syntax differences between ksh/csh/bash/etc. can be useful -- even if not because you're writing your own scripts, to debug other people's scripts that screw up when you go to install them on your system.

    Sometimes, perl can be overkill for quick scripts ... unix shell has branching, loops, procedures, etc, and can do a whole lot more than people use it for. I typically have my cron jobs call shell scripts, which set up the environment, and then pass off to perl or whatever else.

    C can also be very useful ... learn what the various compiler errors mean, even if you never write a C program in your life, as you don't want to be in the situation where you're told to install something, only to find out that it has a dozen dependancies, which are spewing errors.

    If you're also a windows sysadmin, then I'd probably move to learn VB, even with the horrors I have from my year of VBA programming. (functions, or objects... pick one ... what the hell is up with with 'DoCmd' object?).

    As there are lots of different types of system administrators, I'd suggest you look at what it is that you do, and determine where you seem to be taking longer on tasks than you feel is appropriate ... from that, you can get indications of what sort of things you feel you can make improvements on, and give you a hint as to what sort of things you need to learn.

Re: Learning ***** as a second language
by tlm (Prior) on Aug 12, 2005 at 13:02 UTC

    I pretend to be a sysadmin for my home system (Linux Debian). I totally disagree with the statement that Perl is the only scripting language that one needs to know as a sysadmin, because a sysadmin not only has to write his/her own scripts, he/she must be able to understand the code written by others, and much code one runs into while doing sysadmin work (at least in the Linux/Unix universe) is not written in Perl.

    IME, I find that being able to understand bash scripts and have a clue about how to edit these scripts is a an absolute must in the Linux universe. Next in the list is C. After that it's a toss up between Python and C++, though Python is gaining the upper hand. (Just not to confuse anyone, I don't mean to imply that C and C++ are scripting languages; I'm just referring to the frequency with which I've had to be able to grok a non-Perl language in order to take care of a sysadmin task, irrespective of the specifics of the language.)

    the lowliest monk

Re: Learning ***** as a second language
by izut (Chaplain) on Aug 12, 2005 at 11:42 UTC

    I was thinking about this few days ago. I just can say I can't use any other technology after meeting Perl. As neniro said, there are nice things in Python, Ruby, Java and PHP, but my opinion is Perl can do everything they can, but those can't do what Perl does.

    So, my suggestion is: learn other usage for Perl than sysadmin scripts :-) There are a plenty of nice modules in CPAN that does about everything: from resolving card games to complex web applications, workflow control, etc. Improve your knowledge doing that, you'll see Perl always will surprises you ;-).

    Update: After reading mrborisguy reply, I must emphasize that I am a former Java and PHP developer with unix background. The above text applies to me. I tried to perform the same tasks I do with Perl in Ruby, Python and Java but it really disappointed me. I think the only aditional language I would invest my time with is Ruby (after trying Ruby On Rails, but I switched back to Perl after I discovered CGI::Application and Class::DBI ;-)


    Igor S. Lopes - izut
    surrender to perl. your code, your rules.

      neniro said this earlier, and I completely agree with him. Perl is an incredibly powerful language that can do nearly anything. However, learning other languages helps any programmer think in different ways, which ultimately leads to finding the best solution for a problem more often. Some people rave about functional programming. Other people rave about Object Oriented Programming. Other people rave about AI programming. Other people rave about this and about that. It's true that a programmer can get Perl to do all of those things, if said programmer understands all of those things well. Learning other languages gives any programmer those tools because he or she understands the concepts and the best way to do things in that style from learning a relevant language. Learning other languages brings that all back to Perl to make the programmer more effective. If the programmer were just expanding his or her knowledge of Perl, sure, they'd end up picking some of that up just from Perl, but the programmer wouldn't have the deeper understanding of it, so would feel less comfortable using it to solve a problem.

          -Bryan

Re: Learning ***** as a second language
by uksza (Canon) on Aug 12, 2005 at 09:30 UTC
    Hello bronto

    I think there isn't better language for sysadmins for Perl. So, I think you only can start learn/use C - for improve your Perl programs ;-)

    uksza
Re: Learning ***** as a second language
by GrandFather (Saint) on Aug 12, 2005 at 10:48 UTC

    You already have a good idea of what scripting languages are about, so I'd suggest you take a look at C/C++.


    Perl is Huffman encoded by design.
Re: Learning ***** as a second language
by radiantmatrix (Parson) on Aug 12, 2005 at 13:35 UTC

    If your focus is primarily on System Administration, Perl gives you the greatest flexibility of any cross-platform language I know. However, despite my personal distaste for .NET, it is an excellent platform to get used to if you work ever need Windows-specific applications (esp. if you need to do advanced work with Active Directory).

    If .NET doesn't jingle for you, I recommend Java. Again, I personally dislike the language; but, it is a cross-platform language that has free (and Free) compilers and runtime environments. It's used in many places for automation and security work, so it's a good skill on a resume, and it's not far off from MS's C#.NET if you end up needing to go that direction.

    If you have solid Java (esp. WebSphere and Tomcat) experience and solid Perl skills, you'll never have trouble finding a job.

    However, if you simply want to challenge yourself, stretch your brain, and improve your overall programming ability, I suggest LISP. It seems like most of the popular languages are becoming more like LISP on a daily basis, anyway.

    <-radiant.matrix->
    Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law
Re: Learning ***** as a second language
by Koolstylez (Scribe) on Aug 12, 2005 at 13:43 UTC
    I would suggest, if you are so inclined, to try to learn the concepts behind programming languages. Once you understand this, learning a new language is mostly buying a good reference manual to figure out the syntax for what you are trying to do! This won't make you an expert on any one language, mind you, but will allow you to pick up a new language much quicker, and allow you to evaluate the strengths/weaknesses of using ****** language for any given task. Another advantage of this approach is that you aren't tied to <insert currently popular language here>.

    If you aren't too interested in the theoretical stuff, and you don't know C/C++, those are a good place to start since they are quite widely used.
Re: Learning ***** as a second language
by samizdat (Vicar) on Aug 12, 2005 at 14:07 UTC
    I think I've been around just about every language on the block, though not always for production stuff. I totally agree with the comment that one can learn much from other languages even though their capabilities overlap. Paradigms are often clearer in one language over another. For instance, objects and references are much clearer in Ruby than they are in Perl, but CPAN is much dearer (so far) than RubyGems, especially for sysadmin type tasks. Ruby's OO is much like the Smalltalk I used to love, only better, and I find myself buliding objects naturally in Ruby where it's work in Perl.

    C is essential to understand UNIX. It's also necessary to understand modules built with XS and swig. Look especially at make. It's not a 'real' programming language, but it's a really useful tool.

    Another useful tool for sysadmins, though you can equal its functionality with Net:SSH et al, is expect. expect is just the cat's meow for using Perl to massage other systems as though you were sitting at the keyboard. Highly recommended, and, of course, there's a Perl module to talk to it!
Re: Learning ***** as a second language
by bofh_of_oz (Hermit) on Aug 12, 2005 at 14:17 UTC
    First, great question!

    Second, there is not enough information supplied to answer the question properly... so the answer is "it depends"

    Perl has so much flexibility that you can use it for almost anything (note the "almost" part). There are many other languages, each serving their purpose, and they tend to be somewhat more narrow-focused.

    So you know shell scripting (and perhaps batch scripting on Windoze) and want to delve into the realm of *real programming* languages...

    If you mostly work on *NIX computers, I would strongly recommend to learn C followed by C++. You can think those are old languages, but so far no newer languages can beat them in system programming field (just my opinion of course).

    If you're in the Windows realm, you can learn Visual Basic for dealing with Databases (IMHO it's the only thing VB is good for - easily make connections to MSQL DB and manipulate data in visual way). VBscript is somewhat useful for pulling information from systems and Active Directory (using WMI).

    For Web-oriented programming, Java is the most advertised/marketed language, even though a little cumbersome (MS JVM vs SUN JVM, applets security etc etc). PHP and Python are pretty good languages too, but if you want to "increase your marketability" as well, pick Java...

    However, the main thing about programming (again, personal opinion) is not about knowing a particular language. It is about being able to think logically - identify the problem/find its cause/devise logical solution/implement in the most appropriate way. If you know and can create block diagrams (the logical flow of a process/program/whatever), you can take a book on any language to learn a syntax and be able to implement your solution in the matter of days (or less if you already know the language). That being said, I would recommend you to get a few books on the topic of programming itself, not restricted to a particular language. When you understand the general concepts, use the language you want to get what you need.

    --------------------------------
    An idea is not responsible for the people who believe in it...

Re: Learning ***** as a second language
by willyyam (Priest) on Aug 12, 2005 at 16:25 UTC

    You've raised a good question, and you've gotten a lot of great answers, so I won't bother you with repeated advice. Instead, I'd suggest not another language, but learn your editor of choice.

    If you use vi or vim there is a vast wealth of power and utility, and once you start learning how to tap into it it will make a significant difference in your life every single day. Vi(m) scripts, perldo, folding, block editing, tagging and multi-file editing - these can really change the way you work for the better.

    If you use emacs, then you have a wealth of power over data that simply boggles the mind. This editor attempts to do everything, and largely succeeds. As a byproduct of learning emacs, you'll likely learn LISP, so that's all right too.

    If you are not using one of these editors, then start. They are the power tools - learning curves like the Matterhorn, but worth every minute of the climb.

    Whatever you tackle next, good luck.

Re: Learning ***** as a second language
by Arunbear (Prior) on Aug 12, 2005 at 09:46 UTC
    Jython, because it makes Java much less painfull and you will learn Python and a bit of Java in the process.
Re: Learning ***** as a second language
by Anonymous Monk on Aug 12, 2005 at 15:33 UTC
    If you're a Unix system administrator, then given you already know shell, the answer is obvious: C. The kernel and all the important tools are written in C. Perl is in many ways, specially when it comes to system admin stuff, just a thin layer over the C libraries anyway. Beside it being a must for a Unix system administrator, knowing C will significantly increase your understanding of Perl. A lot of Perl things will start to make sense once you know C.

    I'd say, for a Unix system administrator (and I've been one for over 15 years on a variety of platforms, including Solaris, (old) SunOS, HP-UX, Linux, AIX, and IRIX), shell and C are a must. And another (scripting) language to write your own stuff in, like Perl, Python, Ruby, Rebol, etc, is very useful.

    I'd hire someone without Perl knowledge as a Unix system administrator (although knowing Perl would certainly be welcome). I wouldn't hire someone without C knowledge.

Re: Learning ***** as a second language
by punkish (Priest) on Aug 12, 2005 at 17:44 UTC
    Musical notation, because reading and playing music will really help you unwind after a long day solving sysadmin type problems.

    French, because is sounds so good.

    Chinese or Hindi, in case you have to work with Chinese or Indian techies knowing their language will make it all more fun. Besides, traveling through either China or India while knowing the local language would be a pretty amazing experience.

    Otherwise, the other 45 responses all have very good suggestions.

    --

    when small people start casting long shadows, it is time to go to bed
Re: Learning ***** as a second language
by InfiniteLoop (Hermit) on Aug 12, 2005 at 13:50 UTC
    I suggest you familiarise with:
    1. awk
    2. sed
    3. shell script
    4. management speak ;)
    These are life savers for any sys admin, esp. the ability to communicate well to your bosses boss.
Re: Learning ***** as a second language
by BaldPenguin (Friar) on Aug 12, 2005 at 14:41 UTC
    Having lived in both worlds, though currently residing in developer land, I can say that there are many advatanges to learning some if not many of the other languages.

    First, I have been coding for close to 10 years now. Relatively young compared to some of my esteemed brethren. In those years, I started with BASIC, then on to Visual Basic, JavaScript, ASP and then Perl. Then I became a moved over to what some would say is the dark side. Going through a rough time in the dot.bomb phase, my company had given me charge of a team of developers. Good guys, but no one knew Perl, 'oh and BTW the next project will be in Java, Have Fun!', I learned Java. And then on to C# and others. To cut the story short, all of them made me a better Perl programmer.Learning how to do, or not to do, the same sames in other languages can give you a better grasp of the patterns and methods you need as a developer,

    Now, as a SysAdmin, I have a not-so-new word for you, JavaScript. I know most people think this is just for web sites, but it actually goes further. M$ is using javascript as a scripting language that is replacing batch files, and they are using it in OO style. Give it a thought, using JS in that manner can be more challenging.

    Whatever you choose, have fun with it. If you don't have fun, you won't like it.

    Don
    WHITEPAGES.COM | INC
    Everything I've learned in life can be summed up in a small perl script!
Re: Learning ***** as a second language
by Anonymous Monk on Aug 12, 2005 at 16:05 UTC
    I'll be the heretic and mention scheme. You might not use it directly as a sys-admin, but you'll have the potential to learn about the essentials of computer science which will make you a better programmer. Check out DrScheme, TeachScheme, and some books on scheme. And if you're feeling advanced, you might want to check out these video lectures.
Re: Learning ***** as a second language
by EvanK (Chaplain) on Aug 12, 2005 at 15:26 UTC
    php would be useful if/when you're doign anything web-based (php & perl work well in tandem)...knowing C/C++ is always a good thing for a perl programmer (perl, among others, is written in C, so any perl problems are inherently C problems). so php and mabye C (depending on your future projects) would be my suggestions for you

    addendum: though you can do just about anything in perl, sometimes perl isnt the best way. for instance, if you're aiming for fast, small, standalone executables, C would be the way to go. if you're looking for cross-platform with minimal porting, Java. it's not always "you can do that in perl", sometimes its "you can do that more efficiently in ******* language".

    __________
    Give a man a match and he'll be warm for an hour. Set him on fire and he'll be warm for the rest of his life.

      if you're looking for cross-platform with minimal porting, Java.

      It's not my experience that Java is more portable and requires less porting work than Perl.

        than perl, no. I was referring to C.

        __________
        Give a man a match and he'll be warm for an hour. Set him on fire and he'll be warm for the rest of his life.

Re: Learning ***** as a second language
by b10m (Vicar) on Aug 12, 2005 at 21:00 UTC

    As for your professional use (sysadmin), just study the heck out of 'bash', I find new uses for it on almost a daily base (and also daily forget about it's substitute syntax as ${FOO//bar/baz/} etc.).

    A lot of people think bash is just for looping some GNU tools together. It is more powerful than that ... but then again, you're a sysadmin, so you probably already can dream the manual pages ;)

    Substitute 'bash' with your favorite shell in this post

    --
    b10m

    All code is usually tested, but rarely trusted.
Re: Learning ***** as a second language
by Dinosaur (Beadle) on Aug 12, 2005 at 20:15 UTC

    OK: Java! Java!. But here's why I think so.

    Perl is just plain *wonderful* -- up to a point. It lets you do some pretty sizable jobs with incredible ease. But there comes a point where the job gets bigger than perl (or any other scripting language) can handle. For big jobs, where you'll probably find yourself collaborating with other developers, you need an industrial-strength language.

    Funnily enough, it's just about at the point where perl collapses under its own weight that OO techniques become useful. This is also the point where a bit more design thought before you code starts to pay off.

    (Sorry, much as I love perl, I don't consider its OO support one of its strong points).

    Lots of languages inhabit the space that lies beyond above scripting languages, and I'm not familiar with most of them. But I like Java. IMHO, it has got OO just about right: not as kludgy as C++, but usable to do real stuff, unlike more academic offerings like Eiffel.

    Java's not as facile to code in as perl (no surprises there). But that's where tools come in. To program in an IDE like Eclipse is a completely different experience. A lot of the heavy lifting is done for you.

    Eventually, you may find design tools, such as one of the numerous UML packages, useful for doing really big jobs.

    Go down this route and, as an earlier Anonymous poster suggested, you will "learn about the essentials of computer science which will make you a better programmer". In the process, you may find your way to a few things that are more enjoyable (and remunerative) than Sysadmin jobs.

    But you'll still find that, for the small things that need doing every day, there's nothing like perl.

    -- Dinosaur

      Funnily enough, it's just about at the point where perl collapses under its own weight that OO techniques become useful. This is also the point where a bit more design thought before you code starts to pay off.

      Curiously enough I find languages like Ruby and Perl more effective at producing larger applications than Java. Seems I'm not alone in this.

      Not that this is an argument against learning Java. Learning more languages is always a good thing.

        Curiously enough I find languages like Ruby and Perl more effective at producing larger applications than Java.

        I find that large(ish) applications in Perl tend to be a lot smaller / simpler than more-or-less equivalent applications in Java (measured in lines of code / number of objects/classes involved etc). Which in turn makes the program easier to understand and maintainable (and quite often faster) than the Java equivalent.

        Partly this is because of the usefulness of perl's built-ins; arrays and hashes, which means you hardly ever deal with hand-coded "Value-Objects" (i.e. structs, listsOfMyObjects etc), the extremely compact and useful text-processing functions and simple conversion of numbers and strings (which help a *lot* when you're dealing with a large user-interface and is a royal pain in Java).

        I'm sure another part is due to differences in programmer experience / skill and because the Java projects tend to have more programmers working at them than the perl projects. A project with many programmers of different skill-levels makes for more overhead, more explicit (and complicated) interface specs and many, many more class diagrams :-) (see mythical man-month; basically I'm claiming that not only does a project take more MM if you add programmers, the design also tends to be much more complex than necessary if you don't keep it under tight control). This has probably has little to do with the languages themselves, it's just the specific projects I've worked on, but see below.

        One of the much-touted advantages of Java is that it enables explicit interfaces, class-contracts and large object-oriented design. Unfortunately (IMO) it also *encourages* large multi-layered designs and complex class-contracts / interfaces where they're inappropriate or even counter-productive.

        In this respect, Perl is the anti-Java: it encourages compact, implicit code and has *no* explicit class-contracts by default. This can result in programs that basically have "no" design and are completely unmaintainable, but it also means an experienced programmer has a lot more choice on what parts of the pogram are "worth" spending a lot of design time on (which, I think, is why many CPAN libraries have much simpler APIs than their Java counterparts).

        Basically, in Perl you design because you need to manage complexity, in Java you design *everything* because you just "have to". Personally, I know which of the two approaches I like best :-)

Re: Learning ***** as a second language
by SolidState (Scribe) on Aug 12, 2005 at 18:56 UTC

    As you move on from simple system-administration related tasks, you'll find that there is at least one area where Perl does not, alas, excel at - building GUIs

    Now of course I'm only talking for myself here, other people will probably disagree, but I've seen very few mature, widely used and popular GUI based apps in Perl. I've tried the Perl GTK and QT bindings (too complex, under-documented) and Perl/Tk (simple but plain ugly). After those attempts, I began to understand why I could find few succesful GUI projects in Perl...

    So if you're interested in trying your hand at GUI building, what should you use? Well, having never tried other languages myself I cannot recommended anything from personal experience, but I've heard Java and Python both mentioned as good GUI languages.

Re: Learning ***** as a second language
by fmerges (Chaplain) on Aug 12, 2005 at 22:08 UTC

    Hi,

    Second language??? Strange.

    Perl is good, but taking a look into another programming languages is a _MUST_, I think, not an option...

    As someone stated, take a look at C is very important

    Before learning C++ I would learn Python, Is very simple and it has some nice method to do things, like the lambda mentioned before, Python is very easy to read, andunderstand, and well Pythons OO is much more nicier than Perl strange method...

    def info(object, spacing=10, collapse=1): """Print methods and doc strings. Takes module, class, list, dictionary, or string.""" methodList = [method for method in dir(object) if callable(getattr +(object, method))] processFunc = collapse and (lambda s: " ".join(s.split())) or (lam +bda s: s) print "\n".join(["%s %s" % (method.ljust(spacing), processFunc(str(getattr(object, method).__doc__ +))) for method in methodList]) if __name__ == "__main__": print info.__doc__

    After taking a look at Python I would take a look into C++ and Java.

    Java is also very easy to understand, some things are not logic, like why the fuck you need to type something like:

    class MyWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }

    Only to see the Hello World printed on STDOUT...

    On the way, learn UML, can be useful. ;-)

    Regards,

    |fire| at irc.freenode.net
Re: Learning ***** as a second language
by nothingmuch (Priest) on Aug 15, 2005 at 09:53 UTC

    SICP is fun and interesting. It's not very relevant for system administration, but in my opinion any programmer should be interested in what they have to say.

    -nuffin
    zz zZ Z Z #!perl