Why not allow empty code blocks?

Steven D'Aprano steve+python at pearwood.info
Tue Aug 2 13:50:09 EDT 2016


On Tue, 2 Aug 2016 11:28 pm, Rustom Mody wrote:

>> I think the real reason is not willing to admit that the language lacks
>> something that could actually be useful, and especially not to an
>> upstart on usenet who is not even an expert in that language.
> 
> And earlier you said:
> 
>> But dedicated forms (even if they just map to 'while' or 'for') wouldn't
>> hurt. Syntax is free after all, and it's about expressing exactly what
>> you mean.
> 
> You are in effect repeating yourself
> What you are saying would be true if syntax were free — or even cheap
> 
> However a case may be made that syntax is one of the most wastefully
> expensive hobby with which computer scientists waste their time
> 
> First some…
> <background>
> Turing-completeness or Church-Turing thesis says that all languages are
> the same — identical power. 

That depends on how you define the power of a language.

Earlier, you wrote:

"Ok Python is better than Java is better than C++
But it cannot stand up to scheme as a teaching language"

So you are aware that languages are *not* the same. Languages have more or
less "power", where power is defined (rather fuzzily) as the expressiveness
of the language, how easy it is for the programmer to read, write and
maintain code, how efficient/fast you can implement it, etc. The power of a
language is rather subjective, but we all surely acknowledge that adding
new features to a language can make it more powerful:

- Python 1.5 is less powerful than Python 3.5;

- Fortran 77 is less powerful than Fortran 95.

We acknowledge that languages can differ in power too:

- 1970s BASIC is less powerful than C;

- COBOL is less powerful than Scheme.

Google for the Blub Paradox, by Paul Graham, for more information.

So language are not all the same, and can differ in power.

So what does the Church-Turing thesis say? It doesn't say anything about
language power in the above sense. Language power is a rather subjective,
fuzzy, non-linear measure, which is why language flame wars will never end.

What the C-T thesis talks about is *computability*. *What* can you compute,
not necessarily how easy it is to compute it. And there is a hierarchy of
language "power" in this sense.

(A Turing Machine can do anything that Conway's Game Of Life can do, but is
easier to program; assembly language is easier still, and Javascript even
more so.)

A good discussion of the Church-Turing thesis can be found in Chapter 13 of
Hofstadter's "Gödel, Escher, Bach". He introduces three languages that
differ in computing power in the computability sense: Bloop, Floop and
Gloop.

- Bloop can perform calculations that predictably terminate; that is, it 
  can do any calculation which can be performed by a primitive recursive
  function;

- Floop can perform calculations that have no upper bounds to the number
  of steps needed; that is, it can perform *unbounded* potentially
  non-terminating loops; another way of saying this is that terminating
  Floop programs are general recursive, and non-terminating Floop
  programs are partial recursive;

- Gloop can perform calculations which never terminate in Floop, and
  do so in a finite number of steps.

In simple terms, Bloop has for-loops; Floop has while-loops; and Gloop,
well, Gloop is magical and probably doesn't exist. "Gloop is a myth" is one
way of putting the Church-Turing Thesis.

Hofstadter gives three equivalent ways to state the C-T Thesis:

(1) What is human-computable is machine-computable;
(2) What is machine-computable is Floop-computable;
(3) What is human-computable is Floop-computable (i.e., general or 
    partial recursive).

Most interesting and useful languages are equivalent to Floop, but there are
languages (potential, if not actual) which are equivalent only to Bloop.
Pure regular expressions, for example, are not Turing Complete: they can
only perform calculations which are primitive recursive.

The Halting Problem is easily solved for Bloop languages: they always halt.


> And yet in the last ½ century of computers 
> there is as chaotic a babel of computer languages as there is of natural
> languages in the last 5000 years of human history.

I think that human languages have been *far* more complicated. The history
of English *alone* is probably as complex and chaotic as that of
programming languages. My guess is that once you go down to the level of
regional dialects, there are more variants of English alone than
programming languages have existed. In some sense, virtually every village
and hamlet in Great Britain has had its own version of English (and
sometimes not even mutually comprehensible).


> IOW that L₁ and L₂ are same in power means that the difference is entirely
> in syntax

But as we've seen, syntax can make a HUGE difference to power in the sense
of expressiveness, maintainability of code, readability, efficiency of the
programmer, and even efficiency of the interpreter. Conway's Game of Life
is Turing Complete. Would you rather use Python, or Game of Life? BrainF*ck
or Javascript?


[...]
> But do we really need Python and Perl and Ruby and Tcl and Pike and …?
> Or bash and zsh and ksh and powershell and …?

Yes.

Programming languages are tools for solving problems, but they are also
tools for thinking about problems and communicating between people. There
are many ways to think about problems, many ways to communicate between
them, and no clear or practical way to decide what is "best". That's why
language flame-wars occur!

With no objective way to decide which language to use, there will always be
people who are dissatisfied with the existing languages they have available
to them. Look at yourself: you are dissatisfied with Python's lack of
support for Unicode operators. But that's "just syntax". And yet you are
convinced that Python would be a better language if it supported more
mathematical notation with Unicode operators.

And perhaps you are right.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list