SQLite’s Use of Tcl (2017)
tcl.tk
tcl.tk
His article on threads from 1995 was highly influential on me, and I remember it to this day. More recently (2018, revised and expanded in 2021), he published a book on software engineering practices called A Philosophy of Software Design which is, in my opinion, the best in its category.
Would you have a link?
TCL can handle binary data. It is just not a separate type: https://wiki.tcl-lang.org/page/Working+with+binary+data
SQLite also always had a null type, surely?
> However, types are still very flexible in SQLite, just as they are in TCL. SQLite treats the datatypes on column names in a CREATE TABLE statement as suggestions rather than hard requirements
This is something I do not much like. Its not compulsory (you can create "strict" tables). It works well in TCL which is an entire language designed around the idea. Less so in SQL.
One of the advantages of RDBMSes is that not accepting obviously wrong data makes life easier for developers. You can debug an issue that happens on inserting the data, not when you find the wrong type or other bad much later on.
"Binary data is now supported in Tcl."
https://www.tcl.tk/software/tcltk/relnotes/tcl8.0.txt
Well before 2004, but worth mentioning because you'll find a fair amount of old posts complaining about it.
"Binary I/O. The new object system in Tcl 8.0 supports binary strings (internally, strings are counted in addition to being null terminated). There is a new "binary" command for inserting and extracting data to/from binary strings. Commands such as "puts", "gets", and "read" commands now operate correctly on binary data. There is a new variable tcl_platform(byteOrder) to identify the native byte order for the current host."
The confusion comes from the fact that set() automatically coerces space-delimited items into a ;-delimited list
set(ONE alpha;beta)
set(TWO alpha beta)
list(LENGTH ONE one_len)
list(LENGTH TWO two_len)
message(FATAL_ERROR "one <<${ONE}>> length ${one_len}\ntwo <<${TWO}>> length ${two_len}")
emits one <<alpha;beta>> length 2
two <<alpha;beta>> length 2NULL is surely a value, not a type, no? You can restrict use of NULL with the column type, but it doesn't make any sense to have a NULL type rather than, say, a nullable-string type. What would be the point?
This is an example of a singleton type - a type that can only hold one value. It's not the only example though, it's fairly common to support string or integer singleton types, e.g. in Typescript you can have the type "foo" which only has a single possible value, "foo". Or some languages support a type int(5) for which the only possible value is 5.
You might think that's useless, but it's very useful when combining types, e.g. via unions. Or sometimes when writing generic code.
SQL has an extremely primitive type system so there's no syntax for type unions etc. But you can imagine if it was written by someone who had experience of modern typing you would say `my_nullable_column: string | null`.
In 'stringly typed' languages, the natural value of NULL is the empty string.
SQLite currently distinguishes between "" and NULL, and I don't know if this was always the case. But it's quite possible that SQLite 1 and 2 conflated the empty string and NULL.
https://youtu.be/kHmwv3I1Kxk?si=CrZW_VVnA_UqcXCU
I was looking for this because Figure 1 (Breakdown Of SQLite Source Code By Language) is missing, and archive.org doesn't seem to have it. That chart can be found near 11:56 of the video above.
Always feels silly to have to install Tcl to compile sqlite3,
I use the --disable-tcl configuration option before compiling. After "make" I have a one-liner to statically-link the sqlite3 binary. It takes a relatively long time to link; sqlite3.c is a whopping 8.7M. I end up with a 1.7M sqlite3 binary.
I never do "make install". I do not want to install all the Tcl stuff.
Duff's Device[1] for the win!
http://i.stanford.edu/pub/cstr/reports/cs/tr/80/796/CS-TR-80...
https://wiki.tcl-lang.org/page/Tcl+Editors
And you can find a version here:
http://grumbeer.dyndns.org/ftp/cdroms/freebsd/freebsd-2.2.1-...