On Mon, May 5, 2014 at 1:36 PM, Stephan Beal <sgb...@googlemail.com> wrote:

> On Mon, May 5, 2014 at 7:31 PM, Petite Abeille <petite.abei...@gmail.com
> >wrote:
>
> > On May 5, 2014, at 7:15 PM, Stephan Beal <sgb...@googlemail.com> wrote:
> > > Why expect an error? It's abstractly the same as saying WHERE 'a' =
> 'b’,
> >
> > I mean ‘where 1’, or ‘where ‘1 - 1’, or ‘where null’, or ‘where 0 / 0’,
> or
> > any of this nonsense. There is nothing to compare. It’s nonsensical.
> >
>
> Oh, but there is: 1-1 is an expression, the result of which is integer 0
> (as opposed to string '0'), which, in all programming environments except,
> IIRC, Xenix, is boolean false.
>

Petite's complaint is that in most other SQL database engines, 0 is not
false.  If you try to use 0 where a boolean is needed, you get a syntax
error.  In strict SQL, boolean and integer are incompatible types that
cannot be interchanged.

There are two diverging philosophies of computer programming at play here.
On the one hand, there is the idea that you should have as few primitives
as possible but make them as powerful as possible so that you can do
everything you need.  Thus, since boolean values can be represented easily
as integer, there is no reason to have a separate type for boolean as that
would merely add gratuitous complication.  This is the approach taken by
SQLite.  It is also the approach taken by C.  It is also philosophically
aligned with, for example, modern physics, which seeks to find a single set
of rules that govern the behavior of seemingly different phenomena.  Why
have one physics for magnetism and a separate physics for electricity when
you can easily combine them into a single unified physics of
electromagnetism.

The other approach is to have different types for everything, under the
theory that this prevents programming bugs.  Thus you have a boolean type
that is distinct and incomparable to integers.   And there are separate
rules for dealing with booleans versus integers, adding complexity to the
language. Ada takes this approach, for example.  The official SQL standard
language is also this way.

I am deeply committed to the concept that simpler is better.  And I am
deeply skeptical of arguments that making a language more complex by adding
new type rules does anything to reduce bugs.

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to