The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Perl vs. C/C++
Discuss Perl vs. C/C++ in the C Programming forum on Dev Shed. Perl vs. C/C++ C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 14th, 2002, 04:48 PM
|
|
Dazed&Confused
|
|
Join Date: Jun 2002
Location: Tempe, AZ
|
|
|
Perl vs. C/C++
I'm a kid in heart (and not too far off in maturity level) and enjoy designing games with the knowledge of programming that I have. Unfortunately, my knowledge of C/C++, the ideal language for creating MUDs (Multi-User Dungeons) is lacking next to my knowledge of Perl.
After searching around the internet, I've come upon a simple Perl-based MUD codebase which I know I could build up very quickly to the levels of quality of C/C++ based MUDs in features and appearance. However, I know that Perl's flexibility comes with a price of speed. What price would I be paying? Half as slow, one third? I know it would depend on the functions used, so just a general estimate would help.
I also wish to impliment MySQL in to it. I've dabbed in using MySQL with C once before, and the code I wrote, albiet with a good level of ignorance, was much more bulky than it's Perl equivalent. Is this common or can MySQL be as streamlined in C as it it can be in Perl and still offer reasonable error-checking? Also, does one language offer better MySQL support than the other?
Thanks,
Dave Mittner
Ignorant C Programmer
P.S. One of the major reasons I'd like to use Perl are hashes. I know C/C++ has hashes as well, but in researching them I was utterly confused. Needless to say they don't appear anywhere near as simple as Perl's. In the end, though, would they offer similar functionality or would I be out of luck there if I went with C?
|

June 14th, 2002, 05:18 PM
|
|
Junior Member
|
|
Join Date: Jun 2002
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
There is a very hig probability that if you optimize the hell out of both
a Perl version and a C version, the C version would be faster.
The question is how much faster and for how much more effort?
I'd recommend going ahead and doing it in Perl first.
To accurately answer the question about performance without doing
two implementations would probably take about as much time
and effort as actually just implementing it twice and just
comparing. So I'd do it the easy way first (Perl) and _if_ performance
is not acceptable, then see if you make your perl faster, and then if
that isn't good enough, then do a partial or complete redo in C.
Try to keep this possible scenario in mind when doing the perl.
I.e. write good modular software. Maybe even put placeholder
wrappers around things like hashes that you know would require
some extra kung fu if done in C.
Both languages are turing Complete and can do anything any
the other language could do.
|

June 14th, 2002, 06:58 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
I will say that if you know perl better, definately try that one first. Both are very powerful, but one drawback to C is that you have to do it a while before you can really learn to optimize it and use the real tricks that save you major time and processing power.
The big plus between going for perl is its database interaction, which is a little easier to learn than doing it in C. If you decide to use C, then do a little research to see if you can find any libraries that have been built to use database calls before trying it on your own. From there you can learn a little more about some of the tricks about C. Plus, you really have to watch your pointers, a pointer out in the forest can crash it all, which in short, be careful using pointers and dynamic memory until you get use to it.
|

June 14th, 2002, 07:03 PM
|
|
Dazed&Confused
|
|
Join Date: Jun 2002
Location: Tempe, AZ
|
|
|
Thanks for the input so far. I know the atleast the basics of C, having self taught myself a good portion of it. I can get by with memory and such, but fall behind when it comes to sophisticated memory management and dealing with a lot of information on a system with multiple, simultanious users. I'm pretty much stuck with being able to do moderately difficult changes and although I can think of some nice things to add, it's frustrating when my skills don't permit it.
As for Perl, I program that for a living so could overcome most challenges much easier. I guess I feel old age creeping up on me because I'm not learning things as quickly as I use to.
|

June 14th, 2002, 07:13 PM
|
 |
/(bb|[^b]{2})/
|
|
Join Date: Nov 2001
Location: Somewhere in the great unknown
|
|
|
We are in reverse rolls to a point. A program in C/C++(plus a few others) for a living, but nothing to do with games. Most of my apps deal with wireless terminal barcode scanners and inventory management. I have to deal with a massive amount of data between the terminals and a DB2 database (mysql comes no where close to offering the things I needed for this) so I deal a lot with memory and data transfer.
As I said before though, I would try Perl first, since you know that language best.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|