Programming language Choice

Areas of Use

Possible Criteria for Choice

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:

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!