Posts

From Oberon to Go: A Short Family Tree

A compact overview of the Oberon family of languages and how their ideas lead to Go. The lineage runs from Pascal and Modula-2 through Oberon and its variants to Go, with shared emphasis on simplicity, strong typing, and clear semantics.

Oberon (1986) — Niklaus Wirth & Jurg Gutknecht

  • Evolved from Pascal and Modula-2; designed for simplicity and efficiency.
  • Strong typing, modular programming, integrated development environment.
  • Used in software and hardware (e.g. Ceres workstation); part of Project Oberon at ETH Zurich.

Oberon-2 (1991) — Hanspeter Mössenböck

  • Extension of Oberon with object-oriented features.
  • Type-bound procedures, read-only export of variables and methods.
  • Improved type safety and reusability.

Modula-3 (1988) — Luca Cardelli, James Donahue, Greg Nelson, Paul Rovner, Andrew Birrell

  • Evolution of Modula-2: simplicity, safety, systems programming.
  • Garbage collection, exception handling, strong type system with modules.
  • Concurrency and generic programming.

Active Oberon (1997) — Jurg Gutknecht

  • Extends Oberon with active objects and concurrency.
  • Combines object-oriented and system-programming features.
  • Runtime and language support for concurrent processes.

Zonnon (2005) — Jurg Gutknecht

  • Draws on Oberon, Active Oberon, and Modula-2.
  • Component-oriented programming, concurrency and parallelism.
  • Refined syntax and semantics.

Oberon-07 (2007) — Niklaus Wirth

  • Simplified, modernized Oberon.
  • Removed deprecated features; clearer syntax and safer semantics.
  • Streamlined compiler and language report.

Component Pascal (1997)

  • Clemens Szyperski: Component Pascal at Oberon Microsystems (1991–1997); component-based software; author of Component Software: Beyond Object-Oriented Programming.
  • K. John Gough: Co-developed Gardens Point Component Pascal for .NET.

Derived from Oberon-2 with stronger object-oriented and component-oriented features; designed for component-based software engineering and .NET integration (Gardens Point).

Solving a Three-Variable Recursion via Generating Functions

This post extends the generating-function technique from the two-variable recursion to a three-variable case. I originally wrote this as an answer to a Math Stack Exchange question; here it is adapted for the blog with clearer exposition and code.

The Problem

We want to solve the recurrence

$a_{n,m,k} = 2a_{n-1,m-1,k-1} + a_{n-1,m-1,k}$ $ + a_{n,m-1,k-1} + a_{n-1,m,k-1}$

where $m$, $n$, $k$ are nonnegative integers, with boundary conditions:

  • $a_{0,0,0} = a_{0,1,0} = a_{1,0,0} = a_{0,0,1} = 1$
  • $a_{n,0,0} = a_{0,n,0} = a_{0,0,n} = 0$ for any $n > 1$
  • $a_{n,m,k}$ is symmetric in $n$, $m$, $k$

A subtlety: $a_{1,0,1}$ is not defined by the recurrence alone, since it would require values like $a_{0,-1,0}$. We take $a_{n,m,k} = 0$ whenever any subscript is negative.

Binomial Coefficients Modulo a Prime: Fermat's Theorem and the Non-Adjacent Selection Problem

In the previous post, we implemented the closed form $F_{n,m} = \binom{n-m+1}{m}$ using Python’s math.factorial, and with scipy and sympy. Here we cover the common competitive-programming case: computing the answer modulo a large prime $M$ (e.g. $M = 10^9+7$).

Why modulo?

In counting problems, the result can be huge even for moderate input. Often the problem asks for the answer modulo a big prime so that it fits in a standard integer type. We could compute the full number and then take the remainder, but that forces expensive long-integer arithmetic. Computing everything modulo $M$ from the start is much faster.

Efficient Implementation of the Non-Adjacent Selection Formula

In the previous post, we derived the closed form for the non-adjacent selection problem:

$$ F_{n, m} = {n - m + 1 \choose m} $$

Now we discuss how to implement this efficiently in Python—from a simple factorial-based solution to library implementations. For the common case of computing the answer modulo a large prime (e.g. in competitive programming), see the next post.

Fast Solutions Based on Binomials

We can reflect the closed form in very trivial Python code:

Cracking Multivariate Recursive Equations Using Generating Functions

In this post, we return back to the combinatorial problem discussed in Introduction to Dynamic Programming and Memoization post. We will show that generating functions may work great not only for single variable case (see The Art of Generating Functions), but also could be very useful for hacking two-variable relations (and of course, in general for multivariate case too).

For making the post self-contained, we repeat the problem definition here.

The Problem

Compute the number of ways to choose $m$ elements from $n$ elements such that selected elements in one combination are not adjacent.

The Art of Generating Functions

The notion of generating functions and its application to solving recursive equations are very well-known. For reader who did not have a chance to get familiar with the topics, I recommend to take a look at very good book: Concrete Mathematics: A Foundation for Computer Science, by Ronald L. Graham, Donald E. Knuth, Oren Patashnik.

Generating functions are usually applied to single variable recursive equations. But actually, the technique may be extended to multivariate recursive equations, or even to a system of recursive equations. Readers who are familiar with one-variable case, may jump directly to the next post: Cracking Multivariate Recursive Equations Using Generating Functions.