Well said!

C++ provides the average programmer "automated" Object Orientation, or
better stated, good programming practices, at a price.  A good C programmer
can equal and most times exceed the results of a C++ programming project.
As previously stated C is really just a lazy man's Assembler, and you can't
get any closer to the hardware, unless you are into machine language,
independently wealthy, with no need for sleep.

Fred

-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Ibrahim A
Sent: Wednesday, June 03, 2009 6:25 AM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] sqlite programmed in C++


Hi all,

I'd like to comment this topic as well.

I think C is a very good choice for projects like sqlite. The point is
that C is in contrary to C++ very easily portable. If you have the bad
luck that you have to port a programm on a new plattform for which no
compiler suites exist than the choice of C for such a project pays of.

You'll find a few short understandable and editable C-Compiler
implementations on the internet. As an example TCC, LCC or PCC. They are
short enough to port to a new plattform. To port TCC to a new plattform
as an example needs about one week when you have to start from zero
because you only need to refine the code generation interface for the
destined target system.

sqlite uses a few dozen standard function calls and the most of them are
easily to implement in C itself. And don't forget that C is designed as
a portable assembly language so it's really fast.

If you now look at C++ you'll find only two mentionable Compiler
implementations which you can use for a porting task. And these
toolchains require more than the knowledge of C with which you could
port TCC or PCC.

When you look closer to the sqlite code you'll find, that the code uses
objectoriented techniques on many places. Many of the interfaces to
different functionality like vfs or fts are objects in a portable way. A
C++ object is nothing different than a table of functions and data
pointers and this is used in sqlite as well but the difference is, that
this implementation is portable and interchangeable between compilers.
If you would start to use C++ than you would end up compiling a
interface with one compiler and being unable to use this interface from
another compiler or even a compiler with a newer release date. C++ only
supports compile time modularity and no runtime compatibility between
libraries written in this language and compiled with different versions.
The binary implementation of OOP abilities is always proprietary. The
support of the code would be horrible because you'd have to deal with
incompatibilities between different implementations.

To summarize my opinion :

C is the best choice for portable projects like sqlite. C is fast enough
and if you don't have a compiler you can create one. If you don't have a
standard library you can use free libraries.

I would wish that drh would go a step further and avoid using awk and
tcl for the code creation process. This would solve the problem with
Preprocessor definitions which can be set during compile time but where
some have also to be set while you create lemon. It is possible to
exchange each of the awk and tcl scripts which are used during code
generation and the generation of the amalgamation with only C this would
make the whole thing simpler to port and more independent from any
external tools or plattforms and it would also make it possible to use
all of the creation makros while you create the sourcecode.

Ibrahim
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to