wiki:Fundamentals

Fundamental concepts and notions

To understand programming really, we have to understand hows and whys. For that we need to understand a few fundamental concepts and notions and the first principles which form the foundation of any programming language.

The most important fundamental principle is that we should use a reduction process which tries to converge to a closest possible approximation to a global optimum (even unattainable) in each aspect (dimension), to obtain smallest possible good-enough set of complementing each other features.

The second fundamental principle is that at a higher level of abstraction (an upper layer) the expressive power of a language is fundamentally different from mere composition of the basic building blocks (think of proteins made out of amino-acids, which are made out of atoms according to a templates encoded in DNA, which is made out of nucleotides, which itself are molecules made out of atoms).

Layers upon layers of domain-specific languages, in which there is no fundamental difference between code and data - this is where the inspirations and insights behind Scheme and Common Lisp, presumably came from.

The Principles

  • Everything is an expression.
  • Every expression evaluates to a value.
  • Equivalent value could be substituted for equivalent (the Substitution Model).
  • Some expressions are self-evaluating (they represent a value itself "in-place").
  • Each value has a type (a tag or a reference).
  • No implicit conversion between the types (only explicit coercion).
  • Values could be associated to symbols (which is called a binding).
  • There are no box-like variables, only bindings (to values which has types).
  • Multiple symbols cold be bound to the same value (synonyms, aliases).
  • Every value must be a first class entity.
  • A closure is a block of code to be called later (a Callable).
  • Closures are first class "values" (could be bound to symbols).
  • Every closure has its own type associated with it (a type-signature).
  • A defined value cannot be changed (a new value should be created instead).
  • Once bound, symbols cannot be re-bound (referential transparency).
  • Bindings could be grouped into a structure (each binding is called a slot).
  • Every structure is a first class value (it is an expression, like a closure).
  • Every structure is of its own type (Abstract Data Type).
  • A structure could contain any value in a slot (including a closure).
  • A structure is defined by its "template" (which is an expression).
  • Instances are values from evaluating constructor expressions.
  • An Abstract Data Type is defined by a set of possible operations (an interface).
  • An interface is a named set of procedures (declared as a type).
  • Objects which implement the same interface could be substituted (duck-typing).
  • Optional Maybe - an either-of-type (a value or NIL) is just an ADT.
  • Monad is just an Abstract Data Type (with constructor and selectors).
  • A protocol is an interface with a set of explicit rules (constraints).
  • Protocol is a named type. Objects which implement it belongs to the type (duck-typing).
  • A structured value could belong to more than one type (implement more than one interface).
  • Classes are mere structures - "templates" for object instances.
  • With a protocol which defines inheritance.
  • And a protocol to resolve the calls to the code slots (methods).

Expressions and Values

Bindings, References

Bindings

Blocks, Lambdas, Closures

Closures

Types of values, Strong typing

Structures, Slots

Data Structures

Pattern Matching

Pattern Matching

Modules, Packages

Classes and Objects

Classes are templates for objects, similarly to how a definition of a structure is a template for its instances.

Last modified 4 years ago Last modified on Nov 8, 2016, 7:20:42 PM
Note: See TracWiki for help on using the wiki.