perl vs. c++

Hey.

I was wondering if anyone can tell me the advantages perl has to C/C++?
What is the disadvantages of perl compared to C/C++?
How's the performance of perl programs compared to C/C++ programs?
Is perl object oriented?
Can you use low level programming, like assembly in perl?

I am a c++ programmer, but I have heard that perl is even more powerful.
As for myself, I have my doubts, but that is what I am trying to find out :)

I hope anyone can give me some good answers, hopefully not just "Perl kicks C's ass" or "C sucks" or "Perl sucks" or something like that :)

Thanks in advance for any replies :)

Comments

  • Hi,

    D'oh. I just dropped a fizzy cola bottle sweet in my cup of tea. Anyway, your question...

    : I was wondering if anyone can tell me the advantages perl has to
    : C/C++?
    I'd say you get a higher level of abstraction. In C/C++ you often have to worry about memory allocation, you are working directly with pointers meaning you can easily write a segfaulting app if you ain't careful, and if you want to work with strings you have to call a set of functions to do it. In Perl you don't have to worry about those kinds of thing, or other niggly things. You get a lot of built in stuff too. C/C++ has a large collection of libraries, and a largue exist for Perl too, so doing database access, GUI apps, etc. is reatively easy. Also, as Perl is interpretted, you

    : What is the disadvantages of perl compared to C/C++?
    Take the above statements are reverse them. In C/C++ you have a lower level of abstraction. That means you are working directly with memory, meaning you don't have the overhead of something watching your back. Sometimes you need to worry about niggly things, and being able to do so can be a bonus. No matter how fast libraries get supported by Perl modules, you will still be able to use all of them in C/C++ using #include whatever.h. And yes, Perl looking after your strings is nice - but sometimes you want to be able to work with them like you do in C/C++.

    : How's the performance of perl programs compared to C/C++ programs?
    Higher level of abstraction = higher developer performance = lower computational performance. As you have less to worry about, you can write the thing more quickly, generally. However, because there is an extra layer in there doing the stuff for you, it adds overhead so it won't execute as quickly as the equivalent C/C++ program. This is not to say Perl's performance is bad, by any means. But remember that Perl itself is implemented in C...then, so are the vast majority of C compilers, right? :-)

    : Is perl object oriented?
    Yup.

    : Can you use low level programming, like assembly in perl?
    Uh...kinda. :-)

    : I am a c++ programmer, but I have heard that perl is even more
    : powerful.
    : As for myself, I have my doubts, but that is what I am trying to
    : find out :)
    The bible teaches us that "there's a time to embrace and a time to refrain.."...ARGH! This is Perl board, not my Sunday School lesson plan. No, my point is that there are times where Perl is "best", and other ones where C is "best". If you want to do low level stuff, need high performance, want direct memory/hardware access (as the OS allows) and so on, use C. If you want a fast hack to shift that data around in your database, or you want to do some text data proccessing (like extracing data from a file and generating other stuff based off it), or write a CGI script, or write any system where you don't need low level access or blistering performance, use Perl. Between the two are grey areas where we could use either, and then it's personal taste.

    : I hope anyone can give me some good answers, hopefully not
    : just "Perl kicks C's ass" or "C sucks" or "Perl sucks" or something
    : like that :)
    I'm pretty true to all I've said above. I love Perl greatly, and write a lot of things in Perl. But when it came to writing AMaMP, an open source audio engine I'm working on, Perl wouldn't have cut it performance wise, so I used C - and it worked well, and I'm enjoying working in C too. And yes, I did manage to write code that segfaulted, and yes, I did manage to overshoot on an array as well. Which brings me to my final point. It's pretty darned hard to write a script with buffer overflow exploits in Perl. But I digress.

    : Thanks in advance for any replies :)
    Hope this helps. What I really want to say is - asking whether Perl is more powerful that C/C++ in general is a bad question (no offense). The real question is - which will best allow me to solve the problem at hand?

    Happy hacking. Oh, and my tea tasted completely disgusting. :-(

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • Hey.

    Thanks a lot for a great answer :)
    I got everything I wanted to know.

    Again, thanks :)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories