Scripting Languages:
How to know what to use when

Provided by the Good News Web Designers Association

Return to Directory of Tutorials or GNWDA home page

   

When we write code that makes the computer do something, we are programming. (On the web, our programming is usually really scripting, but that's more precise than we need to be and debatable anyway.) Web programs make the user's computer do something, or they make the server do something. If your program makes the user's computer do something, it is client-side; if it makes the server do something, it is server-side.

1. HTML

HTML is the basic document language of the web. Writing HTML is not programming: it is just an ugly version of word processing or desktop publishing. In fact, writing HTML is a lot like word processing and desktop publishing in the bad old days before WYSIWYG (What You See Is What You Get) graphical word processors and desktop publishers. If you use any version of WordPerfect, you can still “Reveal Codes” and see all the tags that define the appearance and structure of your document.

HTML suffers from multiple personality disorder. Dr. H. T. Jekyll describes the structure of a document: e.g., <p></p> indicates that the enclosed content is a paragraph; <ol></ol> indicates an ordered list with items denoted by <li></li>. Mr. M. L. Hide tries to say what the document should look like: e.g., <font></font> tags prescribe font color, size, and face of their content; bgcolor and align attributes prescribe background color and text alignment.

2. CSS 

CSS is designed only to say what a document should look like. CSS has a richer vocabulary for saying what HTML should look like than HTML itself. CSS and HTML don't do anything, they just get processed and displayed.

3. Looking Good, Being Clean, Feeling Great

If you're starting a new site or a new section of a site, you should seriously consider using HTML and CSS only for their strengths. HTML does a fair job of describing the structure of a document, but it only works for appearance by a lot of weak hacks (spawning endless tutorials and tips!). Ideally, you wouldn't even use a table for anything except a table of data (see http://glish.com/css/ for templates and tutorials), but that may be too much of a jump. If you don't want to jump all the way into CSS layout, try using a table for the basic layout of the page but use CSS for your text styles. Instead of six or eight non-breaking space entities to indent paragraphs, just write a style rule to indent all paragraphs, or only some you choose on the basis of position in the document or a class attribute. Instead of writing the same font tag over and over again to make your headings large, Arial, and burgundy, use <h1>, <h2>, or whichever heading is relevant and write a style rule making them all the right look. CSS has a bit of a learning curve at first, but using CSS as exclusively as possible for specifying the appearance of your site will help you make your site look good and keep your code clean. When you discover how easy it is to make style changes site-wide, you'll feel great.

4. It Would Be Really Cool If . . .

If you're thinking about a proposed feature of an individual page in terms of “it would be really cool if it could do X,” X probably involves JavaScript. JavaScript is a client-side technology: the programs you write in JavaScript will make a visitor's web browser do something, but to your server they are only so much text. Anything that could be called a special effect on a web page, if it requires programming at all, is probably done with JavaScript. Examples include pull-down menus, moving an image or block of text around on a page, and the ever-popular switching out images.

5. Getting Started with JavaScript

JavaScript is easy to cut-and-paste and not too difficult to begin learning. It is, however, harder than HTML or CSS, and building a deep understanding of the differences between all major web browsers can take years. If your requirements are not unusually advanced, you can sidestep learning much JavaScript if you develop your websites with Macromedia Dreamweaver. Adobe GoLive has similar functionality, but for the same amount of money you would be well served to use industry-standard Dreamweaver. Microsoft Front Page is inadequate for developing JavaScript, and the short-cuts it provides result in inferior, sloppy, and harder-to-use pages.

6. Alternatives: Java Applets and Flash

There are two other major client-side technologies: Java Applets and Flash. Like JavaScript, both are rarely used for anything but special effects, but any of the three can be combined with server-side technologies to produce complete applications. Java performs poorly for special effects and should be avoided. Flash was made for special effects and works well for the purpose, but perhaps more than any other web technology it has been over-used and abused to the detriment of usability, efficiency, and even taste on the Internet. If you start developing Flash (you will need Macromedia Flash MX), you will have to work hard to resist the temptation to create effects just because you can. Seek guidance from an experienced developer or designer who began his or her career with the web: not multimedia CDs, not television, not print.

If you want to build an advanced application involving extensive interaction between client and server or just incredible effects “like that site over there,” but you don't already have some idea of which set of technologies would best fit your needs, you need to hire someone to help you or do it for you.

Occasionally you may run across VBScript on the web. VBScript is a Microsoft-only technology meant to do exactly what JavaScript does. VBScript's programming model is inferior to that of JavaScript, and there is virtually never a good reason to use it, since it excludes users unnecessarily and promotes weaker coding.

7. Handling Information From Visitors

If your web site needs to do anything with information supplied by visitors, you will need server-side programming. Basic examples of functionality requiring server-side programming include guest books, forums, and contact forms. Popular scripts to implement all of the above are freely available for most kinds of servers. If you need a loan application, a library of content, a calendar, or anything that facilitates a group of people working together, though, you may find ready-made solutions unavailable or inadequate to your needs.

Choosing a server-side technology is complicated. Depending on where you are working or what server you already have an account with, your choice may be made for you. If the choice is up to you, however, you'll need to choose between Java Server Pages, Active Server Pages, ASP.Net, Cold Fusion, PHP, Perl, and many others. All other features being equal, a web host offering PHP or Perl is nearly always going to be cheaper than any of the alternatives. Perl is complicated and not really designed for web development, so I would recommend against it. If you only need to do simple things, you will find PHP very simple to use, and there are numerous high-quality solutions to common needs freely available on the web. I have been using PHP for years to develop increasingly complex web applications, and I find it to be powerful and flexible enough for those as well. I have also worked extensively with Active Server Pages (ASP), but ASP is now obsolete, replaced by ASP.Net, so it is not a good choice for new projects. ASP.Net is reported to eliminate many of the weaknesses of ASP, but it is still in the early-adoption phase and comes with a higher server price tag.

8. Beware of Geeks Bearing Gifts

Whenever you want to use information from your visitors for any purpose, you must remember that you can't trust them to provide you with the right information, or even with safe information. Providing your users with the convenience of a JavaScript-powered form check before the form actually submits is good practice, but if your form requires an email address for example, client-side JavaScript is insufficient to insure that every complete form submission actually includes an e-mail address. Perhaps none of the wonderful people who usually visit your site would want to give you bad data, but some computer geek with a bad attitude might give you the pleasure of his company, or someone's computer may be limited or malfunctioning, and all the JavaScript alerts in the world won't stop them from feeding bad data into your system that could cause errors in your database or even compromise your system, depending on your application. If anything about the data matters, it has to be checked on the server side, which may be the best reason to learn at least the basics of some server-side scripting language as soon as possible.

© 2003 by Joshua Paine

EXTRA TIPS

Server-side scripting is also the better way to do a hundred little things for which there are thirty JavaScript tutorials each — all about how to make up for the fact that you aren't handling the functionality on the server side. Inserting a random quote or picture into a page, displaying the current date, and maintaining standard headers and footers, for example, are all trivial with any server-side scripting language, and really should never be done in JavaScript.

LINKS

In the near future, this article will be sprinkled with links throughout. In the meantime, if you want to know more about anything mentioned here, just go to google.com and type in your topic of interest.

Return to Directory of Tutorials or GNWDA home page