Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

C or C++ to go with Perl.

by Anonymous Monk
on Jan 18, 2013 at 07:58 UTC ( #1013973=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks

System admin here. Been thinking of learning one programming language that'll help me do a lot of system side stuff. So why ask the question here right? Well, I've been working on Perl and its going fine so far. Noticed that there are couple modules which happen to be written in C, BUT not sure. So I wanna learn either C or C++ so I can may be some day before I kick the darn bucket write a module for Perl.

Tried Python, and cant get my head wrapped around the whitespace stuff. I did a little C and C++ in college, but I need to chose one from it.

Which do you think will fit better for a sys admin kind of suff? C or C++ (Yes, I know, this is kinda premature...I am not even 1/10th good at Perl and y'all can speak Perl like your native tongue, but heck, I wanna learn one compiled Language that can help me write system side stuff, so either C or C++ its gotta be)

Replies are listed 'Best First'.
Re: C or C++ to go with Perl.
by flexvault (Monsignor) on Jan 18, 2013 at 12:39 UTC


    As a system admin, all you need is Perl.

    As a reference to learning 'C' please see Forgetting Syntax. . . in which my learning 'C' in the 80's didn't help much in the late 90's since the 'C' compiler developers didn't think backward compatible was necessary.

    Thank goodness, the Perl developers did!

    So why not join our group, since you'll learn a lot more about writing real system admin functions on PerlMonks than learning 'C' or 'C++' from a textbook. But then again, I've never found a system admin requirement that I couldn't do with Perl.

    Good Luck!

    "Well done is better than well said." - Benjamin Franklin

Re: C or C++ to go with Perl.
by tobyink (Abbot) on Jan 18, 2013 at 08:53 UTC

    Perl is part of the "C family" - i.e. a language syntactically inspired by C (like Java, Javascript, etc), so if learning C some things will be familiar - insignificant whitespace; many of the operators; some functions (printf, sprintf, etc); braces as block delimiters; semicolons as statement separators; etc.

    Some things in C are quite painful though; memory management is done manually - you often need to deallocate the memory used by variables when you've finished using them - it lacks an automatic garbage collector. And personally I've never been especially happy with the lack of a native string data type (strings are just arrays of characters).

    But C/C++ is one of the most widely used programming languages in the world - perhaps the most widely used. So it will stand you in good stead that way.

    Another direction to consider is something like Ada - a high level, object-oriented language which can compile down to machine code. (Ada has been on my "to learn" list for some time, but recent events have pushed Scala up the list.)

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      recent events have pushed Scala up the list

      Chromatic's reddit post re: Moe?

      A mistake can be valuable or costly, depending on how faithfully you pursue correction

        Indeed. I don't read reddit, but read about Moe from the horse's mouth.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: C or C++ to go with Perl.
by vinoth.ree (Monsignor) on Jan 18, 2013 at 08:38 UTC

    * C is the closets language to assembly. Which means it is really low level and you have lots of memory management to do.

    * C++ may be difficult to use, because it is like C in some ways but a higher level of abstraction, plus you still have to control memory.

    * C++ is easy to learn simple things.

    * I would suggest learning C before C++.

      C++ does have the handicap of object-orientation. OO is pretty good for designing large to very large programs, but fares poorly in small programs and it's very difficult to wrap your head around the paradigm -- especially for a new programmer.

      (Of course you can completely skip the OO and program in a non-OO style, but whichever tutorial or book you choose to learn C++ from will probably dedicate at least a few chapters to it)

      I'd still rather go for some other compilable language, and I'm not sure which one to suggest, but I'll echo the sentiment that the OP should stay in Perl-land for a while.

Re: C or C++ to go with Perl.
by perl514 (Pilgrim) on Jan 18, 2013 at 13:13 UTC


    I agree with FlexVault. Plus, I am doing admin work too...Barring the freeze periods, we are neck deep with day to day activities. In my case, even if I get 15 mins to write or revise Perl Script, it seems to keep me from blanking out on Perl. :)

    So I would humbly suggest to get very well versed in Perl, as that will be more than enough for what we admins do. And yeah, some good perl books (see my signature) and Perlmonks (again, see my signature) will do you a lot of good.

    Perlpetually Indebted To PerlMonks

    use Learning::Perl; use Beginning::Perl::Ovid; print "Awesome Books";

Re: C or C++ to go with Perl.
by blue_cowdawg (Monsignor) on Jan 18, 2013 at 14:07 UTC
        Which do you think will fit better for a sys admin kind of suff?

    Every year since 1973 I've revisited what languages I want to learn or stay current in and it all boils down to how much time you have and what tools you need to get done what you want to get done.

    To answer your question directly I've used a whole lot more Perl for SysAdmin kind of work than I have C or C++. That's not to say I haven't written XS code for a Perl module before and therefore used C. (Actually: one module I wrote for a financial firm I worked for was a hack of embedded SQL (ESQL) grafted into a Perl module. ESQL->C->XS was the path.)

    I would shudder to think how much more difficult it would have been for me to automate backups back in 1990 using just C or C++ to get the job done, not to mention all of the log scraping scripts I've written, user account generation scripts and on and on. These are tasks that Perl is much more suited to. On the other hand I'd hate to write a compiler in Perl. Not that it couldn't be done, but being able to use lex to generate C code for a parser and yacc to create the finite state machine in C would make much shorter work of the task than having to do all that by hand in Perl.

    I've said it in other posts on PM and I'll say it again: "right tool for the job."

    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: C or C++ to go with Perl.
by slayedbylucifer (Scribe) on Jan 20, 2013 at 07:52 UTC
    Myself being a Linux/windows sys admin for 9 years, I have never come across a use case which I could not do with Perl. As far as sysadmin stuff is concerned, I don't really see a point learning c/c++. I have been doing perl automation for quite long and still explore new features of perl every now and then. On windows, I have used VB/batch/powershell and was able to automate the things. There were however few instances where I had to use python (I am a python noob). Definitely there is no need to work on c/c++ for **sys admin stuff**.
Re: C or C++ to go with Perl.
by Anonymous Monk on Jan 18, 2013 at 08:17 UTC
Re: C or C++ to go with Perl.
by jakeease (Friar) on Jan 19, 2013 at 07:29 UTC

    I agree with the several posters saying that Perl is about the only language you'll need for admin tasks. I can recall writing backup and restore programs for a Univac 1108 in Fortran back in the '70s, but then I was a programmer not an admin and only responsible for my own team's work; it was straightforward without much of the complexity today's admins face. The next year I discovered a scripting language on the 1108 and was able to build test cases singlehandedly comprising pretty much all the production runs of my software by a team of 20. I loved it.

    Perl is better for all sysadmin tasks. I haven't been particularly current with C since 2000; C++ since 2003 and Java since 2009. There aren't many cases where you'd want a compiled program. Try to anticipate their nature and choose a language suited for that.

    A few more books worth a look:

    • Perl Hacks
    • Effective Perl Programming
    • Minimal Perl

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1013973]
Approved by LanX
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-08-24 00:07 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (360 votes). Check out past polls.