ruby - Why should I avoid using CGI? -


i trying create website using cgi , erb, when search on web, see people saying should avoid using cgi, , use rack.

i understand cgi fork lot of ruby processes, if use fastcgi, 1 persistent process created, , adopted php websites too. plus fastcgi interface create 1 object 1 request , has performance, opposed rack creates 7 objects @ once.

is there specific reason should not use cgi? or false assumption , entirely ok use cgi/fastcgi?

cgi, mean both interface , common programming libraries , practices around it, written in different time. has view of request handlers distinct processes connected webserver via environment variables , standard i/o streams.

this state-of-the-art in day, when there not "web frameworks" , "embedded server modules" think of them today. thus...

cgi tends slow

again, cgi model spawns 1 new process per connection. while spawning processes per se cheap these days, heavy web app initialization — reading , parsing scores of modules, making database connections, etc. — makes quite expensive.

cgi tends toward too-low-level (imho) design

again, cgi model explicitly mentions environment variables , standard input interface between request , handler. ... cares? that's lower level app designer should thinking about. if @ libraries , code based on cgi, you'll see bulk of encourages "business logic" right alongside form parsing , html generation, seen dangerous mixing of concerns.

contrast rack::builder, right away coder thinking of mapping namespace action, , means broader web application. (suddenly free argue semantic web , virtues of rest , , that, because we're not thinking generating radio buttons based off user-supplied input.)

yes, rack::builder implemented on top of cgi, but, that's point. it'd have layer of abstraction built on top of cgi.

cgi tends sneeringly dismissed

despite cgi working within limitations, despite being simple , understood, cgi dismissed out of hand. you, too, might dismissed out of hand if cgi know.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -