Programming Languages - Concepts

Last Updated: 2023-02-23

Standard vs. Implementation

  • Standard is the language specification, listing all the definitions and features of the language, however nothing "physical".
  • Implementation is the actual engine that can execute the code that comply with the spec.


  • Java:
  • JavaScript/ECMAScript:
    • one specification: ECMA-262
    • JavaScript, JScript and ActionScript are all implementations of ECMA-262 standard. The implementations are compatible with ECMAScript though may also provide additional features.
  • SQL
    • Standards like SQL-92, SQL-2011, etc.
    • Databases usually implement only a portion of the standards, plus some custom features. So one SQL query from a certain database may or may not work in another database.

Imperative vs Functional

  • In a imperative program: a function depends on two things
    • the parameters it is passed and also
    • the current state of the machine store.
  • In a functional language:
    • only the parameters it is passed matters.

Dynamic Type vs Static Type

Dynamically typed language means that variables do not have types, only values do. There are no type definitions in the language. All values carry their own type.

Rust goes a middle way: It’s a static type system, but it only requires the programmer to specify top-level types like function arguments and constants. Inside function bodies, Python-style type inference is allowed.

Dynamically Linked vs Statically Linked

  • static: link at compile time
  • dynamic: link at runtime

Some languages use both: static linking to deploy, dynamic linking to iterate

Statically Declared Array vs Dynamically Declared Array

  • static: allocates memory at compile-time, size is fixed, in stack, no need to manage memory
  • dynamic: can alter the size at run time, in heap, need to allocate and free memory
int* a = new int[10];
delete[] a;

Alternatively std::vector can be used, which resizes itself automatically

std::vector<int> v = {1, 2, 3, 4}

Lexical Scope vs Dynamic Scope

  • Lexical scope: a.k.a static scope.
    • A variable may be referenced from within the block of code in which it is defined.
    • Determined at the compile time, "early binding",
    • "The name resolution depends on the location in the source code and the lexical context, which is defined by where the named variable or function is defined."
    • Examples: most modern languages use lexical scope for variables and functions.
  • Dyanmic Scope:
    • uses the location of the function's invocation to determine which variables are available.
    • Determined at the run time, "late binding".
    • "The name resolution depends upon the program state when the name is encountered which is determined by the execution context."
    • Examples: Perl (originally with dynamic scope only, later supports both), LISP, shell languages like bash and PowerShell.

System Programming Languages


A system programming language usually refers to a programming language used for system programming; such languages are designed for writing system software, which usually requires different development approaches when compared with application software. System software is computer software designed to operate and control the computer hardware, and to provide a platform for running application software.


  • Immutable: cannot be changed once created
  • Mutable: can be changed

Java: String and all of the number classes, such as Integer, Double, Character, and BigInteger.

Stack vs Heap

  • Stack: primitive values, references to objects, and methods; short-lived. LIFO. Whenever a method is invoked, a new block is created in the stack memory for the method to hold local primitive values and reference to the other objects.
  • Heap: object created by new; array is also object, so also in heap.
    • Young gen
    • Old gen
    • PermGen(replaced by Metaspace, which uses native memory, in Java 8)
  • use -Xmx, -Xms to specify the size of Heap
  • use -Xss to specify the size of stack

Recursive methods usually use much more stack space, and therefore more memory, than an iterative counterpart.


  • RMI is a Java-specific technology. CORBA has implementations for many languages. You can use CORBA to share objects between programs written in different languages (e.g. C++ and Java).
  • CORBA uses IDL (Interface Definition Language) to separate interface from implementation. RMI just uses Java interfaces.

PPL: Probabilistic Programming Language


4th Generation Programming Language


Char in Programming Language

  • Java: 2 bytes, 16 bits, unsigned([0, 65535]), unicode(UTF-16)
  • C/C++: 1 byte, 8 bits, ASCII

Domain-Specific Language (DSL)

Different from a General-Purpose Language (GPL), a DSL is for a specific problem. For example, CSS is just for styling web elements, SQL is for database queries, make for building programs.

Ruby, Scala, Groovy are especially good for building DSLs. E.g. Gremlin is a graph traversal language written in the Groovy.

Weak Reference

Weak reference is a reference that does not protect the referenced object from collection by a garbage collector, the object will be garbage collected once they are not reachable elsewhere, even though this weak reference is still pointing to it.

Some garbage-collected languages support weak references, like Java (WeakReference class), C#, Python (weakref module), etc.


  • Java LinkedHashMap = python collections.OrderedDict: remembers the order that keys were first inserted
  • Java TreeMap: red-black tree based, sorted by the keys, log(n) for all actions; no python equivalent


High-performance computing (HPC) frameworks, such as OpenMP and OpenACC: provide application program interfaces (APIs) that programmers can use to express parallelism in code.

Type Introspection and Reflection

  • Type Introspection: the ability of a program to examine the type or properties of an object. C++ is not capable of introspection at runtime, only compile-time.
  • Reflection: the ability of a process to examine, introspect, and modify its own structure and behavior.

Type Casting vs Type Conversion

Trivially destructible

Informally this means that the destructor does not do anything, even taking member and base destructors into account. More formally it means that the type has no user-defined or virtual destructor and that all bases and non-static members are trivially destructible.


A pointer is an object that stores a memory address.

Smart pointers are data structures that have additional metadata and functionalities.

Foreign function interface (FFI)

A program written in one programming language can call routines or make use of services written in another.

In Java, it is called JNI (Java Native Interface) or JNA (Java Native Access).

Java foreign function: