# The overview of a programming environment

Date: 2020-06-09 06:21:37 +08:00Date modified: 2021-05-04 20:52:15 +08:00

The study of Computational processes start with the study of a programming environment. The programming environment is mostly a given in programming but let's inspect and state some things (and some are obvious) about it.

# The elements of programming

A programming language enables you to make the following:

- Expressions ranging from a primitive value to a complex type.

- A way to combine simple expressions into complex ones.

- A way to abstract procedures into higher-level processes.

# Expressions

Expressions may be of a primitive value (e.g., `265`, `-1.0`, `'string`) or combinations which are composed of operators and expressions (e.g., `(+ 2 6)`, `(* 6 3)`). An expression can also hold expressions referred to as a subexpression (e.g., `(+ (* 5 12) (- 54 6) 9)`).

# Namespacing and function composition

A programming environment should have a way to refer to computational objects. These often comes in the form of names with each referring to a value (e.g., `(define x 10)`).

A programming language should also provide the way to combine simple procedures to compound procedures (e.g., `(define (square x) (* x x))`) which can be referred to by name (e.g., `(square 10)` evaluates to `100`). With that said, we can then combine compound procedures to create a procedure of higher level (e.g., `(define (sum-of-squares x y) (+ (square x) (square y)))`).

# Conditionals

With expressions, environment, and function composition, we can create simple programs. However, we cannot create functions that may test for the value (e.g., piecewise functions). For this, a way to conditionally evaluate a value is a must for a programming language.

Here's an example function of getting the absolute value of a number.

    (define (abs x)
      (cond
       ((< x 0) (- x))
       (else x)))

# Evaluation model

Each interpreter implements a different way to evaluate expressions.

One of the simplest evaluation model is the substitution model . The substitution model works by knowing the meaning of each value and substituting the value with its equivalent.

# Related resources

- Structure and interpretation of computer programs, chapter 1