esolang

FiM++

Every program is a letter to Princess Celestia, about what its pony learned today.

Cereal Velocity, 2012 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 4 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: Hello, World!

The idea

FiM++ takes its name from Friendship is Magic, the subtitle of My Little Pony. Cereal Velocity, a blogger on Equestria Daily, published the idea on 4 October 2012, and a team of programmers from the show's fans completed it within the month. A program opens with Dear Princess Celestia: and signs off with Your faithful student, and a name. Functions are paragraphs, each about one thing the writer learned.

Read the story

The language grew in several directions at once, so interpreters disagree. Try It Online runs Karol Stasiak's interpreter in Scala, from the fimpp repository, and this implementation follows that one.

The machine

Values are 64-bit integers, strings, true and false (harmony and chaos), nothing, lists and books. A book is an array whose pages start at 1. Names may be several words long, and a keyword ends them, so Twilight Sparkle got one more. adds one to twilight sparkle. The words a, an and the are dropped from names, and a name that was never given a value is its own text, so I said Rainbow Dash. prints Rainbow dash.

SentenceDoes
Did you know that Spike likes 5?Assign; also is, are, like
I said Spike.Print with a newline; I quickly said prints without one
Spike got one more.Add; less and fewer take away
Rarity did the sum of Spike and 2.Call a paragraph or a built-in and keep the result
When Spike had more than 3: ... That's what I did.If, with In the end, I did this instead: as else
I did this while ...: I did this 5 times:Loops, ended by That's what I did.
I learned about f with n: ... That's about f with r.A paragraph with a parameter, returning r
On the first page of B I wrote X.Write a page of a book
By the way, ...A comment; , because ... adds one to any sentence

There is no arithmetic syntax. Sums, differences, products, quotients and remainders are built-in paragraphs. Numbers can be digits or the words zero to twelve.

Example

The third letter has a paragraph about factorials.
Expected: 12345
Expected: 3628800
Expected: Rainbow dash

The third letter has a paragraph about factorials. Its result is the variable named after with in its last line.

Patterns it teaches

  • Camouflage: the program reads as a letter, with paragraphs and a signature.
  • Turing completeness: books grow as far as they are written to, and loops run until a condition fails. The reference ships a Brainfuck interpreter written in it.

Try this

  1. Print the numbers 10 down to 1.
  2. Write a paragraph that returns the larger of two numbers.
  3. Hard: FizzBuzz. the remainder of n and 3 gives what is left over.

Further

Object-oriented paradigm

Write your own in Run Convert a program from FiM++

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: fimpp.

Command line

shib run fimpp -e 'Dear Princess Celestia: An example letter.

Today I learned about greetings:

I said "Hello, World!".

Your faithful student, Twilight Sparkle.'
shib manual fimpp

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/fimpp.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org