User:Infinity Linden/Notes On LLSD
LLSD is the abstract type system used by Linden Lab and some OpenSimulator components. It is described in varying levels of detail in several places. But the motivation for various design decisions in LLSD have yet to be documented. This document is an effort to more accurately describe LLSD and why it is the way it is.
What Is LLSD?
LLSD is an abstract type system which includes an interface description language and serialization formats. LLSD is a language-neutral facility for maintaining and transporting dynamic structured data. It provides dynamic data features for loosely-coupled collections of software components, even in statically-typed languages. It includes an abstract type system, an interface description language (LLIDL) and three canonical serialization schemes (XML, JSON and Binary). The term "LLSD" is used to refer to the abstract type system, code that implements the mapping and conversions between abstract and concrete types and the it's serializations. This can lead to confusion, so this document will make an effort to be explicit about which aspect is being discussed.
The term "language-neutral abstract type system" means that LLSD is used to define the "type" of objects in an application and protocol data being sent across the wire. When we say "type" we mean that different objects may have semantics. For instance, Integers are data objects that can be added together, subtracted one from another, multiplied or divided; Dates represent moments in time; Booleans represent true and false values.
It is "language-neutral" and "abstract" in the sense that is intended to be usable by programmers of several different computer programming languages. Another way to say this is that type semantics unique to a programming language are not replicated in LLSD. For instance, in the C programming language, there is not default date type. Rather, it is sometimes represented as an unsigned 32 bit integer and other times represented as a data structure. When represented as an integer, you can add an integer to a date and get the date of some time in the future. But you can't do this with the data structure from C's standard library. Because LLSD is language neutral, it makes no attempt to preserve the semantics of dates stored as a 32 bit unsigned integer representing seconds since 1970. LLSD is used to reason about type semantics of protocol data units in a manner independent of any particular programming language.
Saying that LLSD is "abstract" speaks to the fact that there are no programming languages that directly use LLSD's type system. It also implies that there's something out there that's "concrete." Implementations of LLSD (some of which are identified below) "concretize" it's abstract behavior. The Python implementation of LLSD for instance, maps LLSD's abstract types to types understandable by Python programs. C++ implementations do the same for C++ programs.
Finally... the term "dynamic structured data" implies that LLSD structures can be modified at run-time. Note that there are several languages where this is not the case. For languages like C or C++, the LLSD implementation would need to create the illusion that LLSD data structures are malleable at runtime.