The Department of Computer Science & Engineering
 STUART C. SHAPIRO: CSE 305

# Preliminaries

In class survey: What programming languages do you know? Compare the TIOBE Index, and the CSE list of available programming languages.

Course Objectives
• You will understand the various components of programming languages, and the available design choices.
• You will expand your notions of how procedures may be expressed.
• You will increase your programming abilities.
• You will be able to learn new programming languages easily.
• You will be able to participate in the design of new programming languages.

Basic Concepts
• The computer as a linear array of addressable sets of binary switches
Like other machines: set the switches; turn it on; it does something.
A group of bits can represent an: integer, real, character, truth value, etc. It's all in the interpretation.

• The von Neumann architecture (equivalence of data and program)
Programs can be treated as data. Some data can be stored or modified, and then executed as program.
Enables high-level programming languages.

• Compilation, Interpretation, and Hybrid (Compilation & Interpretation)

• What's a programming language anyway?
• A well-defined language,
• for which there exists an interpreter or compiler (or hybrid) for at least one computer,
• that has a means for specifying input,
• and a means for specifying output,
• and at least one basic operation on data,
• and a means for specifying the performance of a sequence of operations,
• and a means for specifying the conditional performance of one or another operation,
• and a means for specifying the repetitive performance of an operation.

Key Distinctions
• Standards vs. Manuals
Language standards are written for implementors. They say what different operations must do, but may also explicitly state that some operation is undefined in some way. For example,
"6.3.1.4 Real floating and integer
1. When a finite value of real floating type is converted to integer type other than `_Bool`, the fractional part is discarded (i.e., the value is truncated toward zero). If the value of the integral part cannot be represented by the integer type, the behavior is undefined."
[ISO C Standard ISO/IEC 9899:TC2, May 6, 2005, p. 43.]

Manual are written for programmers. They should specify all the operations, but some specifications may be implementation-dependent.

Testing can show you what one version of one compiler does.

For portable code, refer to the standard.

• Space vs. Time
For example, what is the order of the statements at and around statement `A` in the below C program?
```#include <stdio.h>

void sub()
{
int x = 2;
printf("In sub, x = %d\n", x);
}

int main()
{
int x = 1;
printf("In main, x = %d\n", x);
A: sub();
printf("In main, x = %d\n", x);
return 0;
}```

• Compile time vs. Run time
For example, when is `x` given the value `1` in the above C program?

Overview of Language Categories
There are several categories of programming languages, including: imperative, functional, logic, relational, procedural, object-oriented, expression-oriented, and scripting. Most currently used languages are not purely any one of these.

This course will not be structured by these categories, but by PL components that all, or most, PLs have.