Choosing The Right Server-Side Scripting Language
By Craig McElwee2004-01-06
How Five Languages Do The Same Basic Tasks
Assuming your Web site currently serves up dynamic content, how did you pick your scripting language from the numerous open source server-side scripting methodologies available? Did you inherit it or receive it from on high? Or did you methodically look at the pros and cons of each option, weigh them against your site's needs, deadlines, and your own skill set, and choose the one that fit best? If not, read on. You may find a scripting solution that is easier, more powerful, simpler to maintain, or just more fun.
Personally, I used the highly scientific notion of personal bias to select five languages for comparison: Java servlets, Perl, PHP, Python, and Tcl. These fall into two basic categories: Common Gateway Interface (CGI, or calling an external program that returns HTML) and what I call Super Markup (an HTML page embedded with other-language markup code -- a superset of HTML). My apologies if I left out your favorite sever-side scripting tool; mine is not an exhaustive compilation of possibilities (since practically any language can be used for CGI).
To show how they work side-by-side, we'll implement the same six tasks in each language:
Task 1: Get and format the time/date
Task 2: Put form field data into variables: receive 2 HTML form field variables
Task 3: Search and replace
Task 4: File writing: write the two values, along with the transaction date and time as a comma-separated string to a CSV text file (CSV = comma-separated values, such as: one, two, three)
Task 5: File reading: read and present all the records of said CSV file
Task 6: Split comma-delimited line into variables: split the last, just submitted, record back into individual fields for processing, in this case simply echoing back to the browser
Barring the use of a "real" database, these six tasks cover a lot of basic functionality, and you can derive most chores, with modest modifications, from them.
This article provides five scripts (see Resources), one per language, for the basic set of tasks above. Take a moment to them look over to get a feel for each before we dissect them. Gurus in any of these languages will note that I've dropped most language idioms, leaving the constructs they replace, thus favoring readability (for newcomers' benefit) over performance.
Let's go through the programs task by task.
Tutorial pages:
|
First published by IBM developerWorks
|
|||||||||
You might also want to check these out:
|
Leave a Comment on "Choosing The Right Server-Side Scripting Language"
You must be logged in to post a comment.
Link to This Tutorial Page!

