Skip to content
Nick Sabalausky edited this page Sep 25, 2016 · 3 revisions

Q: Is SDL trying to replace XML? What is the relationship?

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
}

Tip: Boolean Literals

on and off can be used as boolean literals.

Q: How mature is SDL? Is it safe to use on my project?

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.

Q: Can I use SDLang with older versions of Java (pre Java 5)?

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.

Q: Can I use SDLang with older versions of C#?

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.

Q: I have a question about SDLang. Who can help me?

At this point, the best way would be to post your question as a new issue over at SDLang-D's issue tracker.

Q: Is the Java SDL library thread-safe?

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.

Q: If tags are nested to very deep levels, doesn't the lack of a closing name cause confusion?

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 ;)

Q: Does the order of values, attributes, or children in a Tag matter?

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.

Q: Why don't you add <insert suggested literal type>?

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.

Q: Have you heard of <insert related language>? Why wasn't it good enough?

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.

Q: I want to contribute to SDL. Who do I talk to?

Most implementations are hosted on GitHub, so if you'd like to contribute, feel free to fork the projects and submit pull requests.