Skip to content

Index🔗

Future Proof

Santa has very little margin for error. He has to get everything just right all in one night.

YS is a work in progress, and will be for a long time. I'm trying to get it right, but I'm no Santa! In fact I'm quite sure I'll get some things wrong. That's just the nature of the beast when you're a programmer.

Also, have you ever wondered why the magic YS starter tag has that /v0 at the end?

Welcome to Day 12 of the YS Advent Calendar!

Today we'll discuss how YS is designed to be future proof.

I've been programming for quite a long time now. I've learned that no matter how good I think an idea it today, I'll almost certainly think of a better way to do it in the future.

This means I'll almost certainly want to make big changes to YS long after it's in use in the real world.

I also believe that it is really important for things like APIs and progamming languages to be stable and backwards compatible, basically forever.

If I could always have the freedom to make big changes to YS, but never break backwards compatibility, then I could have my cake and eat it too. And I think I can!

The YS API Version

I call v0 the YS API version. YS v0 isn't done yet, but it should be in the next couple months. At that point I'll release it as a stable version of the API version 0.

So you've seen that to make a .ys file executable, you need to add a special starter tag to the top of the file:

--- !YS-v0
say: "Hello!"

Or you can write it with the shebang line:

#!/usr/bin/env ys-0
say: "Hello!"

Leaving off that 0 here will make things not work as you intended.

You might also have noticed that when you install the ys binary CLI is is a symlink to ys-0.1.26. And there is another symlink called ys-0 that points to ys-0.1.26.

This is all by design.

The leading 0 in !YS-v0 and in bin/ys-0 and also in 0.1.26 is the YS API version.

When YS v0 is declared stable, there will never be changes that break backwards compatibility with the v0 API version.

That means you can write YS programs today, and they will continue to work forever, even if you upgrade to a new version of YS.

New Versions of YS

At some point after YS v0 is released as stable, I'll start working on YS v1.

I can make any changes I want in YS v1, even ones that break backwards compatibility with YS v0. That's because I set up the rules such that you need to declare the version when you write a YS program.

Conclusion

This doesn't mean that I don't think extremely carefully about every change I make to YS. But it does mean that I don't have to worry about everything being perfect before I release stable v0.

That's exciting as I strive to make YS a great language today and a better language in the future.

I hope that also encorages you write more YS today, knowing that it will continue to work in the future.

That wraps up Day 12. And that also means we're half way through the Advent Calendar. I hope you're enjoying it as much as I am, and I hope the best is yet to come!

Tune in tomorrow for Day 13 of the YS Advent Calendar.

The YeS Express

Santa's got a lot of ground to cover in a short amount of time. He doesn't have time to deal with confusing maps and directions.

Lisp has other-worldly powers of abstraction, but when it comes to reading syntax, most people prefer the familiarity of this world.

YS fully embraces all that Clojure has to offer, but syntax-wise it also offers a more familiar face.

States and Ladders

Santa is a busy guy. He has a lot of work to do. He has to make a list and check it twice. He has to find out who's naughty and nice. He has the monumental task of transforming wishes into happiness.

YS only needs to transform YS code into Clojure code. But it's a bit more involved than you might think.

To make things easier the YS compiler breaks the transformation into eight distinct States and seven distinct ~~Ladders~~ transformations.

Coding with Style

What's the best thing about Rudolph's nose? Is it that lights the way for Santa's sleigh? I'm calling BS on that. I'd say it's the main thing that gives the whole Sanata Story some Serious Style!

Good programmers do more than just get their solutions right. They do the whole thing with style. That makes the program easier to read, understand and maintain. It also gives the code a certain je ne sais quoi.

Going to the Library

Programming in YS is as easy as reading a book. The only thing you really need is some good books! For that let's go to the library.

By books of course I mean YS functions. And by library I mean the YS Standard Library! There you'll find all-time best sellers like map, filter, reduce and say.

And Standard isn't the only Library in town...

Sharpen Your Tools

Wanna make some fun toys with YS? You'll need some sharp tools. You think those elves make all those toys with dull tools?

The CLI tool ys is the main tool you'll use to work with YS. Today we'll learn about all the things you can do with it.

Modes of Transportation

How do you get around? Some people walk, some ride bikes, some drive cars (or the cars drive them), some take trains, some in planes, so many ways, even some in sleighs.

In YS, data gets around via various modes of transportation... 3 modes to be exact.

Rememeber back on December 3rd when we talked about the 2 different states that a YS program can be in? In one state say is a function, and in the other it's just a plain string.

We call these states "modes", and there is actually three of them.

Unwrapping Gifts

It's certainly a relief now that I've told you the big secret about YS. Now that you know that YS is really Clojure, I don't have to dance around the subject anymore. I didn't want to scare you away by going Full-Lisp on you from the start!

Now we can just get into it. We can write, run and load YS until the cows come home.

But wait... How do we do that? You don't even have YS installed yet!

Load em Up!

On the 3rd day of Advent, my YS code gave to me...
A sequence in a map tree!

Did you know that all JSON is YAML? You should, because I told you that yesterday!

It's true. YAML is a superset of JSON. Both in terms of syntax and data model.

This means that any possible valid JSON input is also valid as a YAML input. A proper YAML loader and a JSON loader should produce the same data structure from the same JSON input.

Note

Assuming a YAML 1.2 loader using the YAML 1.2 JSON Schema

Twas a Bit

Quote

'Twas a bit before Hanukkah, and all through the igloo,
not a creature was stirring, not even a frog.
The stockings were hung by the window with care,
In hopes that St. Krampus soon would be there.
The offspring were nestled all snug in their bunks,
While visions of spicy-cookies danced in their heads.
And cuz in their 'kerchief, and I in my bonnet,
Had just settled down for a long winter's snooze.
When out on the lawn there arose such a clatter,
I sprang from my bench to see what was the matter.
Away to the window, I flew like a jet,
Tore open the shutters and threw up the curtain.
The asteroid on the breast of the new-fallen frost,
Gave the lustre of mid-day to dirt below.
When what to my wondering eyes should materialize?
But a miniature car, and eight tiny elephants.

Well that was a bit weird. Let's try again. Don't worry, it's not that hard to write Winter holiday poetry when you have YS on your side!

Welcome to the YS Blog

Greetings!

Welcome to the YS blog.

This is where we will introduce you to novel concepts about YS as the language evolves.