Screen Printing

TUTORIALS » Before you build a website » The world wide web basics

Server side vs Client side languages



Now that you know the difference between a server and a client, you should be ready to start programming your first web site but... there is a whole bunch of languages for website development, which one should you use?

First, let me explain a few things:

Web browsers

You are reading this web page; this means you are using a web browser program. There are five major web browsers being used today around the world: Microsoft's Internet Explorer, Mozilla's Firefox, Apple's Safari, Opera, and Google's Chrome.

Each one has its own pros and cons, but they all have something in common: they all read HTML code, which is the basic language for displaying web pages. HTML is a client-side language. What does client-side language means? Let's see:

Client Side

If you are coding a web page using a client-side language and you include a math statement like:
2 + 2
then the server won't calculate anything. Actually, the server won't even care if it is an addition or a subtraction, if it is red or blue, or if the code is well written or not; the server will simply send the whole code to the client computer and let it deal with the operation. So it is up to the client computer (more specifically the web browser) to "read" the code, perform the operation, and display a number 4 on the screen. That is why it is called a client-side language.

Client side
Figure 1  Note that the client does all the "thinking"

The basic client side languages supported by all the major web browsers are:

HTML (Hyper Text Markup Language) - This is the basic language to program all the text that you want to display in a web page, and how you want it to look like. This very text is done using HTML. You can add color, font sizes, font styles, tables, static images and links to other pages; HTML displays plain pages and graphics, and is not capable of more "dynamic" functions like math operations (e.g. 2 + 2), comparators, or conditionals.

JavaScript - Just as HTML, JavaScript is a client-side language intended to work along with HTML to do all the "dynamic" work HTML cannot do on its own. With JavaScript you can now add math operations, comparators, and conditionals to your web page. We can call JavaScript as the "dynamic" buddy of HTML.

Server Side

Opposite to client-side languages, server-side languages do all the work inside the server before the result is sent to the client computer; so if you include your 2+2 statement in a server-side language coded page, the server will perform the operation and send a plain "4" to the client computer. This way, the client computer will never know how this number 4 was achieved; it will just have to rest happy knowing that our number 4 arrived safely. The major server-side languages are: PHP, ASP, JSP, Python, Perl, and ColdFusion. Since it is free, very reliable, powerful, and relatively easy to learn, we recommend using PHP as your server-side language of choice.

Server side
Figure 2  Here the server does all the "thinking"

Client-side vs. Server-side languages

Imagine you want your web site visitors to fill a form with their name and email address, and you want to make sure they fill both fields before they click the "Submit" button. Since this validation has to happen inside the client (before they send anything back to the server) a good language to use would be JavaScript (Yes, client-side). Your JavaScript code will check if both fields are properly filled; if they are, it will send the form back to the server, if they are not, it will display an alert telling the user to fill both fields.

Now imagine you are building a web site whose contents will be dynamically created based on additional information stored inside the server, just like a news web site, or an online store, or a blog, or a forums system like the one we have here. Building each and every one of the pages manually would be just too complicated since the information is constantly changing, so you might want to use a server-side language to build a site that delivers web pages that have been dynamically built, every time, based on the user's requests.

Are you ready to start learning HTML? Go to our first HTML tutorial.

Comments & Questions