Where the Funcs Have No Name
Any self-respecting functional language has a way to create anonymous functions.
In YS there are more than one!
Today we'll talk about nameless functions, why they are useful, and how to create and call them.
Any self-respecting functional language has a way to create anonymous functions.
In YS there are more than one!
Today we'll talk about nameless functions, why they are useful, and how to create and call them.
YS is a functional programming language.
Therefore we should be able to write functions in YS.
This week I want to do a mini-series of blog posts about using and writing functions in YS.
Let's get started!
How did YAML get started in the first place?
Today's Sunday post is about YAML, not YS.
But since YS is YAML, I think that's OK.
This is the story of how the YAML data language got its start as far back as 1999.
React and Comment here please!!!
I'm not sure how many people are reading this series, but I'm enjoying writing it. It's nice to know that I'm not alone on this Summer journey.
I recently added Reactions and Comments support to these blog posts. Scroll down to the bottom of each post to see them.
If you are enjoying the Summer of YS series, please don't forget to react (and comment if you want to) to let me know!
Like I said before, in YS, There's More Than One Way To Do It.
This is especially true for YS expressions.
Later on you'll learn that YS is a Lisp in disguise. In Lisp, an expression is a list consisting of a function and its arguments inside a set of parentheses.
Consider this Python code:
name = "World"
print("Hello, " + name + "!")
In a Lisp, this would be written as:
(def name "World")
(println (str "Hello, " name "!"))
In YS, this could be written as:
name =: 'World'
say: str('Hello, ' name '!')
I say could because... TMTOWTDI!
Today I'm going to show you many of the ways to DO IT in YS.
Yesterday I left you with a program that really needed to "YS up"!
$ ys -e '
url =:
"https://github.com/dominictarr/random-name/raw/master/first-names.json"
people =: url.curl().json/load().shuffle().take(3)
shoes =: read("shoes.yaml").yaml/load()
say: str(people.0, " wears size ", shoes.0.size, " ", join([shoes.0.name, "s"]))
say: str(people.1, " wears size ", shoes.1.size, " ", join([shoes.1.name, "s"]))
say: str(people.2, " wears size ", shoes.2.size, " ", join([shoes.2.name, "s"]))
'
Let's make this awesome!
Ever been to Manitoba? I went there once when my flight from Seattle to Toronto diverted to Winnipeg because the plane's toilets stopped working! That's when I learned about the World's Largest Curling Rock.
Toronto DevOps Meetup
Speaking of Toronto, I'll be giving a talk called "The YS way to YAML" at the Toronto DevOps Meetup on June 12th. That's one week from today!
If you're in town I hope to see you there!
Today we'll be doing a little curling with YS.
Probably the biggest problem people have with YAML is that everything has to be in one file. Things start off nice and clean, but as requirements grow, so do your files!
What if you could compose your YAML documents like you compose your code? Lots of small, single-purpose, possibly reusable files that you can load and compose together into the thing you need?
That's what YS is all about. As you know, YS is a functional language, and it has quite a few ways to load data (and code too, since Code is Data™!) from external sources.
Today we'll be looking at how to load things from disk files, including:
You can also load things from CSV/TSV files, shell commands, databases, APIs, environment variables, and the web, but those are topics for another day.
YAML files (aka YAML streams) can contain multiple "documents".
A YAML document is a top level mapping or sequence "node".
Most YAML files contain a single document, but YAML files can contain multiple
(or zero!) documents.
New documents are started with a line of three dashes: ---
.
YS can put these documents to all kinds of good use.
When you "load" a YAML file with YS, the result is the evaluation of the final document (by default). But since YS is functional, it can access any of the other documents.
Let's continue with yesterday's shoes example.
YAML itself isn't a functional programming language, but advanced users are probably aware of YAML's anchors, aliases and the merge key.
The merge key is YAML's one functional thing, and it's actually not even part of the YAML 1.2 spec. However, people find it useful and many YAML implementations (including YS) support it.
The merge key (<<
) is a special key that allows you to merge the contents of
one mapping into another.
Today we'll explore the merge key a bit and show how variables can make it nicer to use.
Today starts a 3 month long, daily summertime journey into the intricacies of YAML and the wisdom of YS! Put on your favorite pair of coding sunglasses, grab a refreshing config drink, and let's get started!
Back in March I promised to start writing more often about all the ways that YS can help you out day-to-day with your YAML interactions. When I last posted here it was barely Spring and now Spring is turning into Summer.
Seasonal turning points be damned, I think of Summer as June, July, and August. In other words...
It's Summer dammit!
Let's declare this Summer, The Summer of YS!
Wait, what?!!?
Run a YAML file?
And with Bash?
How is that possible?
Greetings! And welcome back to YAMLScript in 2025!
Or as we now say, YS in '25!.
It's been a minute since our last update, but we've been working super hard to make YS the best it can be.
Oh… What's "YS", you say?
Well, don't say "Y-S"…
In my many years of creating Open Source software and talking about it at conferences, some of the most productive development times are often those leading up to the presentation.
In the last post, I mentioned that I was going to present a 90 minute YS tutorial at KubeCon (November 15th in Salt Lake City).
The conference was amazing and the YS tutorial was a huge success. I came away with the feeling that YAML and YS had found their community. KubeCon felt like YAMLCon!
Greetings!
It's been over 3 months since the last blog post here.
Just to be clear, the YS/YAMLScript project is alive and fantastic!
We've just been busy as hell on 2 very big things: Exercism and KubeCon.
To be successful in both of these endeavors, YS needed to be amazing both as a programming language (Exercism) and as a data language (KubeCon).
There's so much new stuff to talk about, and I promise to write about all of it after things get back to a normal pace.
Today let's talk about Exercism, KubeCon and the positive impacts they've had on YS.
Last week two new language bindings were added to the YS family: Go and Julia.
Well now, what happened is, uh, one of our data scientists, uh, well, he went a little funny in the head. You know. Just a little funny. And uh, he went and did a silly thing.
Well, I'll tell you what he did. He started chatting with computers... in YAML.
Well, let me finish, Elon.
Let me finish, Elon.
Well, listen, how do you think I feel about it?
It's been a while since I let you know what's been happening with YS. I've been busy working on it every day this year and I have a lot to tell you about!
Let me start by telling you about some of the events that have happened in the YS world recently.
Finally I'm presenting a talk about YS at the Open Source Summit North America this Thursday, April 18th. Super excited about that!
Do you remember the first time you wrote a program in a new language? For YS, mine was yesterday!
This is my first post of 2024. I've been working on YS non-stop since the last YS Advent 2023 post. Too busy to write a blog post, I guess.
Yesterday something awesome happened.
Putting out a YS release is a complicated process. It takes me about an hour to do it. Of course I plan to automate it fully but I just haven't had the tuits.
For the last several releases, I've had a text file that listed all the steps so that I wouldn't forget anything. Yesterday I automated that list...
...you guessed it...
...in YS!
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.