Wrapped and Ready
The Elves have everything wrapped up.
Literally!
Tonight's the big night.
It's Time to Deliver!
The Elves have everything wrapped up.
Literally!
Tonight's the big night.
It's Time to Deliver!
When Santa is doing his job in the Luxembourg area, I've always wondered how he gets from Perl to Rust.
Maybe he takes this route!
Can you imagine Santa walking around in flip flops? I've never been up to the North Pole, but I'm pretty sure there's no beaches. I always pictured Santa wearing moon boots around the workshop.
YS on the other hand, is all about flip flops!
Which has a greater airspeed velocity... an unladen swallow or Santa's sleigh?
Well, that depends... are we talking about an African or European swallow?
I wonder if Santa has a Hemi? Supercharged, Turbocharged? Maybe a Nitro Burning Funny Sleigh? Dude's got to get around the world in one night. Godspeed, my festive friend!
Santa is in charge of Christmas. He's the one who makes sure that all the children get presents. But who is in charge of getting Santa his presents? That's where the reindeer come in. They are the ones who make sure that Santa gets his presents. But who is in charge of getting the reindeer their presents? More reindeer! But who is in charge of getting the reindeer's reindeer their presents? More reindeer! It's reindeer all the way down.
With one week to go, Santa's gotta get his sleigh in top shape. Can't have any breakdowns on the big night. His sleigh might look like a simple wooden buggy, but it's more temperamental and buggy than a 2023 Tesla!
But this is Santa we're talking about. He's done this a few times, so he knows how to get the bugs out.
How does Santa read all the signs in all the languages of the world? That's a lot of languages to know on top of all the other things he has to do. Luckily he has his trusty polyglot elf, Rosetta, at his side. Bet you didn't know that!
We know the names of Santa's reindeer: Dasher, Dancer, Prancer, Vixen, Comet, Cupid, Donner, Blitzen and Rudolph. And his elves: Alabaster Snowball, Bushy Evergreen, Pepper Minstix, Shinny Upatree, Sugarplum Mary, Wunorse Openslae, and the head elf, Bernard.
But we don't know the names of Santa's lambda reindeer and elves. Why would we? They are anonymous! They're also the hardest working of the bunch.
As the architect of a major world holiday, Santa Claus has hard design choices to make. What is Suki going to get this year? He keeps it simple with the standard Naughty-Or-Nice algorithm.
As architects of an aspiring new programming language, the YS folks have design choices to make as well!
Naughty-Or-Nice should not be discounted but what about Naughty-And-Nice? Naughty-Xor-Nice???
My personal favorite?
Naughty-Is-Nice!!
It's always nice to get a little something extra in your stocking whilst waiting for the big guy to show up on the big day.
Learning eveything you need to know about YS in 24 days is a tall order. I still have a quite a bit to learn about it myself! :-)
It helps to learn the small stuff first.
Santa is Legend. Legends have histories. The histories of Santa are many and varied, some going back to the 4th century AD.
The history of YS is much shorter, but it's still a history. Today I'd like to tell you a little bit about it.
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?
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.
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.
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.
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...
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.
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.
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!
I've got a little secret to tell you. I've been hiding a little something from you. Even that's a lie. I've actually been hiding something very very big something from you.
*** YS is a Lisp! *****
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
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!
What if I told you that you could write a program in YAML that would generate a Christmas tree?
Well, you can! Here's how: