Oberon and language design

This paper by Niklaus Wirth describes the evolution of Modula-2 into Oberon. The whole paper is interesting, but I found this paragraph to be the most poignant:

My long term goal had been to demonstrate that a systematic design using a supportive language leads to lean, efficient, and economic software, requiring a fraction of the resources that is usually claimed. This goal has been reached successfully. I firmly believe, out of many experiences over many years, that a structured language is instrumental in achieving a structured design. In addition, it was demonstrated that a clean, compact design of an entire software system can be described and explained in a single book. The entire Oberon System, including its compiler, text editor and window system occupied less than 200K bytes of main memory, and compiled itself in less than 40 seconds on a computer with a clock frequency of 25 MHz. In the current year 2007, however, such figures seem to have little significance. When the capacity of main memory is measured in hundreds of megabytes, and disk space is available in dozens of gigabytes, 200K bytes do not count. When clock frequencies are of the order of gigahertz, the speed of compilation is irrelevant. Or, expressed the other way round, in order that a computer user will recognize a process as being slow, the software must indeed be lousy. The incredible advances in hardware technology have exerted a profound influence on software development. Whereas they allowed systems to reach phenomenal performance, their influence on the discipline of programming have been rather detrimental as a whole. They have permitted software quality and performance to drop disastrously, because poor performance could easily be hidden behind faster hardware. In teaching, the notions of economizing memory space and processor cycles have become a thing apart. In fact, programming is hardly considered as a serious topic; it can be learnt by osmosis or, worse, by relying on extant program “libraries”.

This stands in stark contrast to the times of ALGOL and FORTRAN. Languages were to be precisely defined, their unambiguity to be proven; they were to be the foundation of a logical, consistent framework for proving programs correct, and not only syntactically well-formed. Such an ambitious goal can be reached, only if the framework is sufficiently small and simple. By contrast, modern languages are constantly growing. Their size and complexity is simply beyond anything that might serve as a logical foundation. In fact, they elude human grasp. Manuals have reached dimensions that effectively discourage any search for enlightenment. As a consequence, programming is not learnt from rules and logical derivations, but rather by trial and error. The glory of interactivity helps.

The world at large seems to tolerate this development. Given the staggering hardware power, one can usually afford to be wasteful in space and time. The boundaries will be hit in other dimensions: usability and reliability. The enormity of current commercial systems limits understanding and fosters mistakes, leading to product unreliability.

Comments

Modula-3 tips and tricks

I love playing with programming languages, especially the more obscure ones.  I decided to try out Modula-3 after learning a little about it.

Modula-3 is an upgraded Modula-2. It’s syntax is somewhat the same as Modula-2, but Modula-3 includes a number of nice features, the nicest from my point of view being Garbage Collection.

Unfortunately, a lot of information about Modula-3 is on dead links. One very good resource however is modula3.org.

I decided to really try the language, so I searched around and found out that Critical Mass Modula-3 is the most popular (and still actively developed) Modula-3 implementation. A very good installation guide for Debian/Ubuntu is available at http://opencm3.net/install-cm3-on-ubuntu-7-10.html.

Also, if you’re curious, you can still grab the original SRC Modula-3 source from here.

Comments

F# subreddit

I created an F# subreddit for F# news/links.

I find Reddit’s programming subreddit to be lacking recently, mostly because it seems ALL submissions get downvoted to 0 initially by bots and then only a few articles make it out of the hole. I’m not sure if this is just the current state of the programming subreddit or if it has something to do with the recent explosion of subreddits since they unlocked the ability to create your own.

Comments

Zeepf, a new metasyntatic variable.

You’ve most likely seen the words “Foo” and “Bar” used in nonsensical ways (e.g. as a silly variable, or a nonsense word). Both foo and bar belong to a bigger list of what is known as Metasyntatic Variables.

The list consists of the words “foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy and thud”. Most of these metasyntatic variables originated from MIT, and others are from Stanford, CMU, Berkeley, and other universities. (For a more detailed history, see RFC 3092)

Guy L. Steele Jr., noted computer scientist and writer of many language specifications, is also known as “The Great Quux”, an obvious reference to metasyntatic variables.

In Steele’s latest language specification for Fortress, a new metasyntatic variable popped up, “Zeepf”. Googling for “zeepf” returns only references to Fortress source code, where it is used along with the more standard foo and bar.

