Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

RE: Perl Vs. C

by Malkavian (Friar)
on Oct 31, 2000 at 00:19 UTC ( [id://39183]=note: print w/replies, xml ) Need Help??


in reply to Perl Vs. C

Rather than being mutually exclusive, C and Perl fit together nicely.
As a starting point, writing a system in Perl is a good step. It works rather nicely as a rapid development language, due to it's easy syntax, and it's abstraction from the lower levels that are required for C (pointers, memory allocation etc).
C, for dedicated purposes, is faster than Perl in a good many areas, but, unfortunately takes far longer to develop, and is more prone to errors and undefined behavour.
A question you should ask yourself is: Do you actually require that extra speed that compiled C will be giving you? Is your program the bottleneck of data transfer rather than the database accesses?
If it seems that the database will be the main use of system resources, then you won't get much more kick for using C as your glue over Perl, and it could easily be a lot less maintainable.
A good way to start something such as this, is to design the initial system, and code in Perl.
Treat this as the prototype, as any major changes in functionality can be easily made.
Once you're happy that things run as they should, perhaps start profiling, to work out where your bottlenecks are.
You then have the option to either optimise these in Perl, or, recode in inline C.
If it seems to you then, that you absolutely require the extra boost, then you have a working, functional model that can be used for reference while coding a C application that is logically identical, but, hopefully faster.
After programming in both C and Perl, I've found that nearly all the things that I'd previously have used C for, I now use Perl, and, in the instances I still do C coding, I usually use Perl as a prototyping language to ensure that I have the design correct.
So, to sum:
Perl advantages:
  • Speed of development
  • Good early stability
  • Good prototyping language
  • Easily maintainable
  • A large base of existing libraries to use, which are already heavily optimised and debugged for a great many uses.
  • Can use compiled C to replace Perl functions for extra speed where required.

C advantages:
  • Very fast.
  • Lower memory footprint.
  • Higher degree of control over low level functionality.

Anyhow, hope this helps, among the rest of the advice,

Malk

Replies are listed 'Best First'.
RE: RE: Perl Vs. C
by merlyn (Sage) on Oct 31, 2000 at 07:06 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://39183]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-19 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found