C Primer Plus (5th Edition)
C#'s Background
Before we begin the practical parts of creating a C# program, it is useful to take a look at C#'s roots and design goals.
Currently, there are more than 2000 different high-level languages. Each was designed to fulfill certain requirements related to a specific problem domain and some of them provided inspiration for the designers of C#.
New Term: Problem Domain
The problem domain is the realm or range of a specific set of related problems. Some examples are computer simulations and nuclear physics. |
One of the main incentives to invent new languages has been the growing need to develop complex applications. Users have increasingly demanded feature-packed, easy-to-use programs running on faster, more sophisticated computers. Ironically though, the easier a program is to use, the harder it is to program. Today's user-friendly interfaces, also called GUIs, contain windows, menus, icons, and all the other features most of us now take for granted. These are based on extremely intricate underlying applications.
Note
Progress in the theory of computing, especially in the formal understanding of semantics, modules, program abstractions, and processes, has been a major factor in allowing the evolution of languages to continue. |
The meaning or an interpretation of the meaning of a word, sign, sentence, and so on is referred to as semantics of a language.
Figure 2.7 presents a genealogical tree of selected high-level languages preceding C#. They might well be considered the most important in terms of popularity or influence on other languages.
Figure 2.7. Genealogical tree of influential high-level languages.
The date for each language is approximate and indicates when a broader audience knew about the language.
Note
A few technical terms are used in this discussion with which you will probably not be familiar. They are included for completeness and should not interfere with the overall understanding of this section. |
According to the designers of C#, a wide spectrum of many different languages have influenced them. In this section, we will only look at a few selected obvious predecessors to C#.
The origins of C# can be traced all the way back to FORTRAN and Algol.
Developed in the 1950s, FORTRAN is the first high-level imperative language. The acronym FORTRAN stands for FORmula TRANslator, reflecting that the main purpose of FORTRAN was to translate mathematical formulas into sequences of assembly language instructions.
Algol 60 was considered a major step forward in clarity and conciseness compared to previous languages. It is the original block structured language and has had an enormous influence on most programming languages. The block is also an important aspect of C#. Chapter 3 will introduce you to this concept, which is used in numerous languages today.
The C designers got their basic ideas from the Algol family of languages and were, to a large degree, influenced by C's intended use as a programming language to write the UNIX operating system. Despite this limited initial use, C became one of the most popular imperative languages due to its concise syntax and fast execution.
Pascal was very popular during the 1970s and 1980s, especially in academic circles and for teaching purposes. It was designed in the late 1960s as a response to Algol 68's (a direct descendant of Algol) very complicated design.
FORTRAN, Algol, Pascal, and C are all referred to as procedural programming languages and are linked to the process-oriented programming style. A procedural language has at its core a set of procedures that acts upon data. Each procedure contains a set of instructions executed in a step-by-step fashion. The procedures are somewhat separate from the data, as illustrated previously in Figure 2.2. This means that much of the programmer's time is devoted to checking which procedures act on what data and when. As the complexity of the application increases, it becomes increasingly difficult for the programmer to use this method; hence, the need for a new paradigm is apparent.
Ideas of encapsulating the procedures together with the data they were acting on, already illustrated in Figure 2.3, led to object-oriented programming. This was perceived as the new model for which many frustrated programmers had been waiting.
The common predecessor of most object-oriented languages is Simula, designed in the 1960s. Simula was built on the ideas of Algol60 and was targeted at writing simulation programs, such as the Elevator simulation presented earlier in this chapter. This emphasis on simulations introduced the paradigm of writing programs reflecting the objects (nouns) of the problem domain and their actions (verbs) and attributes, all of which are now at the core of object-oriented principles.
Lisp is the earliest functional language and is used extensively for computer programs related to artificial intelligence. Lisp is very different from languages like C++ and C#, but it contains one mechanism that has been adopted by many languages, including C# automatic reclamation of memory, also called garbage collection.
Smalltalk extended the ideas of Simula. It is considered the quintessential object-oriented language. Everything in SmallTalk is an object, or part of an object and all actions are considered to be "messages" sent between these objects. Later, you will see why everything in C# can also be viewed as being an object or part of an object.
Several attempts were made to turn C into an object-oriented language, but Bjarne Stroustrup's C++ turned out to be the most successful by far. C++ is largely a superset of C. It provides what most programmers would regard as improvements, such as type checking, overloaded routines, and object-oriented programming features.
C++ is a very powerful language due to its inheritance of C's features that support operating system development. Unfortunately, the acquisition of power and freedom is directly related to the responsibility, complexity, and risk of "pressing the red button," in other words, creating plentiful bugs.
Java is based largely on a subset of C++ and is considerably simpler. It was designed for the construction of architecture-neutral, highly portable programs. An intermediate language, called byte code, which is comparable to MSIL, is interpreted by a Java virtual machine (JVM) during execution. It features a type-safe reference model, a simplified inheritance model, multi-threading, and extensive class libraries.
Basic is a very simple language. Basic is short for Beginner's All-purpose Symbolic Instruction Code.
Visual Basic was created by Microsoft and is very different from Basic. It is the most widely used programming language today. Part of its huge success is due to its Rapid Application Development (RAD) capabilities when integrated with the Microsoft's Visual Studio development environment. RAD allows programmers to design GUI-based programs rapidly by dragging and dropping visual components in a visual design environment.