I wonder what the origins of this new variable are, and for how long it has been used?

Comments

Amarok Now Playing in Psi with PEP

I found this script a while back to display what music Amarok was playing in Psi (You need Psi version 0.11 or later to support the PEP stuff).

EDIT: See the comments for Caustiq’s proper package for Amarok!

EDIT2: See the comments for Jean-Marc Liotier’s updated package that’s (almost) compliant with XEP-0118!

The script, however, didn’t differentiate between streams and MP3s. Caustiq and I modified it to display differently if you are listening to a stream or an MP3.

# Authors: Silian Della Ragione
#          Andres Gomez Garcia <agomez@igalia.com>
#          Antoine <Alan71> Gassot <antoine_dot_gassot_at_gmail_dot_com>
#          Modification by 'Albert'
#          (04/02/08) Modified to fix stream/mp3 tune strings by mbishop <mbishop@esoteriq.org>
# Version: 0.0.3
# License GNU/GPL
############################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
#########################################################################

#!/bin/bash

change () {
    title=`dcop amarok player title`
    artist=`dcop amarok player artist`
    album=`dcop amarok player album`
    track=`dcop amarok player track`
    time=`dcop amarok player totalTime`
    type=`dcop amarok player type`

    if [ "$type" = "Stream" ];
      then tune="${title} - ${album}"
      else tune="${artist} - ${title} - ${album} - ${time}"
    fi

    echo ${tune} > ~/.psi/tune
}

stop () {
    rm ~/.psi/tune
}

terminate () {
    stop
    exit 0
}

trap terminate 0 1 2 5 15

while [ 1 ]
do
    read input
    input=$(echo $input | sed -e 's/engineStateChange:\ //')
    case "$input" in
    "playing" | "trackChange" )
        change
        ;;
    "paused" | "empty" | "idle" )
        stop
        ;;
    esac
done

Comments (8)

Fibonacci numbers in F#

I typically write a few simple programs in any new language. I mostly write the standard ones: factorial, a guessing game, fibonacci numbers, etc.

Here I have my F# code for Fibonacci numbers. I also write (when it’s applicable) an arbitrary precision version, to print out integers larger than those that can be stored in a regular integer type.

#light

let fib n =
    let rec fib_aux (n, a, b) =
        match (n, a, b) with
          | (0, a, b) -> a
          | _ -> fib_aux (n - 1, a + b, a)
    fib_aux (n, 0, 1)

This Fibonacci code is properly tail recursive, and uses a helper function.

However, it will overflow and return negative numbers after a certain point.

> fib 20;;
val it : int = 6765
> fib 200;;
val it : int = -552082539

We can get arbitrary precision using BigInts. In F#, this is done very easily (we don’t even have to open Math.BigInt!).

let big_fib n =
    let rec big_fib_aux (n, a, b) =
        match (n, a, b) with
          | (0, a, b) -> a
          | _ -> big_fib_aux (n - 1, a + b, a)
    big_fib_aux (n, 0I, 1I)

Notice how all we need to do is use the “I” literal in the tail call for the numbers in the tuple.

> big_fib 20;;
val it : bigint = 6765I
> big_fib 200;;
val it : bigint = 280571172992510140037611932413038677189525I

Comments

F# is neat!

I’ve always liked Ocaml, but recently I started looking into F#. It seemed neat, and even worked on Mono when I tried it out last year. Now that my desktop system runs Windows (my laptop still runs Linux, thankfully) I wanted to use F# in it’s natural habitat, so I installed Visual Studio 2008 Shell.

VS 2008 Shell is a “bare bones” version of Visual Studio. It doesn’t have C# or any other language support, but it does allow you to use “plug ins”, which is what F# does. After you install VS 2008 Shell, you need to install F# (the latest as of this writing is 1.9.3.14). After that, create an F# project and you’re on your way.

Here are some helpful links involving F#:

Comments

Just a note…

If you came to my site looking for the PDF of “All About Monads”, I no longer have it up, but there is an HTML (and more up to date) version at haskell.org.

Comments

Cheb i Sabbah

Last week I bought DJ Cheb i Sabbah’s latest album Devotion. It’s a fantastic album. A great blend of eastern and modern music, with some really nice beats.  Highly recommended!

Comments

Weblogs, oh my!

So I just installed Wordpress on my dreamhost account. Huzzah!

Comments