Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

zoomvroom89

macrumors newbie
Original poster
Aug 29, 2008
21
0
Hi,

I'm trying to make a dynamic website, and found out that the backend can only be done in C. My question is that if I want to use C as the backend and say, PHP, as the frontend, how would I integrate the two? Soap calls back and forth? Some custom module?
 
i think that you want to use PHP as the backend and Javascript as the frontend, i never heard of C as backend for a web site
 
i think that you want to use PHP as the backend and Javascript as the frontend, i never heard of C as backend for a web site

Apparently sites like meebo can do it, but they wrote a custom module, dubbed 'mod_meebo'
 
You can write PHP and/or Apache modules in C that allow you to do stuff in PHP that you can only do in C. You write the actual website stuff in PHP.
 
wow never heard of that, i not to much into web site, but i usally use PHP as my backend and javascript, i may have to try C as my backend
 
i think that you want to use PHP as the backend and Javascript as the frontend, i never heard of C as backend for a web site

Why not? C would work just fine.

The term "back end" means software that runs on the server so you write that software in C. If that program runs as a gci-bin then whatever it writes to standard output goes directly to the user's browser. But it is really odd that your server has only a Compiler and not even Perl.

The term "front end" means software that runs on the end user's browser. I think for that your options are only Javascrit and Java unless you want to force your users to download a browser plug in.
 
But with C one is forced into using the antiquated and inefficient CGI interface. Not scalable, and not very extensible either.

If one is going to get into programming a backend, the scripting approach of PHP, or the programatic approach of Java are the best alternatives. And no, don't confuse server-side Java with client-side applets. They're not even remotely related.
 
Ditto as to ChrisA's excellent response and advice.

Since this is an usual situation, I suggest unusual advice to the OP, copy/pasted from various Google search results I found:

There is a pear library http://pear.php.net/package/Inline_C but I
doubt it is usable with a whole C library.
You could also try to compile your C library as php extension. I read
about it in http://www.amazon.com/Building-Custom-Extensions-Blake-Schwendiman/dp/...1601882

Just a different set of approaches to research on your own. Personally, I'd drop your webhost if they're the one forcing C on you and they don't support Perl or Java on the server side. But if you code is C based and either you don't know how to port to Perl (perl_mod) or Java (compiled from the SDK) or PHP (Apache DSO, optional Zend compiler) and or your client demands you use it then consider the above advice, but you're on your own as to seeking support. It's kind of like asking a modern car mechanic to fix a broken engine on a model T in terms of web application development standards of today (not desktop or CLI application coding in general where C is still used of course). Yeah, I know, I hate it too when stupid car analogies are used in web stuff. But it gets the point across here!!!!

-jim
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
A Backend in C seems like a rather odd idea. The web is all about fast development, scalable deployment, and being fast enough.

C will crash and burn on everything except for the last one, as it's typically 2-3 x faster then PHP. With Java and Perl the speed benefit is even lower. Sure some websites might use a little bit of C code sprinkled in (PHP Plugins?), or for handling more complicated server/client interactions, but in general they're going to be using PHP/Java/Perl/Python/Ruby. C is fast, but it's a pain to develop for, and I'm not even sure if there's any frameworks for web uses, althougH I assume you could write an Apache Module.
 
I was mainly looking to integrate libpurple into my existing web application. I guess I should just create my own Apache module.
 
To be honest mate, PHP would be all you would need along with Javascript and CSS and MySQL. PHP is one of the most popular web coding languages.

PHP can create incredibly dynamic websites and many employers look for people with PHP experience. Also PHP can be easily read by many other people as so many people know it. There are also more servers that would support a PHP back end. As PHP is open source and popular there is also lots of support.

One that I use is www.one.com.
 
Google's back-end is mostly C with some Python. Use what ever language is right for the job, we use C/++, Python, Perl, PHP for our backends.
 
i think that you want to use PHP as the backend and Javascript as the frontend, i never heard of C as backend for a web site

There is no reason you can't use C in the back end. I've done it and I'm doing it right now. It depends on what you need to do on the back. In my case it's a bunch of number crunching and database thrashing. Actully I've got a mix or Perl and C.

The waycgi bin scripts work is they just write to "standard out" and whatever they write is sent out to the user. why can't a C pergram write to stdout?
 
I was mainly looking to integrate libpurple into my existing web application. I guess I should just create my own Apache module.

I would do the module only if your site has enough traffic that performance becomes an issue. The reason you go with a module is to eliminate the overhead of process startup. But it the site is only getting a few hits per minute you are not going to have to worry about loading up a server.
 
i think that you want to use PHP as the backend and Javascript as the frontend, i never heard of C as backend for a web site

These are the Common Gateway Interfaces belonging to your father.
An elegant set of environment variables and stdout, for a more eleg... Scratch that. Long live RoR!:p
 
Thanks for all your responses.

So it seems like there are two (3?) ways to approach this:

1) Write a PHP extension
2) Make an Apache module (fastest)
3) Make a C program that writes to stdout?

Thanks for all your help!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.