Reputation: 10191
I am creating a small web service which will only be accessed by machines, not users that simply takes a query string and makes a few MySQL queries. I decided to code this in PHP because it is simple and easy to write and does its job well. My boss however, wants we to write it as a CGI in C (using FastCGI) because he says it will be faster and use less memory. I'm not so keen on this idea for a few reasons:
But that's just my opinion. What other factors do I need to take in to account? Is C the best tool for this job? Or is PHP?
Upvotes: 7
Views: 4992
Reputation: 13816
Ask your boss if it wouldn't be better if you used C++.
And try fastcgi++. You've also got boost and other libraries which can help you do the boring stuff faster, and concentrate on WHAT MATTERS.
And if the application does lots of calculations, it is a good idea to make it in C / C++.
If he simply doesn't want, then you have two choices:
Why C++, and not C
It is true that with good coding conventions, you can write manageable code in C too.
But with C, you still have the verbosity of error handling, as opposed to exceptions, of NUL-terminated strings, of maps or what not. I love C too more than C++, but let's face it: here is not about the language, it's about the mentality of a despot (the boss) who needs to be fought with arguments and learn to lend an ear to his employees.
Upvotes: 1
Reputation: 9424
shudder... You should leave the company. A boss shouldn't be allowed to micormanage the workers... unless he's also the programming guru of the company :)
Upvotes: -1
Reputation: 18953
Your app is most likely I/O bound. So it won't even be noticeable faster in C.
Upvotes: 0
Reputation: 15264
If speed is your (or your boss's) concern, check out the G-WAN server, which allows allows you to write C scripts. There are some MySQL samples in the forum. It'll be much faster than FastCGI (which has to cross process boundaries via sockets).
Upvotes: 3
Reputation: 15922
Some points about this:
Upvotes: 2
Reputation: 1437
IMHO, if most processing is made by MySQL, there is no need to write this code in C, because difference is negligible, but if there is much processing will be made by your code, it makes sense to listen to your boss and make it in C
Upvotes: 1
Reputation: 1034
You got no choice because your boss want it. Unless you can't code in C then just C it.
Upvotes: 0