Go = Google Oberon ?

Dr Maurer of https://www.murus.eu/ announced he is rewriting parts of his Murus and jMurus software for the new Google language 'Go'. Now, ths means something. Dr Maurer is a real Modula-2 diehard. So if he changes over to 'Go' it must be something special.

So I paid some attention to 'Go' as well. When you look at some smaller sources you see a resemblance to Modula-2 and Oberon. Many 'Go' keywords are borrowed from Oberon and Modula. Also the syntax of 'Go' is based on Oberon. Even parts of the underlying thoughts are strongly influenced by the school of Niklaus Wirth. Still, when you go deeper into the 'Go' language, you soon find out that 'Go' is just another C compiler. Here https://golang.org/doc/go_tutorial.html you find the following piece of text:

This document is a tutorial introduction to the basics of the Go programming language, intended for programmers familiar with C or C++. It is not a comprehensive guide to the language; at the moment the document closest to that is the language specification. After you've read this tutorial, you should look at Effective Go, which digs deeper into how the language is used and talks about the style and idioms of programming in Go.

Note the piece in red. I hoped that fluency in Modula-2 and Oberon would also do when trying to read the 'Go' documents. But that was too much asked. The tutorial is only comprehensible when you are a C, C++ or Java programmer. It teaches them to use some kind of type casting. But 'Go' is too chaotic to be used as such by true followers of Professor Wirth. I guess Dr Maurer was spoiled a bit by his Java attempts and now embraces 'Go' because 'Go' is C-ish while still leaning somewhat against Modula-2.

An example

The Go tutorial starts with an example:

package main

import (
    "os"
    "flag"  // command line option parser
)
	
var omitNewline = flag.Bool("n", false, "don't print final newline")
	
const (
	Space = " "
	Newline = "\n"
)
		
func main() {
	flag.Parse()   // Scans the arg list and sets up flags
	var s string = ""
	for i := 0; i < flag.NArg(); i++ {
		if i > 0 {
			s += Space
		}
		s += flag.Arg(i)
	}
	if !*omitNewline {
		s += Newline
	}
	os.Stdout.WriteString(s)
}
   
Similarities with Oberon, for this small example: The rest is C or C-ish. Even the documentation is C-ish. Don't try to understand the tutorials when you are not fluent in C, C++ or Java. Even the EBNF definition of 'Go' is like C++. Much too complex and hence impossible to see through it. The 'Go' EBNF definition is the first EBNF I encountered that is harder to master than the language itself. Well done, Ken Thompson et al....

This quote is a nice one:

amd64 (a.k.a. x86-64); 6g,6l,6c,6a

The most mature implementation. The compiler has an effective optimizer (registerizer) and generates good code (although gccgo can do noticeably better sometimes).


It generates good code... Of course I tried to compile the Hello World example:
package main

import "fmt"

func main() {
    fmt.Println("Hello, world")
}
   
and it compiled to a lean executable of no more than 1 Megabyte. After stripping, only 750 Kb remained. Not bad for some good code. A comparable Mocka executable is something like 30 KB. And obc makes a very small executable file, of less than 4 kilobyte. So far for 'Go' I guess.

10 years later

My initial test with go was in 2011. It's 2020 now. SO it's 10 years ago, in base 9. The above source compiled to 1 MB of executable in 2011. The current Go compiler compiles to 28K. That's comparable to what Mocka does. Well done boys.

I wanted to give Go a new chance. Within 24 hours I was cured again. To start with, there are a lot of bad tutorials for Go. They all assume you are a C++ coder who wants to learn a better language. That part they succeeded. Any language is better than c++. I am not fluent in C++. I couldn't get a grip on any of there tutorials. The turorials were created to mimic C++ so there was no line of thought. No plan. Just separate chapters without any logicl buildup.

And then I found this: http://www.golangbootcamp.com/book/intro A truly good tutorial. They also jump from topic to topic sometimes but all in all it is understandable. You can use it to study Go, if you are desperate enough.

Why I don't want to use Go

First of: it's a mess. Go is even more of a mess than Python. Let's look at an example:

package main

import "fmt"

var	fac = 1

func main () {
  for i := 2; i < 12; i++ 
  {
     fac *=  i
     }
  fmt.Println (fac)
  }
   
Will it compile? Let's see:
jan@fluor:~/Langs/go/test$ go run f01.go
# command-line-arguments
./f01.go:8:27: error: missing ‘{’ after for clause
   for i := 2; i < 12; i++
                          ^
   
It doesn't. Why? Because Google decided to give you zero flexibility in writing your sourcecode. On the left is what I wrote, on the right is what Google demands:
   for i := 2; i < 12; i++		for i := 2; i < 12; i++  {
   {
   
The same goes for other places where a '{' is required such as in IF clauses. ZERO flexibility in making tour source more readable. It's either the GO way, or the HI way. Go is a DDR compiler.

Sometimes you type one letter wrong and you get 40 lines of error messages, plus the "# command-line-arguments" which we also have here. I did not supply a command line argument. The program doesn't expect arguments. I did not check on arguments. And still Go blames me for a command tail.

The way in which vars are declared. Too much carelessness. Too chaotic. The ':=' operator that allows declaring a variable without typing the word 'var'. As if that makes all the difference. The return statement that automatically deduces which variable should be returned to the caller. The ommission of all looping constructs, but allowing too many options for the FOR loop, in order to make the omitted WHILE, REPEAT and LOOP control structures still possible. Allowing assignment operations inside an IF statement. Local variables inside control structures.

Excessive ornamentation is what described C++ and it also describes GO. When professor Wirth developed Modula-2 into Oberon, one of the first things to remove were local modules. GO re-invented the local modules. In fact, GO resembles Oberon quite a lot. If you see how Stroustrup went from C to C++ he just invented 'Modula-2 for C'. But for marketing reasons he did not develop a new syntax; he borrowed the C syntax. And he did not make a new name. He just named it C++ so all mediocre C coders just knew they needed the 'C superset'. Ritchie was not too pleased about this. Stroustrup just stole Ritchie's compiler.
And now Google did something similar, although they did not rob the C syntax. Google created "Oberon for C". And of course the three developers named every single programming language they could listas a source of their influence, except for Oberon, to prevent people from seeing the more than accidental similarities. In a recent Oberon, Wirth removed the LOOP EXIT END structure since LOOP/END is an infinite loop and most LOOP/ENDs can be rewritten using either a REPEAT or a WHILE statement. They copied even that!

Page created on 4 August 2011 and