LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-14-2009, 02:19 AM   #1
deepak_p86
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Rep: Reputation: 0
Question Where exactly Perl & C/C++ are getting different and unique compare to each other..?


Hi Friends,

I am new to perl, and I want to understand the importance of perl compare to C/C++. I want input from your experience & Knowledge.

Please share the scenario's or requirement where perl would be more preferable then C and also vice-versa.

I know its broad subject. But your single input will be helpful to everyone.

Thanks,
Deepak
 
Old 07-14-2009, 08:39 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
C/C++ is a great language for writing the Perl compiler/interpreter. In fact, it's the language that is used. (C/C++ was even used to write itself, but that's another story...)

It's also a good language for writing certain low-level portions of some of the many CPAN modules.

"Aye, here's the rub..." The low-level portions, not all of them. The parts that need to run very fast. In the proverbial "80/20 rule," C/C++ is used for "the crucial 20% of the code that is running 80% of the time." The messy inner workings of "a hash," for example. Memory management and garbage-collection. Or references. The rocket-science stuff... but only the rocket-science stuff.

For "all the rest of it," you simply write it in Perl, knowing that by so doing you are happily taking advantage of a very large amount of well-tested C/C++ code that you call "Perl, itself." In a single line of Perl code you can do many complicated things that would ... and in fact, that did ... take "pages and pages of clever and tricky C/C++ code" to specify. That clever, tricky code is part of Perl itself, and so you can take full advantage of someone else's cleverness while completely ignoring it.

Referring once again to the "80/20 rule," nearly all of the code in a typical application is boring ... uninteresting ... and, time-wise, rarely used. The time that needs to be saved is your time, not the computer's. ("At 10 billion ops per second, no one can hear you scream.") What you need, then, is a very well-written power tool that allows you to be expressive ... and that's what Perl is. Perl is a lever.

What makes Perl particularly useful and impressive is... the CPAN library. Your work becomes vastly more efficient when you can leverage someone else's complete, well-tested package to do some task... which Perl allows you to do particularly easily.

This analogy can of course be extended to any of the other myriad scripting-languages that Unix/Linux supports: PHP, Python, Ruby, Scheme, various Visual Basic knock-offs, etc. etc. (They, too, have their analog to CPAN.)
 
Old 07-14-2009, 10:48 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
And, in fact, one can essentially mix Perl and "C" code using Inline::C module

http://search.cpan.org/~sisyphus/Inline-0.45/C/C.pod

- I've implemented pretty serious stuff using it.

Furthermore, in my case Perl is used to autogenerate part of the needed "C" code.
 
Old 07-14-2009, 11:14 PM   #4
deepak_p86
LQ Newbie
 
Registered: Feb 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks a lot for your valuable input.
 
Old 07-14-2009, 11:52 PM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by sundialsvcs View Post
...In fact, it's the language that is used. (C/C++ was even used to write itself, but that's another story...)
Did they already solve the chicken-and-egg problem on those days Why am I still running into it
 
  


Reply

Tags
cc++, perl



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl: Want to compare CGI input with data from a MySQL table resetreset Programming 1 11-20-2008 06:58 AM
LXer: Unique Sorting Of Lists And Lists Of Lists With Perl For Linux Or Unix LXer Syndicated Linux News 0 09-05-2008 01:50 PM
How to compare records in two tables in seperate My Sql database using perl script chandanperl Programming 1 08-22-2008 09:33 AM
How to compare two lists (arrays) in perl WindowBreaker Programming 13 04-24-2008 03:01 AM
Perl List::Compare printing PB0711 Programming 2 08-10-2006 12:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration