Computer Programming

A computer program is a set of instructions compiled from source code (the code written by a programmer) that a computer will follow when the program is executed - i.e., when the program runs. The program can be quite simple and consist of a few lines of code, or it can be incredibly complex, consisting of millions of lines of code. The total number of lines of source code in a computer program is often used by software engineers as a metric against which the size and complexity of a program or software project can be gauged.

The earliest computer programs for electronic (as opposed to mechanical) computing devices were written in assembly language - a low-level programming language that uses a set of human-readable mnemonics to represent the binary machine code instructions that the computer hardware understands.

Conversion of the assembly language into machine code is carried out by a special program called an assembler, whose output is called object code. Another program, called a linker, takes one or more files containing object code, and links them together before using them to generate an executable program file that the computer can run.

Writing a program in assembly language is time-consuming and labour intensive, because there is often a one-to-one correspondence between assembly language instructions and the machine code instructions they represent. Nevertheless, assembly language is still used in areas such as embedded and real-time systems where direct control over hardware is required and both program size and execution speed are critical factors.

Most modern application programs are written in a high-level programming language for which the source code consists of a series of English-like statements, each of which may be the equivalent of several assembly language instructions. Programs written in a high-level programming language are typically compiled into object code by a program called a compiler. The resulting object code is then used to create an executable file by the linker.

Computer programming is the task of writing the source code for a program using a suitable computer programming language. The number of programmers involved in carrying out this task very much depends on the size and scope of the project being undertaken. Small, stand-alone programs are often written and maintained by a single programmer. Larger applications may be broken down into functional units called modules, each of which is handled by a different individual or dedicated programming team.

The choice of programming language is dependent to some extent on the nature of the application. Procedural languages such as Fortran, Basic and C are based on the concept of calling procedures, also known as subroutines or functions, each of which consists of a series of computational steps designed to achieve a very specific task.

Object oriented languages such as C++ and Java are based on the concept of objects. An object is a self-contained entity that represents some real-world object. It encapsulates both the attributes that describe the entity's state, and the methods that can be called upon to access and manipulate those attributes.

As the size and scope of application programs has increased, the task of managing the software development process has also become increasingly complex. This has led to the creation of integrated development environments (IDEs) - software programs that are designed to help the programmer or programming team to develop and manage code in an efficient manner. An IDE typically provides facilities that allow programmers to write and edit code, and to build and test programs and program components.

In addition to IDEs, there are a large number of code libraries available for most popular programming languages. A code library is a collection of reusable code elements, each of which is designed to handle a very specific task. The availability of code libraries simplifies the task of writing code, allowing the programmer to concentrate on the code that deals with the specific problems the application is designed to solve.

The emergence of visual programming languages over the last two decades or so has helped to popularise computer programming. Microsoft's Visual Basic first appeared in 1991, and provided both an event-driven programming language and an integrated development environment that could be used to quickly produce a graphical user interface (GUI) using Visual Basic's built-in forms and form control objects. Adding the functional code associated with the GUI controls was also relatively easy, which made Visual Basic an ideal entry-level programming language.

The availability of code libraries, integrated development environments, and visual programming languages has greatly enhanced our ability to create and maintain software, and to manage even the most ambitious software projects. The down side is that application programmes have grown exponentially in size and complexity - a phenomenon sometimes referred to as "code bloat".

This increase in size and complexity can partly be explained by the increased sophistication and functionality of the applications themselves, but is also due to the inclusion of a significant amount of code which is simply never used by the application. The use of code libraries, for example, invariably requires that all of the library's code is compiled together with the code we have written ourselves, even if have only used a small part of the library's functionality.

These pages are intended to introduce the reader to the practical aspects of writing a computer program using various programming languages, including C (a largely procedural programming language), C++ (an object-oriented programming language), and Visual Basic (an event-driven visual programming language currently provided as part of Microsoft's Visual Studio IDE). We hope to expand on the existing material, as well as adding content that covers other programming languages, in the not-too-distant future.