Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've seen questions (mainly on Stack Overflow), which lack this basic knowledge. The point of this question is to provide good information for those seeking it, and those referencing to it.

In the context of web programming, what are the differences between Server-side programming and Client-side programming? Which languages belong to which, and when do you use each of them?

share|improve this question

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

3  
Server-side programming is writing code that runs on the server, using languages supported by the server (such as Java, PHP, C#; it is possible to write code that executes on the server-side in JavaScript). Client-side programming is writing code that will run on the client, and is done in languages that can be executed by the browser, such as JavaScript. –  FrustratedWithFormsDesigner Oct 24 '12 at 14:13
    
This one is pretty good: programmers.stackexchange.com/questions/138561/… –  JeffO Oct 24 '12 at 14:16
4  
I think you should include in the question that you refer only to web programming, as in the current form the answers are not complete. For example, server-client communication need not be done in HTTP; client side might not use a browser, etc. –  K.Steff Oct 24 '12 at 14:42
    
@KSteff you are welcome to edit my question to add that. –  Madara Uchiha Oct 24 '12 at 17:06

2 Answers 2

up vote 48 down vote accepted

Background

Web development is all about communication. In this case, communication between 2 parties, over the HTTP protocol:

  • The Server - This party is responsible for serving pages.
  • The Client - This party requests pages from the Server, and displays them to the user. On most cases, the client is a web browser.
    • The User - The user uses the Client in order to surf the web, fill in forms, watch videos online, etc.

Each side's programming, refers to code which runs at the specific machine, the server's or the client's.

Basic Example

  1. The User opens his web browser (the Client).
  2. The User browses to http://google.com.
  3. The Client (on the behalf of the User), sends a request to http://google.com (the Server), for their home page.
  4. The Server then acknowledges the request, and replies the client with some meta-data (called headers), followed by the page's source.
  5. The Client then receives the page's source, and renders it into a human viewable website.
  6. The User types Stack Overflow into the search bar, and presses Enter
  7. The Client submits that data to the Server.
  8. The Server processes that data, and replies with a page matching the search results.
  9. The Client, once again, renders that page for the User to view.

Programming

Server-side Programming

Server-side programming, is the general name for the kinds of programs which are run on the Server.

Uses

  • Process user input.
  • Display pages.
  • Structure web applications.
  • Interact with permanent storage (SQL, files).

Example Languages

  • PHP
  • ASP.Net in C#, C++, or Visual Basic.
  • Nearly any language (C++, C#, Java). These were not designed specifically for the task, but are now often used for application-level web services.

Client-side programming

Much like the server-side, Client-side programming is the name for all of the programs which are run on the Client.

Uses

  • Make interactive webpages.
  • Make stuff happen dynamically on the web page.
  • Interact with temporary storage, and local storage (Cookies, localStorage).
  • Send requests to the server, and retrieve data from it.
  • Provide a remote service for client-side applications, such as software registration, content delivery, or remote multi-player gaming.

Example languages

  • JavaScript (primarily)
  • HTML*
  • CSS*
  • Any language running on a client device that interacts with a remote service is a client-side language.

*HTML and CSS aren't really "programming languages" per-se. They are markup syntax by which the Client renders the page for the User.

share|improve this answer
2  
+1 for a good answer with examples of the uses! Just to nitpick: HTML and CSS are not actually programming languages, so they probably shouldn't be compared to "PHP, ASP, and Nearly any language (C++, C#, Java)". ActionScript might be another good example of a client-side language. –  FrustratedWithFormsDesigner Oct 24 '12 at 14:25
3  
Next time, use the insta-answer feature ("answer your own question" checkbox below the question textarea) –  Yannis Rizos Oct 24 '12 at 14:26
2  
@MadaraUchiha Yeah, don't do that when you already have a good answer, why waste anyone's time (since you already have a good answer). –  Yannis Rizos Oct 24 '12 at 14:29
3  
Well, you could have given the community more than 15 minutes then, you posted the answer 13 minutes after the question. That, to Programmers, is an insta-answer (remember this isn't Stack Overflow, we don't have as much traffic) –  Yannis Rizos Oct 24 '12 at 14:32
2  
You fail to identify why the server is a server and the client is a client. The server is known about by the client, but not the other way around. The server is expected to be executing at all times, there are no client expectations. –  Chris McCall Oct 24 '12 at 15:04

In layman's words:

Here I will talk only about web programming.

Client side programming has mostly to do with the user interface, with which the user interacts. In web developing it's the browser, in the user's machine, that runs this code, and is mainly done in javascript, flash, etc. This code must run in a variety of browsers.

Its main tasks are:

  • validating input
  • animation
  • manipulating UI elements
  • applying styles
  • some calculations are done when you don't want the page to refresh so often

The person in charge of front end programming must know:

  • javascript
  • css
  • HTML
  • basic graphic design
  • Ajax
  • maybe Flash
  • some 3rd party javascript libraries like JQuery
  • UI design
  • information design, etc.

Server side programming has to do with generating dynamic content. It runs on servers. Many of these servers are "headless". Most web pages are not static, they search a database in order to show the user updated personalized information. This sides interacts with the back end, like say, the database.

This programming can be done in a lot of languages:

  • PHP
  • Java and jsp
  • asp
  • Perl
  • Python
  • Ruby on Rails, etc.

This code has to do which:

  • Querying the database
  • Encode the data into html
  • Insert and update information onto the database
  • Business rules and calculations

The person in charge of server side programing must know:

  • some of the languages mentioned above
  • HTML
  • SQL,
  • linux/unix shell scripting
  • OOP
  • business rules, etc.
share|improve this answer

protected by World Engineer Sep 1 '13 at 15:42

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.