The background to C# / PDF
The background to C# / PDF
The history of
C#
A computer program is a series of
instructions that are obeyed by a computer. The point of the instructions is to
carry out a task — e.g. play a game, send an e-mail, etc. The instructions are
written in a particular style: they must conform to the rules of the
programming language we choose. There are hundreds of programming languages,
but only a few have made an impact and become widely used. The history of
programming languages is a form of evolution, and here we will look at the
roots of Cit (‘C Sharp’). The names of the older languages are not important,
but we provide them for completeness.
Around 1960, a programming language named
Algol 60 was created. (‘Algol’ from the term ‘algorithm’ - a series of steps
that can be performed to solve a problem.) This was popular in academic
circles, but its ideas persisted longer than its use. At this time, other
languages were more popular: COBOL for data processing, and Fortran for
scientific work. In the UK ,
an extended version of Algol 60 was created (CPL — combined programming
language), which was soon simplified into basic CPL, or BCPL.
We then move to Bell Laboratories USA,
where Dennis Ritchie and others transformed BCPL into a language named B, which
was then enhanced to become C, around 1970. C was tremendously popular. It was
used to write the UNIX operating system, and much later, Linus Torvalds used it
to write a version of UNIX — named LINUX — for PCs.
The next step came when C++ (‘C plus-plus’)
was created around 1980 by Stroustrup, also at Bell Labs. This made possible
the creation and reuse of separate sections of code, in a style known as
‘object-oriented programming’. (In C, you could use ++ to add one to an item —
hence C++ is one up from C.)
C++ is still popular, but hard to use; it
takes a lot of study. Around 1995, Sun Microsystems produced the Java language,
which was heavily based on objects, but was simpler than C++. It also had the
benefit of being able to run on many types of computers (Microsoft Windows PCs,
Apple Mac, etc.). Java is still popular today.
In 2002, Microsoft announced the C# (‘C
sharp’) language. It was similar to C++ and Java, with enhancements. (In music,
the # sharp symbol means ‘one semitone higher’.) It was a major part of
Microsoft’s ‘dot net’ initiative, described below. Because of C#’s similarity
to its predecessors, learning it will make C, C++ and Java more approachable if
ever you need to use them.
Of course, the above potted history is
constrained to the branch of evolution that encompasses C, C++ and Java.
Another notable branch began in 1964, with the invention of a language for
beginners named BASIC, which has evolved to a version named Visual Basic — also
part of ‘dot net’.
The Microsoft
NET framework
In 2002, Microsoft introduced a major new
product, named the .NET framework. This is pronounced ‘dot net’. The main
features are:
It comes with the programming languages C#,
Visual Basic and C++.
It has facilities which help programmers to
create interactive websites, such as those used for e-commerce. Microsoft sees
the Internet as crucial, hence the name .NET.
There is the possibility of .NET being
available for other operating systems, not only Microsoft Windows.
It lets us build software from components
(‘objects’) that can be spread over a network.
• What is a program ?.
In this section we try to give the reader
some impression of what a program is. One way to understand it is by using
analogies with recipes, musical scores and knitting patterns. Even the
instructions on a bottle of hair shampoo are a simple program:
wet hair
apply shampoo
massage shampoo into hair
rinse
This program is a list of instructions for
a human being, but it does demonstrate one important aspect of a computer
program - a program is a sequence of instructions that is obeyed, starting at
the first instruction and going on from one to the next until the sequence is
complete. A recipe, musical score and a knitting pattern are similar - they
constitute a list of instructions that are obeyed in sequence. In the case of a
knitting pattern, knitting machines exist which are fed with a program of
instructions, which they then carry out (or ‘execute’).
This is what a computer
is - it is a machine that automatically obeys a sequence of instructions, a
program. (In fact, if we make an error in the instructions, the computer is
likely to do the wrong task.) The set of instructions that are available for a
computer to obey typically includes:
• input a number;
• input some characters (letters and digits);
• output some characters;
• do a calculation;
• output a number;
• output some graphical image to the screen;
• respond to a button on the screen being clicked by the mouse.
The job of programming is one of selecting
from this list those instructions that will carry out the required task. These
instructions are written in a specialized language called a programming
language. C# is one of many such languages. Learning to program means learning
about the facilities of the programming language and how to combine them so as
to do something you want. The example of musical scores illustrates another
aspect of programs. It is common in music to repeat sections, for example a
chorus section. Musical notation saves the composer duplicating those parts of
the score that are repeated and, instead, provides a notation specifying that a
section of music is repeated. The same is true in a program; it is often the
case that some action has to be repeated: for example, in a word-processing
program, searching through a passage of text for the occurrence of a word.
Repetition (or iteration) is common in programs, and C# has special
instructions to accomplish this.
Recipes sometimes say something like: ‘if
you haven’t got fresh peas, use frozen’. This illustrates another aspect of
programs - they often carry out a test and then do one of two things depending
on the result of the test. This is called selection, and as with repetition, C#
has special facilities to accomplish it.
If you have ever used a recipe to prepare a
meal, you may well have got to a particular step in the recipe only to find
that you have to refer to another recipe. For example, you might have to turn
to another page to find out how to cook rice, before combining it with the rest
of the meal: the rice preparation has been separated out as a sub-task. This
way of writing instructions has an important analogue in programming, called
methods in C# and other object-oriented languages. Methods are used in all
programming languages, but sometimes go under other names, such as functions,
procedures, subroutines or sub-programs.
Methods
are sub-tasks, and are so called because they are a method for doing something.
Using ............The background to C# / PDF
0 commentaires: