Re: Change JOIN tutorial to focus more on explicit joins

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jürgen Purtz <juergen(at)purtz(dot)de>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Thomas Kellerer <shammat(at)gmx(dot)net>, Pg Docs <pgsql-docs(at)lists(dot)postgresql(dot)org>
Subject: Re: Change JOIN tutorial to focus more on explicit joins
Date: 2020-10-23 09:23:04
Message-ID: CAFj8pRCY1fibh3E_vBdkQ__WfcRQ3pSjMoQy++PgXem2gpzHuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

pá 23. 10. 2020 v 11:14 odesílatel Jürgen Purtz <juergen(at)purtz(dot)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
>
>
>

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Jürgen Purtz 2020-10-23 13:58:46 Re: Additional Chapter for Tutorial
Previous Message Jürgen Purtz 2020-10-23 09:14:07 Re: Change JOIN tutorial to focus more on explicit joins

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2020-10-23 09:37:41 Re: partition routing layering in nodeModifyTable.c
Previous Message Jürgen Purtz 2020-10-23 09:14:07 Re: Change JOIN tutorial to focus more on explicit joins