-
Notifications
You must be signed in to change notification settings - Fork 21
SDL is not trying to replace XML. XML is an excellent format for marking up documents, describing metadata, mixing tags in free form text, and many other applications.
XML is also commonly used for properties files, configuration files, and object serialization. For these purposes, SDL offers a terser and more perspicuous syntax. SDL is type aware and allows datastructures such as lists, maps, and trees to be easily represented.
Lets look at a snippet from a configuration file represented in both languages.
XML
<path id="prog.src">
<pathelement path="${src.dir}" />
<pathelement path="${res.dir}" />
<pathelement path="${external.src.dir}" />
</path>
<target name="prog.tests" depends="prog.build" echo="true">
<java classname="org.ikayzo.sdl.PackageTests" failonerror="true" dir="${basedir}/test" fork="true">
<arg value="-d" />
<arg value="${basedir}/test" />
</java>
</target>
An SDLang equivalent is shorter, more readable, and type aware:
paths "prog.src" {
"${src.dir}" "${res.dir}" "${external.src.dir}"
}
target "prog.tests" depends="prog.build" echo=on {
java "-d" "${basedir}/test" "org.ikayzo.sdl.PackageTests" failonerror=true \
dir="${basedir}/test" fork=true
}
on and off can be used as boolean literals.
SDL 1.0 was released in 2005. It is in use on a number of large projects and is actively maintained by multiple contributors. A implementation for D, SDLang-D, was first released in 2013 and is actively maintined.
SDL for Java uses new language extensions introduced in Java 5 such as generics, annotations, etc. The included binaries will only work with Java 5, but you can backport the library to Java 1.4 using Retroweaver.
SDL for .NET requires C# 2.0. There are currently no known plans to provide support for earlier versions, but if you would like to contribute a backport, by all means, feel free to fork the project.
At this point, the best way would be to post your question as a new issue over at SDLang-D's issue tracker.
The central Java SDL Tag data structure is not thread-safe. It is up to you to handle thread safety in a way most appropriate to your application. If multiple threads have access to a tree of Tags its a good idea to synchronize on the root Tag.
It is our experience that for most purposes SDL doesn't need to be nested as deeply as XML (because of the value lists, anonymous tags, etc.) If you need deeply nested SDL tags you can add a simple comment to the close bracket to avoid confusion.
tag1 {
tag2 {
tag3 {
}
} # tag2
} # tag1
Besides, the lack of a closing name works fine for most programming langauges ;)
The order of values and children is significant. Duplicates are allowed and the order in which they are listed is maintained in the model. The order of attributes is not significant (although the D implementation does preserve attribute order). Only one instance of an attribute key is allowed in a given tag. See the Language Guide for details.
We are trying to keep SDLang true to its name ("Simple Declarative Language") by including only very commonly needed literal types. There has been some consideration about adding a reference and scalar range type to SDLang 2.0, but that may or may not happen. And that is about it.
If it is listed in the references section of the Language Guide, then yes, we have heard of it. Similar declarative languages like YAML met some but not all of our design goals. YAML code such as:
!!map {
? !!str "---"
: !!str "foo",
? !!str "...",
: !!str "bar"
}
does not seem very natural in the modern language landscape. We feel SDLang's type inference from "natural" looking literals similar to those found in C or Java is preferable. SDLang maps (attributes) and lists look similar to analogous constructs in popular scripting languages.
Additionally, SDLang was designed to cleanly map to and from XML. This is not true for all the languages in our references list.
Most implementations are hosted on GitHub, so if you'd like to contribute, feel free to fork the projects and submit pull requests.