Modern languages, though powerful, can be monolithic in scope—the Swift Programming Language clocks in at over 1000 pages! When I sat down to develop Yo, my goal was to insure its guide could fit inside a smartly edited tweet.
Clearly I failed.
But thanks to the folks at Medium, I found a happy medium at Medium which is not only named appropriately — not too large, and not too small—but also rhymes with tedium, which you certainly will not feel reading a single page post that describes this amazing, compact new programming language.
Thanks to Kernighan & Ritchie, no programming guide is complete without an introductory short program demonstrating how to print out “hello world,” even though you’d think—after 40 years—the concept of printing text to a teletype to be so archaic that the tradition would have gone the way of brown plaid pantsuits and other wonders of 1974.
But it hasn’t.
Anyway, let’s get to it:
In Yo, this single line is a complete program. Like Swift, Yo uses a global scope as the entry point, so no main is required, which is good because the word main sounds weird to me and I’m pretty sure you can’t define it without using it in the definition.
Semicolons are also not required to terminate a line in Yo, though having just read Nobody. Understands. Punctuation., I’m inspired to find new opportunities to use the semicolon when I write; I do feel bad about its omission in Yo.
Finally, indentation in Yo is optional and completely up to you, but I would avoid it like the plague. Especially if you code on a mobile device.
Variables, operators and types
In Yo, there are no variables, operators or types. There are only constants, and they are dynamically typed and coerced into uppercase strings against their will at compile time. They are also, for no practical reason at all, limited to eight characters in length.
Use huh to define a constant:
huh raise?1mil // set raise to MIL
huh messy?"my dog, poor dog" // set messy to MYDOGPOO
huh phaser?stun // set phaser to STUN
Constants in Yo can be used only as parameters to functions, and nowhere else, meaning they are typesafe and probably only useful for lazy typists.
Note: there is room for debate about the practicality of constants in Yo, but that room is not here.
Thanks to our helpful little hello world program up there (oh I get it now; sorry, K&R!) you are already familiar with the one and only function in Yo.
Use yo to send a notification from one user to another user:
yo~RITCHIE>KERNIGHAN // send from RITCHIE to KERNIGHAN
yo~RITCHIE // ditto
huh ayy?Fonzie // (wtf more jokes from 1974?)
yo~ayy>RITCHIE // send from FONZIE to RITCHIE (yup)
If the from user doesn’t exist, a new user will be created at runtime. Yes, this is probably a security hole, but please, try to send messages from your actual username.
As you can see above, the to user is an optional parameter; if not included it will default to the last user you bothered.
Yo has been almost 45 minutes in the making, and most of that time has been trying to figure out how to embed code blocks in Medium.
Nevertheless, it has been thrilling to design such a syntactically terse and sparse programming language, and I hope Yo inspires others to program and build insanely great—but super small—apps.
Thank you for reading this first edition of this guide. If you want to get in touch in as hands-off a fashion as possible, I am DANNYE on Yo (the app not the programming language, which I totally made up).