Programming language Choice
-
1950 - machine-code (or assembler) used. One mc instuction becomes one
cpu instruction: 1:1, 'low-level'
-
by 1960, several 'high-level' many:1 languages. One line is
compiled into many mc instructions.
-
see tree in booklet.
Areas of Use
-
business I.S - was Cobol. Nowadays database
-
'systems programming' - fast code needed. C, C++
-
real-time - process control, 'embedded systems'. There is
usually a need to schedule tasks.
e.g patient monitoring: check heart every 5 secs, check emergency button,
check brain activity every 2 secs. C, C++, Java? , Ada
-
Networks: java, python, perl
-
Scripting: perl, python, vb... (glue)
-
Other: spreadsheets, SQL...
Possible Criteria for Choice
-
Inertia/experience in...
-
-
reliability - (buggy?)
-
tool support
-
facilities - fits problem?
-
libraries
-
'programming in the large' - e.g collections of clsses
-
..etc (there are many other criteria
Strong Typing
... in which a compiler makes strict checks on the use of types of data.
Some langs allow the programmer to specify data types precisely (though the programmer
may choose to avoid this!
This is often thought to be desirable: misuse of data
spotted before run-time.
Strong typing example - Ada
background: US - Dept of Defence
Consider 2 integers:
-
screenWidth (e.g in pixels)
-
age
Both ints, but same type?
n=screenWidth + age; //allowed to do this ????
In approx Ada:
// declare some types:
int ageType 0 to 150;
int pixelType 0 to 10000;
Now declare some variables:
ageType a1, a2;
pixelType width1, width2;
Now use them:
a1=24; //ok
a2=5000; //no
a2=20000; //no
a1=a1+3; //ok
width1=a1 //no - 27 fits, but types wrong!
Example - weak typing - C
int i,j;
char c; // holds a 1-byte char
i=300; //ok
c='A'; // set to 65 (ASCII code for letter A)
i=c*2; //ok - i is 130
you probably didn't mean to mix int and char - but it will run!
Summary
Java based on C, C++, but with stronger typing.
VB6 - weakly-typed - but not as weak as C.
BUT some scripting enthusiasts argue against strong typing!