This entire talk is inspired by a single remark by a former co-worker of mine who just casually
dropped the line that Yama was so simple that nobody could ever attain mastership in
it.
So, a question towards the audience, also slight audience participation, sorry, who would
tend to agree?
That is almost nobody.
That's a shame because you would be in good company.
This is in the goat's section of every spec of Yama, there it is.
So let's get a bit into detail and the very cool Yama exists to provide printable text
presentation of structured data.
In that regard, it is a rival to things like JSON, XML and other formats, it's been around
for quite a while, we're almost looking into 20 years of Yama now.
It is somewhat interwoven with JSON since version 1.2, actually all of JSON is also
valid Yama.
That is, they're just introducing an interesting relation because now since I think 2018, JSON
is a strict subset of JavaScript, thus there's an intersection of Yama and JavaScript now
that is precisely JSON.
Let's not get into the argument if that's good or not.
If you write a lot of Yama, all of the examples, well, most of the examples, most of the real
life specimens of Yama, they will let you believe that there are no real types in Yama.
Actually the opposite is true, Yama is heavily typed, almost everything in the Yama document
has a type.
Here's a selection, they're nothing surprising, all the times you see here, they are also
present in JSON and that's also inspiring an interesting question.
Let's say you have a Yama document, could you just change the syntax to JSON and have
a valid presentation?
What that work?
Oh, you're too good.
I attracted the wrong audience because, yeah, no, that doesn't work.
It falls apart with the map type.
The map type in Yama is really, really wide.
It does allow for such things as composite keys to its entries.
If you're really interested, they're introduced by, what's the token?
Should mark space, so that's a thing.
There are not so basic types, O-map is an audit map, the regular mapping is not audit,
set is somewhat, yeah, special, there's not a complete list, by the way, there's a way
to have Yama inside Yama, that's nice.
And there's a type specifically for binary data.
This one is really, really useful, provided it actually works.
Try it.
The problem really is in JSON, XML, also in Yama is you can't have certain bite marks.
So the first 16, I believe, character points, they are off-limits, they are controlled signals,
they can't be part of the stream.
With this type, you can just base 64 everything, and once your Yama is being passed, that is
being expanded into the raw binary, pretty neat, eh?
First example, this is not minimally Yama, but it does help to illustrate a few points.
I suppose a lot of you got a lot to do with, say, OpenShift, Kubernetes and the like.
You've seen three hyphens a lot, haven't you?
Okay.
Who knows what that does?
Not quite, no, no, it's not the beginning of the document.
What this is is a document separator.
So what you see here is it's not actually a Yama document, it's a Yama stream.
Yama is meant to be streamed, possibly, don't do that unless you have a solid message framing
because truncated Yama tends to be earlier than Yama, so I think twice before you do
that.
The thing is, most of the tools that you have with Yama will assume there's only one document
ever.
You need to do some convincing to get all the documents out of the stream.
By the way, do you know what happens if you omit those three hyphens?
You do.
Okay, pretty much everything you see here, if it's omitting, it's implied.
Also, great, eh?
Say for the version number, there's also a bit of a homework for you, there's a chance
this is going to break your tools because they do not understand version 1.2.
The majority of the tools are still stuck at 1.1.
Yeah, let's get into the time for it.
This is something you see quite common, what do we have here?
It's a mapping with a single entry, which shares the key variables, inside is another
mapping for the key app version, we've got something in it.
Now there's no indication to what dantotype that is.
It's an integer, right?
Agree?
It depends on your schema.
We're not quite there yet, but this is for most pure Yama, so this is an integer, we
agree, for the time being.
This is a float, right?
This is a string, and this is still a string.
You may have noticed I omitted a few things.
What's three-point?
It depends on your schema.
No?
Yes, it does.
It says, the regular expression for float says three-point is float.
What is point one then?
It's also float.
So if you want to make sure this is really always a string, you may be tempted to do
something like this, I quoted things, our thing, also in Yama, big surprise, so you
quoted also, so the professional may do something like this.
This is a tag, the two exclamation marks means it's a global tag.
So there's global meaning, oh, I'm running out of time.
It's a string, have my word for it.
The true professional who lost the plot may do something like this.
These marks are identified by URNs, and also there's a namespace mechanism in Yama.
There's a part where you go, yay, namespaces.
So advanced features, this is something you do not commonly see.
Most users of Yama are probably unaware this exists, but you have some tools to reduce
duplication redundancy within your structures.
One is anchors, they're basically marker, and one are alliances that do invoke those
anchors.
Pretty nifty, also these do give way for an attack known as one billion laughs.
So it's basically you can set an anchor to an array or list of alliances who themselves
contain a lot of anchors.
So this allows for a very complex presentation of a very complex data structure that quickly
expands plenty of votes.
So if you happen to consume Yama from untrusted sources, this is something you should know.
Magical operator, this is another really nifty tool.
It's only valid in 1.1 of Yama, it got immediately deprecated in 1.2, and also it's a data type.
It's there to basically merge mappings into all the mappings, great stuff.
So test from the trenches, these are examples that really happened.
Do you see, I should explain this, this is part of a GitLab setup, as a script, this
is expected to be a sequence of strings to be executed on the shell.
That's not what it is.
What is the answer?
No?
Oh, very good, yes, that's not a string, it's a mapping.
Because of the single pass design of Yama, the algorithm is very, very greedy.
So it sees that colon there and says, oh great, this is a mapping, and completely ignores
the quotations.
So how do you fix this?
There's one for ways, yes, I think the third one is my favorite, the fourth is really unsafe
because once again, raw binary data, perhaps I don't know that.
This is another favorite, again, GitLab CI, we have a mapping.
We try to set some variables for GitLab to expand.
What is the content of bar?
I must remind you, mappings don't have order, oh, who knows?
I thought the answer was for us.
Oh, no, it's going to be empty, it's going to be empty.
Another thing is, the mapping doesn't have an order, the Yama implementation in GitLab
has other ideas, so it takes the mapping and applies an order on it, so bar goes top because
lexicographic order.
And then there's a single round of interpolations, and foo at that point is empty as a variable.
So how do you fix that?
Either way out is you rename your variables, or this, thank you, thank you.
This never happened to me, but it's been too good to pass.
What do we have here?
What does languages contain?
It's a sequence of, we will need to drink.
It's one string and one Boolean, because no, which we're supposed to present Norwegian
here, is accepted as a Boolean, so you need to tag that or quote it, however you wish.
So my observations, because of the edge cases of the hidden complexity, there's a huge disparity
in features that various tools actually support, they also show different behavior.
It's one hot mess, I can't put it in other words.
Also, if you're writing Yama, it is admittedly really a pleasure, it's easy to type, but
you can never let your guard down.
Yama would try to do a lot of lag work for you, being very accommodating, and sometimes
the worst way possible.
Some proposals on that, because the versions of Yama really do different behavior.
You should start to tag your streams, accordingly, you should see that the tools you use for
consuming Yama are properly configured, things like language-specific extensions.
So part of the Yama streams could be evaluated in the process, read, executed, and that's
a bit scary.
As most of, yes, right, as most of Yama is relatively simple, the complexity is mostly
because it's deeply nested and you can't properly edit it.
But Yama may be a solution, it's a strict subset of Yama with a lot of the ambiguity
removed, way safer, way easier, tooling support is so-so.
So I teased a question with this talk, the question could be, Yama is exactly then the
answer if all you wanted was Jason with comments.
Some other niceties as well, but that's pretty much it.
So this concludes my talk, thank you very much, you've been terrific.
Is there any questions?
Please repeat the questions.
We've got four seconds.
Is Jason any better?
There you have it.
It depends on what your use case is really.
Repeat the question please.
Oh yes, the question was Jason any better.
So yes, thank you very much again.