If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

CGI programming in C/alternatives

Hello,

This is my first post. Hope to contribute constructively at some point :). I'm a university student, new to C and not quite capable of C++ yet. I was thinking of writing some simulation software in C as a practical exercise. I'd like to deploy it rather quickly, and perhaps in parts, so I was thinking of writing it up as a set of cgi scripts that would get called on a website, and use the browser's presentation capabilities to draw or at least present the output.

I'm considering the web deployment because it seems the quickest path to having a useable (and user-friendly) program, and I'm far from GUI programming in C. Furthermore, once my C programming skills improve to that level, I'm under the impression it won't take much to convert them to an executable.

I haven't been able to find many books or resources that cover C CGI programming. Is there a reason for this? Is my approach wrong? Will CGI in C be too slow compared with other server-side languages (PHP is the only one I'm seriously considering)?

Could anyone point me towards some CGI in C programming resources if this does seem like a viable option?

Thanks for your insight, and sorry for the long post,
Have a good one,

Not sure what CGI even is, but I often have my programs output programs as a file or whatever, for example the output of many of our programs is a matlab(tm) program, or a batch file, or even another C++ program(!), HTML, etc, or comma divided file that excel(tm) can read directly.

Perhaps that would work for you, to simply write a CGI script/program from the C output? Or HTML?

Not sure what CGI even is, but I often have my programs output programs as a file or whatever, for example the output of many of our programs is a matlab(tm) program, or a batch file, or even another C++ program(!), HTML, etc, or comma divided file that excel(tm) can read directly.

Perhaps that would work for you, to simply write a CGI script/program from the C output? Or HTML?

Edit: you cannot, to my knowedge, call an executable from a browser without funkyness, and certainly your security settings should prevent this. Instead, you would write the c program to generate the output script that the browser can handle and invoke the browser with the file at the end of the C program ... for example, system("C:\\.... IExplore.exe output.html"); would open internet explorer with the file output.html displayed, you can do the same with excel and word and just about any program (most will accept a command line file to open).

CGI in C: Outdated Server-Side Technology?

Hello again, I think I need to clarify.

I'm trying to decide in which direction I oughta guide my programming studies.

sorry for the long post again, the last three paragraphs highlight my question.

I ultimately want to make this a server-side application so that a webbrowser can be tasked with whatever post-processing is necessary. I'd like to take the trouble of writing a post-processing script (MATLAB, or using EXCEL) out of the user experience and have the output displayed nicely in a browser using it's visualization capabilities. ( I think I know JavaScript rather well compared to C).

The fact that you can do this in C excites me because I'm under the impression that I could write the program as a series of CGI scripts and then, at a later date, simply put them together in a C executable when I'm ready to make a proper downloadable program. This would avoid having to learn a second programming language to make a server program, and still learn C well enough to make a proper executable.

My biggest hurdle is that while there are many resources (safariTechBooks) that cover CGI and Perl, there aren't many that cover CGI and C and I'm wondering if this is because C just isn't suited to run this way or if it's too slow to be practical etc.

Do you all think that it's a good idea to pursue writing CGI scripts in C for the sole benefit of being able to later put them together in a C executable?

Are other CGI or server-side languages better suited for this to where the convenience of porting to an executable is nullified?

Might this (writing a server-side app and .exe in same language) be a lost cause? Thanks again,

> I haven't been able to find many books or resources that cover C CGI programming.
> Is there a reason for this?

yes, there is a good reason. The vast majority of CGI programs are written in languages, such as Perl, Python or Ruby - these languages are easier to use, and quite often a CGI script does not need the performance and low level control that C gives. and the structure of a CGI program is identical, no matter which language you use.

The other thing is that executables are less portable. C is a moderately portable language (C++ a bit less, as folks tend to use more OS specific tools in it), but even the simple act of recompiling C code on another machine(different OS and hardware, not just a clone of the first machine of course) can lead to days of work. This would make the scripting languages, which are extremely portable, more acceptable for web-work. If you want to do it in C for the speed, or just to say you did it, or if you have no reason to port, its all good, but it may not be the best choice in general.