Making websites with C, PHP, Javascript

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?
 

italiano40

macrumors 65816
Oct 7, 2007
1,080
0
NY
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
 

zoomvroom89

macrumors newbie
Original poster
Aug 29, 2008
21
0
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'
 

Aranince

macrumors 65816
Apr 18, 2007
1,104
0
California
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.
 

italiano40

macrumors 65816
Oct 7, 2007
1,080
0
NY
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
 

ChrisA

macrumors G4
Jan 5, 2006
11,609
408
Redondo Beach, California
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.
 

bootedbear

macrumors 6502
Sep 13, 2004
373
0
Austin, TX
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.
 

SrWebDeveloper

macrumors 68000
Dec 7, 2007
1,872
2
Alexandria, VA, USA
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
 

Aea

macrumors 6502a
May 23, 2007
838
208
Denver, Colorado
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.
 

zoomvroom89

macrumors newbie
Original poster
Aug 29, 2008
21
0
I was mainly looking to integrate libpurple into my existing web application. I guess I should just create my own Apache module.
 

mari0

macrumors member
Sep 10, 2007
42
0
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.
 

detz

macrumors 65816
Jun 29, 2007
1,051
0
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.
 

ChrisA

macrumors G4
Jan 5, 2006
11,609
408
Redondo Beach, California
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?
 

ChrisA

macrumors G4
Jan 5, 2006
11,609
408
Redondo Beach, California
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.
 

Palad1

macrumors 6502a
Feb 24, 2004
647
0
London, UK
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
 

zoomvroom89

macrumors newbie
Original poster
Aug 29, 2008
21
0
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!