New to Python - block grouping (spaces)

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Apr 19 13:46:31 EDT 2015


On Sun, 19 Apr 2015 09:38 pm, BartC wrote:

> (I think much of the problem that most languages are intimately
> associated with their specific syntax, so that people can't see past it
> to what the code is actually saying. a=b, a:=b, b=>a, (setf a b),
> whatever the syntax is, who cares? We just want to do an assignment!)

You are making the mistake of thinking that we write code for the benefit of
the compiler or interpreter. We don't. If we did that, we'd all be using
machine code, programming in hex.

Source code exists to be read by human beings. If you want to communicate
with other human beings, you have to agree on a common language.

You might be interested in the Coffeescript model. You write Coffeescript
code, which is then translated (compiled? transpiled?) into pure
Javascript, which can then be run in the Javascript engine of your choice.
That's a language design model which is proven to work, unlike the idea of
having configurable syntax.

You'll notice that Coffeescript isn't a mere preprocessor or source code
transformation. The code is compiled into a different language, which may
not be reversible, and different compilers may generate different
(better/worse) code.

The Coffeescript:

    eat food for food in ['toast', 'cheese', 'wine']


compiles to Javascript:

    var food, j, len, ref;

    ref = ['toast', 'cheese', 'wine'];
    for (j = 0, len = ref.length; j < len; j++) {
      food = ref[j];
      eat(food);
    }




-- 
Steven




More information about the Python-list mailing list