Entry Level PHP Web Application Development/What is Programming? Why Write for the Web?

From Wikibooks, open books for an open world
Jump to navigation Jump to search

As a user, you control application software — or programs — that are already written for you to use. Examples of this include your web browser, word processor, or Internet e-mail program. If you need something more than what has been provided for you, however, you are out of luck, unless you know how to give the computer instructions on your own. This is where the practice of programming comes into play.

As you read through this section, you will learn about what programming is, and why you might want to write Web applications. Keep in mind that term Web application throughout this book means “an application accessed through a web browser”. This could be on an intranet or on the Internet.

Programming, in General[edit | edit source]

Computer programming is simply writing a set of instructions for the computer to use to perform a certain task. In essence, you give the computer small steps of instructions, and the computer goes down the list, executing each one in order[1]. By programming, you can “teach” the computer how to perform new tasks, or perform old tasks in new ways. As a user, you control application software — or programs — that are already written for you to use. Examples of this include your web browser, word processor, or Internet e-mail program. If you need something more than what has been provided for you, however, you are out of luck, unless you know how to give the computer instructions on your own. This is where the practice of programming comes into play. Computers, however, do not “speak” English. This means that you will have to learn how to communicate with the computer to make your instructions work. Unlike human languages, there is a best language for each purpose, so it is entirely possible that over time you will learn new languages for doing different types of tasks. This book focuses on the basics of web application programming with one of the most popular web development languages, PHP.

What is Web Programming?[edit | edit source]

Web Programming is the practice of writing applications that run on a web server, which can, in turn, be accessed by many different users. There are many applications which are suitable to be run over the web, and because of that, web applications have become extremely popular. A few examples of popular web applications are Gmail and Google Maps. These are applications in which users are able to send and receive Internet e-mail, and get maps, satellite images, and directions, respectively.

Web application programming has several advantages over methodologies such as client-server programming for applications such as e-mail and geocoding. Web applications can be made in such a way as to be portable — that is, able to run on many types of clients. Some care must be taken to achieve this, however, we will go into that later in the text. Web applications do not generally have to be compiled to be tested, and web applications can run from anywhere in relation to the user. Additionally, web applications allow users that have low-powered hardware to be able to perform computationally intensive tasks without using their own computer. For example, Google does the geocoding and the mapping for users, and then simply transmits the data back to the user. The user’s computer does not have to actually perform the computations necessary to get the data for the user.

There are some disadvantages to writing web applications that must be considered. Applications that are extremely computationally intensive, for example, may perform sluggishly with poor planning. Highly popular applications may require load balancing and such to handle a heavy user-base. Network resources can become heavily loaded if the user-base grows or is using the web application more than anticipated. Generally, all of these things can be taken care of by careful planning, however.

What is PHP?[edit | edit source]

PHP is an Open Source scripting language that is available to the public for free (both gratis and libre). It is primarily used for programs written to run on servers, over the web. More information on PHP is available on Wikipedia in the PHP article and the PHP web site, and, of course, throughout this book.

What Types of Applications are Good Web Applications?[edit | edit source]

In general, any application that:

  • Has a moderate to high number of users
  • Has consolidated, shared data storage (such as a database)
  • Has business rules that are not always easily enforced on the client side
  • Does not have high computation overhead for every user

... is a good candidate for becoming a web application. Sometimes, there are exceptions from these rules, depending on the business. Many applications that are client-server applications fall into the category of being an able candidate for being re-written as a web application.

What Types of Applications are Not Good Web Applications?[edit | edit source]

Applications that have extremely high computing overhead for a user (i.e., video conversion/recoding) generally are not good candidates for becoming web applications. Tasks that must be done on the client computer (such as burning a CD) are also not good candidates for web applications. There are applications that make advanced use of clustering technologies (where multiple servers are working together) and load-balancing (where servers are working individually, but getting only a certain percentage of the load), however, those are outside the scope of this document.

Why Write a Web Application?[edit | edit source]

There are multiple reasons to write web applications as opposed to a traditional application. There are also more varied types of applications that are unique to the web, which would be impractical as a client-server application. For example, a web site for a support organization should not be a static web site. It should actually be a web application that works with databases (perhaps even more than one) and other sources of input. It may even have a content management system that has Frequently Asked Questions for users, or How-To information, or general background/historical information.

Web applications are generally faster to develop then applications that are written in systems programming languages, such as C or C++. There are also many different environments that help you to write, test, and debug in a very fast, streamlined cycle. We will get into some of these later in this book.

Another advantage to web applications is that they also have an unusually clear line between what is called the front-end and the back-end. The user always sees the results that are displayed by the front end, while the back end is never visible. Programs written with different development models (such as client-server applications) have various degrees of separation of the front-end and back-end, and because of the nature of such applications, there is no clear line between them[2].

One advantage – and disadvantage – to traditional web applications is that the source code is always hidden from the user. Because the code is not running on the user’s PC in any capacity, the user is not able to view the actual code. This is something of a double-edged sword: It means that you can conceal the code, and the back-end processes, completely from the user. This makes it harder to reverse-engineer, which is good for proprietary code. However, it can be harder to manage from the standpoint of a technical user, since the source code for the web application and the processes are completely hidden from anybody that does not have access to the code on the server. This is a decision that is made before the work starts on a project, traditionally. Most people view this as an advantage.

Footnotes[edit | edit source]

  1. ^ Technically, some computer processors can execute code out-of-order. However, this is a subject for systems and/or operating system programming – it is out of the scope of this book.
  2. ^ Client-server applications can have the computing tasks shared between the client and server, or all the processing can be done on the server, or there can be varying degrees of this separation. It is actually up to the programmer’s discretion. This is partially true in Web applications, as well, as we will see later.