Programming Languages - Concepts

Updated: 2020-12-31


A script is program code that doesn’t need pre-processing (e.g. compiling) before being run.

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.

Package Managers

  • Java/Scala: Maven Central
  • Python: Python Package Index
  • Node.js: npm(Node Package Manager)
  • Ruby: RubyGems.
  • Perl: Comprehensive Perl Archive Network (CPAN)
  • R: Comprehensive R Archive Network (CRAN).

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.

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, e.g.

  • clang for testing (quick to compile, slower to run)
  • cpp for deploy (slow to compile, quick to run)

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}

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.

Virtual Machines

  • JVM (Java Virtual Machine): Java, Scala, Groovy, Kotlin

    • Why Groovy is more Popular than Scala: Groovy is 100% Java compatible because it IS Java; take any Java class, change the extension to from '.java' to '.groovy' and it WILL compile (NOTE: one must have groovy library installed).
  • CLR (Common Language Runtime): C#
  • HHVM (HipHop Virtual Machine): PHP/Hack. HHVM JIT compilation, executed PHP or Hack code is first transformed into intermediate HipHop bytecode (HHBC), which is then dynamically translated into x86-64 machine code, optimized, and natively executed. This contrasts with PHP's usual interpreted execution, in which the Zend Engine transforms PHP source code into opcodes that serve as a form of bytecode, and executes the opcodes directly on the Zend Engine's virtual CPU.


  • Clang: frontend for C/C++/Object-C/Object-C++
  • LLVM: the backend and the umbrella project name. Backend converts the LLVM Intermediate Representation (IR) to code for a specified machine or other languages (hardware OR software target)


  • static compiler, or ahead-of-time(AOT) compiler: at compile-time, e.g. from .java to bytecode .class
  • dynamic compiler, or just-in-time(JIT) compiler: at run-time, e.g. in Java, compiles bytecode to native instructions

bytecode is portable, but native code is not.

Java JIT 2 flavors:

  • client-side compiler(with -client option): fewer resources, sensitive to startup time
  • server-side compiler(with -server option): long running, more advanced optimizations.

Besides Java, PyPy provides JIT for Python, V8 compiles javascript directly to native machine code.


  • 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.

Compiled vs Scripts

  • compiled to standalone executables: C/C++, COBOL
  • ran in an interpreter: Perl, Tcl
  • Java need for both a bytecode compiler and a runtime interpreter.
  • Python and R have no compile-time type-safety,
  • Compiled-to-JavaScript language: dart, typescript, flow

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.

libc++ vs libstdc++

  • libc++: sourced from LLVM (preferred)
  • libstdc++: sourced from GNU

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