Why do some languages disrupt some common and habitual conventions?

Periklis Gkolias on October 05, 2018

I am diving into Golang, those days. I have noticed that the syntax is most of the times against the "common sense". For example, this how they... [Read Full]
markdown guide
 

The long & short of it is that the creators decided that these idioms convey the concepts the language uses better. I'm not familiar with Go's type system but [5]string seems to imply that something is an array first and a container for strings second; someone who knows the language may be able to elaborate why that distinction is useful. Type on the right can be found everywhere from BASIC to Scala so as far as I know that's simply a case of drawing from conventions you're not familiar with.

 

There's an explanation in the official Go blog - blog.golang.org/gos-declaration-sy.... Basically they chose that syntax because it's easier to read.

var books [5]string

reads as "declaring a var named books as an array of 5 strings"

 
 

First of all, I think you are only familiar with only a few of programming languages and paradigms, there are other types of languages beside c-style.

Go will feel familiar in some places, and very strange in others. This happens because it is the only language (I know) that unifies the two branches of languages that started from Algol (Pascal and C). Steve Garcia explains it better than I could ever do:

 

Yeah, I am mostly familiar with C-style languages, so this makes sense

 

"Common and habitual conventions" are defined by whoever uses that term. Rob Pike, one of Go's designers, spent some time with Smalltalk and similar languages, Go even adds a couple of features from C's predecessors BCPL and B.

 

Here's a good video that touches on some of this if I recall correctly. (Good talk on language design either way, I forget some of the details)

 
 

Just wait till you start touching any kind of lisp. You'll basically hate all syntax from then on.

code of conduct - report abuse