Languages

Concepts

Updated at: 25 Sep 2019 03:39:46

Motivations of PLs

  1. Novel ways of expressing computation

  2. Better execution model

  3. Better reliability

General notes:

  1. With laziness infinite functions can be created

  2. Algebraic data types ?

Types

Sum and Product Types

Product Types: Combine multiple types using an “and”

Sum Types: Combined multiple types using an “or”

Use of product types is similar to the use of strcuts. But the use of product types leads to a strong top-down design pattern.

Sum types allow similarity between types without the same bloated code.

In Haskell, Product types include tuples and records. Sum types includes ordinals and general data types.

Strong and weak typing

Actually typically relates to type safety, memory safety.

Most languages are strongly typed (even Python with duck typing)

Strongly typed languages has stricter rules during compile time, while implies that errors and exceptions are likely to happen during compilation.

Weakly typed languages might expose pointers and allow operations on them. Weakly typed langauges allow for type coercion.