Question:
Why don't people use CGI for web programming anymore?
Yes
2012-01-13 13:25:27 UTC
Back in the day (i.e. 10 years ago when I was studying programming), I would just write a C++ program to write out web pages when I needed dynamic content. Now all the kids are running around with things like PHP, ASP, JSP, etc.

Do you really need to do all that? I understand that scripting languages are easier to learn and for some simple operations are easier to work with... But if you already know C/C++ is there an advantage to learning PHP or some of the other methods?

Also, wouldn't a plain binary file be faster, performance wise?
Seven answers:
?
2012-01-13 13:57:02 UTC
Actually, no on the performance. If your server is running Solaris or AIX, it takes long enough to start a process to run your binary file as it does to send wikipedia halfway round the world. It is possible to match or exceed the interpretive performance in some cases but generally, no.



The others are interpreters, waiting for the file, often running threads. There are more ways yet to do dynamic content using flash, FLEX, etc., that you did not mention. Perhaps the most interesting is WSGI, a strategy that fits many languages and allows middleware apps to stack on each other in meaningful ways, even when written in differing languages. Some frameworks written in Python use WSGI as a matter of course, and others have specific software to adapt to WSGI.



Moreover, there is SOAP, and REST, which make abstractions of web services, allowing communication between server and client with xml or JSON. Some of the interpreters have library modules to implement JSON directly into the language. This means sometimes that clients are receiving code to execute screen scrapings and such. You cannot do that with CGI.



Moreover, as you pointed out, it is cheaper to train someone to use PHP than C++, and the cheap drives out the dear. CPU time and storage are no longer significant cost factors relative to the human element in creating and maintaining programs.



To be sure, CGI and fCGI are still around, but arwe only a couple of the tools in a fairly deep chest.



I would recommend googling the following:



YAWS http server

Plone

Django

Zope 2

Grok

ERP5

Nitrogen Web Framework

Zotonic



The C++ Apache is way way outmatched by the Erlang-based YAWS, which can stand up to at least 100 times the pounding from a DDoS attack than Apache can.



What this all means is that there are many who never use C++, which makes the prices for that skill outasight, like $150/hr up. I am not unhappy with that situation. I get more for Python and C++ skills than most web programmers ever see.
green meklar
2012-01-13 23:49:24 UTC
>Do you really need to do all that? I understand that scripting languages are easier to learn and for some simple operations are easier to work with...



Exactly. This is what people want. A web entrepreneur with a tight budget doesn't want to be in a situation where every single one of their severside programmers needs to be intimately familiar with C++ network coding, and where they have to wait forever while their programmers update and debug a new feature. Rather, they want things to be quick, cheap, easy and malleable.



Also, there's the issue of security. Although using a purpose-built serverside scripting language may expose you to a widely known threat if one appears, they are designed and maintained to keep up good security standards. Whereas custom-made executables may end up full of exploitable bugs, and fixing them would have to be done in-house. It's cheaper and safer if you leave your security to the experts rather than trying to do it all yourself every time.



>if you already know C/C++ is there an advantage to learning PHP or some of the other methods?



In terms of the expertise people are looking for in the industry? Absolutely.



>Also, wouldn't a plain binary file be faster, performance wise?



In principle, yes. In practice, the performance of most modern serverside web applications is dominated by delays in network communication and storage access. Processor time- which is what you mostly save using the CGI approach- is almost never the bottleneck to begin with.
?
2012-01-13 14:13:36 UTC
I worked for a year writing in C++, one day I got a project that took me 3 days to build. after a while I decided to learn PHP and as an exercise I decided to code the same project in PHP, it took me one afternoon to finish it (keep in mind that this was my first project in PHP!).



The bottom line is: if you know how to code, picking up a scripting language is very easy and development time reduces dramatically. Further, if you have a web-app you want to build - better write a JSP/PHP or work with .NET - this way you have all the platform "ready made" and you don't have to re-invent the wheel. Another good point (for PHP) is that most of the CMS are written in PHP (Magento, Joomla, drupal and I think that wordpress as well).
?
2016-03-01 04:15:27 UTC
You need to be aware of these languages, but you only need to learn them as the need arises. Remember, though, that if all you have is a hammer, everything begins to look like a nail. Each language is like a different tool to meet different programming needs, and the more tools you have in your "tool box", the better equiped you will be to meet the programming challenges that arise. In the area of programming, we do NOT have a "one size fits all" attitude, and one programming language alone will not meet every need. Oh, and you can add ColdFusion and DreamWeaver as well as Macromedia Flash to your list of tools you can use in implementing a web design. Good luck, and have fun programming.
jplatt39
2012-01-13 13:57:52 UTC
Once you know them scripting languages are very convenient, for example they are much easier to debug -- it won't crash till it comes to the offending line so you don't have to hunt through everything to get what is wrong. Also the syntax of C++ doesn't have to be so compact it's confusing, but it often is. So shops like scripting languages. CGI is still supported but shops like scripting languages, so the people who know them get hired.
2012-01-13 13:30:46 UTC
You can still use CGI .. it is still 100% supported .. there is no specific "need" to learn a server-side scripting language, but you'll be gad you did.
?
2017-03-01 08:34:34 UTC
Well long nails are attractive... but to make it look sexy, put red nail gloss on.... now thats attractive hun!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...