LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 07-14-2009, 03:19 AM   #1
deepak_p86
LQ Newbie
 
Registered: Feb 2009
Posts: 4
Thanked: 0
Question Where exactly Perl & C/C++ are getting different and unique compare to each other..?


[Log in to get rid of this advertisement]
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
deepak_p86 is offline  
Tag This Post , ,
Reply With Quote
Old 07-14-2009, 09:39 AM   #2
sundialsvcs
Senior Member
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 2,718
Thanked: 43
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.)
sundialsvcs is offline     Reply With Quote


Old 07-14-2009, 11:48 AM   #3
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 1,036
Thanked: 52
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.
Sergei Steshenko is offline     Reply With Quote


Old 07-15-2009, 12:14 AM   #4
deepak_p86
LQ Newbie
 
Registered: Feb 2009
Posts: 4
Thanked: 0

Original Poster
Thanks a lot for your valuable input.
deepak_p86 is offline     Reply With Quote


Old 07-15-2009, 12:52 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 8.04 (upgraded from 6.06), Ubuntu Netbook Remix 9.04
Posts: 2,742
Thanked: 87
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
Wim Sturkenboom is offline     Reply With Quote



Reply

Bookmarks


Thread Tools

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 07: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 02:50 PM
How to compare records in two tables in seperate My Sql database using perl script chandanperl Programming 1 08-22-2008 10:33 AM
How to compare two lists (arrays) in perl WindowBreaker Programming 13 04-24-2008 04:01 AM
Perl List::Compare printing PB0711 Programming 2 08-10-2006 01:59 PM


All times are GMT -5. The time now is 07:40 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration