Chapter 8: Examples and Other Technologies
There are thousands of examples that can be made with this technology. It is as simple as taking any example from another language and seeing how it would be written in STxT. Perhaps the simplest is an example derived from XML, as it has many parallels with STxT.
Many examples I have obtained from Wikipedia.
An (invented) example of XML would be:
<Library> <Book id="1"> <Title>The Fellowship of the Ring</Title> <Author>J.R.R. Tolkien</Author> <Language>EN</Language> <Published>29 July 1954</Published> <Genre>High fantasy Adventure</Genre> </Book> <Book id="2"> <Title>The Two Towers</Title> <Author>J.R.R. Tolkien</Author> <ISBN>76542</ISBN> <Language>EN</Language> <Published>11 November 1954</Published> <Genre>High fantasy Adventure</Genre> </Book> <Book id="3"> <Title>The Return of the King</Title> <Author>J.R.R. Tolkien</Author> <ISBN>12345</ISBN> <Language>EN</Language> <Published>20 October 1955</Published> <Genre>High fantasy Adventure</Genre> </Book> </Library>
The same in STxT:
Library (www.examples.com/demo.stxt): Book: id: 1 Title: The Fellowship of the Ring Author: J.R.R. Tolkien Language: EN Published: 29 July 1954 Genre: High fantasy Adventure Book: id: 2 Title: The Two Towers Author: J.R.R. Tolkien ISBN: 76542 Language: EN Published: 11 November 1954 Genre: High fantasy Adventure Book: id: 3 Title: The Return of the King Author: J.R.R. Tolkien ISBN: 12345 Language: EN Published: 20 October 1955 Genre: High fantasy Adventure
Another example in XML:
<email> <from>John Smith</from> <to>Mery Adams</to> <cc>Keyla Brown<cc> <title>Project report</title> <body>Hello Mery!! The book is finished!!</body> </email>
In STxT, it is transformed into:
Email (www.example.com/email.stxt): From: John Smith To: Mery Adams Cc: Keyla Brown Title: Project report Body: Hello Mery!! The book is finished!!
We can see that the conversion between the two formats is instant, though STxT is much more aesthetically pleasing.
By the way, there is a hidden chapter, STXT and XML, in case you want to read it. I wrote it in 2013, and it's... interesting. Read at your own risk ;-)
Wikipedia (*)
I have great admiration for Wikipedia. I think it is one of the best projects created on the Internet.
How could it benefit from STxT?
Well, Wikipedia could have different templates: actors, politicians, TV series, movies, cities, countries, rivers... sharing grammars in many cases. For example, both actors and politicians can have biographies, but actors would also have a list of movies.
Moreover, it would be very interesting to mix STxT with Wikipedia's own language. I think this is a point where STxT excels compared to most languages. The blend with so-called "lightweight markup languages" is truly spectacular.
So, you can create mixed texts like this:
City (www.wikipedia.org/city.stxt): Name: Barcelona Autonomous Community: Catalonia Country: Spain History: {{Main|History of Barcelona}} The founding of Barcelona is the subject of two different legends. The first attributes the founding of the city to the mythological [[Hercules]]. The second legend attributes the foundation of the city directly to the historical [[Carthage|Carthaginian]] [[Hamilcar Barca]], father of [[Hannibal]], who named the city ''Barcino'' after his family in the 3rd century BC. ...
Another advantage is that with STxT we would not only have "templates" of what city information should look like, but we could also apply styles and formats depending on the type of document.
STxT and Other Technologies
Lightweight Markup Language
Lightweight markup languages have seen a spectacular rise thanks to projects like Wikipedia. Thanks to them, text can be defined much more simply than having to write tags like HTML. But they have a major drawback: They do not have a clear structure or semantics.
In fact, practically all of them focus on text styling:
- Bold
- Italics
- Lists of items
- Data tables
- ...
It is surprising to see what we can achieve by combining these languages with STxT. We get text that is easy to interpret, with defined semantics, and the expressiveness of both languages.
An example:
Product: Name: Magic memory Price: 10€ Description: This product produces a _magical rejuvenation_ of memory and provides an **immediate** effect on all those who try it. Effects: * Rapid memorization * Automatic learning * Increased concentration
We see that we have given structure thanks to STxT, but the description is given in Wikipedia style.
The combination of STxT with Lightweight markup languages is simply spectacular
TeX, LaTeX
Apologies if I criticize too much. I never do it without offering an alternative or a reason. I like constructive criticism ;-) I have seen that one of TeX's goals is for a document to print the same now and 100 years from now. I thought that was perfect... until today. Now I think the goal should be for it to mean the same thing now and 100 years from now, and for it to be understood now and 100 years from now. And by as many people as possible. This is not achieved with TeX, but it is with STxT. A document is understood today and 100 years from now. How do I think it should evolve? I would create documents in STxT, specify a grammar for the different types of documents, allow TeX elements (like formulas) in the same way that lightweight markup languages do, and use TeX as the rendering engine.
I dare say that TeX is unbeatable in terms of rendering; and I think it will remain so for at least 100 more years ;-)
What would a document look like? Well, a simple example would be something like this:
Article (www.latex.com/article.stxt): Title: Author: References: Reference: Title: Year: ISBN: Reference: Title: Year: ISBN: Paragraph: This is a mathematical formula: Formula: \begin{eqnarray} x&=&y\\ x^2&=&xy\\ x^2-y^2&=&xy-y^2\\ (x+y)(x-y)&=&y(x-y)\\ x+y&=&y\\ 2y&=&y\quad \mbox{(first equation)}\\ 2&=&1 \end{eqnarray} Paragraph: Hello World!!
In fact, now that we can think about STxT, it might be time to create formulas in another way, or a more simplified notation, such as:
Article (www.latex.com/article.stxt): Title: Author: References: Reference: Title: Year: ISBN: Reference: Title: Year: ISBN: Paragraph: This is a mathematical formula: Formula: Array: Element: x&=&y Element: x^2&=&xy Element: x^2-y^2&=&xy-y^2 Element: (x+y)(x-y)&=&y(x-y) Element: x+y&=&y Complex: Element: 2y&=&y\quad Element: mbox{(first equation)} 2&=&1 Paragraph: Hello World!!
Well, there are thousands of possibilities and ways to approach the problem; I'll leave it to you as an exercise ;-D
What have we gained compared to just TeX?
- Ease of document creation
- UTF-8
- Defined structure
- Semantic text
- Readable text
And also, we have maintained the compactness in the creation of mathematical formulas and other elements where TeX is indeed a great language.
JSON
JSON initially has nothing to do with STxT, but there are certain times when they might compete. I am thinking of configuration files, for example. Furthermore, it is more flexible and easier to read when embedding large amounts of text, something that always needs to be considered with JSON due to escaping characters.
But there is no need to worry too much. I do not think JSON and STxT are direct competitors, due to their different areas of application.
YAML
Perhaps YAML is the one that most resembles STxT in approach, although it is also very different. We believe that with our structure, we can show the same as YAML, and much more simply. Additionally, we can add semantics to the document with namespaces, while still allowing text that is readable to most people, regardless of their technical knowledge.