Re: Change JOIN tutorial to focus more on explicit joins - Mailing list pgsql-docs

From Pavel Stehule
Subject Re: Change JOIN tutorial to focus more on explicit joins
Date
Msg-id CAFj8pRCY1fibh3E_vBdkQ__WfcRQ3pSjMoQy++PgXem2gpzHuw@mail.gmail.com
Whole thread Raw
In response to Re: Change JOIN tutorial to focus more on explicit joins  (Jürgen Purtz <juergen@purtz.de>)
List pgsql-docs


pá 23. 10. 2020 v 11:14 odesílatel Jürgen Purtz <juergen@purtz.de> napsal:
On 22.10.20 17:14, Pavel Stehule wrote:
>
> Why do you use parenthesis for ON clause?  It is useless. SQL is not C
> or JAVA.


Two more general answers:
- Why do people use tabs, spaces, and newlines to format their code even
though it's not necessary? SQL is a language to develop applications.
And what are the main costs of an application? It's not the time which
it takes to develop them. It's the time for their maintenance. During
the course of one or more decades, different persons will have to read
the code, add additional features, and fix bugs. They need some time to
read and understand the existing code. This task can be accelerated if
the code is easy to read. Therefore, it's a good habit of developers to
sometimes spend some extra characters to the code than is required - 
not only comments. An example: there are clear precedence rules for
Boolean operators NOT/AND/OR. In an extensive statement it may be
helpful - for the developer himself as well as for anybody else -to use
newlines and parentheses at places where they are not necessary to keep
an overview of the intention of the statement. In such cases,
code-optimization is the duty of the compiler, not of the developer.
- In my professional life as a software developer, I have seen about 15
different languages. But only in rare cases, they have offered new
features or concepts. To overcome this Babylonian linguistic diversity I
tend to use such syntactical constructs which are common to many of them
even, even if they are not necessary for the concrete language.

And the concrete answer: Omitting the parentheses for the join condition
raises the danger that its Boolean operators are mixed with the Boolean
operators of the WHERE condition. The result at runtime is the same, but
a reader will understand the intention of the statement faster if the
parentheses exists.

I strongly disagree.

If there are some boolean predicates, then parenthesis has sense. Without these predicates the parenthesis decrease readability. This is the sense of JOIN syntax to separate predicates.

I have a different problem - when I see parentheses where they should not be, I am searching for a reason, and It is unfriendly where there is not any reason. I can understand if somebody uses useless parentheses in their product, but we talk about official documentation, and then we should respect the character of language. 

Regards

Pavel



--

J. Purtz


pgsql-docs by date:

Previous
From: Jürgen Purtz
Date:
Subject: Re: Change JOIN tutorial to focus more on explicit joins
Next
From: Jürgen Purtz
Date:
Subject: Re: Additional Chapter for Tutorial