On 14 Jun 2015, at 9:19pm, Richard Hipp <drh at sqlite.org> wrote:

> There was a huge debate in
> the software industry in the 1980s about whether applications should
> be coded in assembly or C.  Hand-coded assembly is theoretically
> faster than machine-code generated by a C compiler (or at least it was
> in the 80s - that point is debatable now).  But in practice, programs
> written in C tended to perform better than those written in assembly.
> The reason is that C being higher level enabled programmers to spend
> less time fiddling with bits and more time developing better
> algorithms.

To extend this a bit, current compilers are even better.  They're not really 
compilers any more.  They include compilation, interpretation, and simulation 
at multiple levels.  The program is analysed as a directed graph of changed 
variables.  Knowledge of the target processor is used to figure out optimal 
ways to use the various resources (registers, bandwidth, cache sizes).  It's 
ridiculous how good these 'compilers' are.

The result is that that higher level the language you write in, the better.  
The language the programmer is writing is how they tell the compiler what they 
want done.  The more expressive the language, the better the communication 
between programmer and compiler.  Writing in assembly language just shifts this 
burden onto a human, and computers are much better at keeping track of all 
these things than humans are.  The result is that the advantage which used to 
result from writing in assembler is blown away by what can be achieved by a 
good compiler of a good high-level programming language.

Some of Dr Hipp's recent work with the revised query planner reminds me of the 
above.  Rather than simply analyzing the SQL command, SQLite now looks not only 
at the command and the chunkiness of the data (the results of ANALYZE) but also 
at how the command combines the various things SQL can express, trying to guess 
what the programmer is really trying to do.  Rather than the old days of 
parsing, what's going on is moving up to the level of semantic analysis.

At this stage we have finally got to a level where alternatives to SQL -- 
either relational or not -- can be quantitively analyzed.  The 'best language' 
will be the one that compiles to the fastest-executing virtual machine program. 
 I have no idea what the result of this will be.  Perhaps the next generation 
of computer languages will be designed by computer, to let us speak to them in 
an efficient manner.

Simon.

Reply via email to