(→Example Programs: linked to mane method article) |
(→Example Programs: stupid editing errors) |
||
Line 20: | Line 20: | ||
A program that uses two methods, a [[mane method]] and a utility method, to add all the numbers from 1 to 100: |
A program that uses two methods, a [[mane method]] and a utility method, to add all the numbers from 1 to 100: |
||
− | {{codeblock|{{code|keyword|Dear}}{{code|whitespace| }}{{code|class|Princess Celestia}}{{code|punctuation|:}}{{code|whitespace| }}{{code|class|I can add}}{{code|punctuation|!}}{{code|whitespace|<BR/><BR/>}}{{code|keyword|<STRONG>Today</STRONG> I learned}}{{code|whitespace| }}{{code|method|how to add a lot}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|Did you know that}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|the answer}}{{code|whitespace| }}{{code|keyword|was}}{{code|whitespace| }}{{code|method|how to add}}{{code|whitespace| }}{{code|keyword|using}}{{code|whitespace| }}{{code|literal|1}}{{code|whitespace| }}{{code|keyword|and}}{{code|whitespace| }}{{code|literal|100}}{{code|punctuation|?}}{{code|whitespace|<BR/>}}{{code|keyword|I said}}{{code|whitespace| }}{{code|variable|the answer}}{{code|punctuation|!}}{{code|whitespace|<BR/>}}{{code|keyword|That's all about}}{{code|whitespace| }}{{code|method|how to add a lot}}{{code|punctuation|.}}{{code|whitespace|<BR/><BR/>}}{{code|keyword|I learned}}{{code|whitespace| }}{{code|method|how to add}}{{code|whitespace| }}{{code|keyword|with}}{{code|whitespace| }}{{code|type|a number}}{{code|whitespace| }}{{code|keyword|using}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|first}}{{code|whitespace| }}{{code|keyword|and}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable| |
+ | {{codeblock|{{code|keyword|Dear}}{{code|whitespace| }}{{code|class|Princess Celestia}}{{code|punctuation|:}}{{code|whitespace| }}{{code|class|I can add}}{{code|punctuation|!}}{{code|whitespace|<BR/><BR/>}}{{code|keyword|<STRONG>Today</STRONG> I learned}}{{code|whitespace| }}{{code|method|how to add a lot}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|Did you know that}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|the answer}}{{code|whitespace| }}{{code|keyword|was}}{{code|whitespace| }}{{code|method|how to add}}{{code|whitespace| }}{{code|keyword|using}}{{code|whitespace| }}{{code|literal|1}}{{code|whitespace| }}{{code|keyword|and}}{{code|whitespace| }}{{code|literal|100}}{{code|punctuation|?}}{{code|whitespace|<BR/>}}{{code|keyword|I said}}{{code|whitespace| }}{{code|variable|the answer}}{{code|punctuation|!}}{{code|whitespace|<BR/>}}{{code|keyword|That's all about}}{{code|whitespace| }}{{code|method|how to add a lot}}{{code|punctuation|.}}{{code|whitespace|<BR/><BR/>}}{{code|keyword|I learned}}{{code|whitespace| }}{{code|method|how to add}}{{code|whitespace| }}{{code|keyword|with}}{{code|whitespace| }}{{code|type|a number}}{{code|whitespace| }}{{code|keyword|using}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|first}}{{code|whitespace| }}{{code|keyword|and}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|last}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|Did you know that}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|sum}}{{code|whitespace| }}{{code|keyword|was}}{{code|whitespace| }}{{code|literal|0}}{{code|punctuation|?}}{{code|whitespace|<BR/>}}{{code|keyword|As long as}}{{code|whitespace| }}{{code|variable|first}}{{code|whitespace| }}{{code|operator|was no more than}}{{code|whitespace| }}{{code|variable|last}}{{code|punctuation|,}}{{code|whitespace|<BR/>}}{{code|variable|sum}}{{code|whitespace| }}{{code|keyword|became}}{{code|whitespace| }}{{code|variable|sum}}{{code|whitespace| }}{{code|operator|plus}}{{code|whitespace| }}{{code|variable|first}}{{code|punctuation|.}}{{code|punctuation|.}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|variable|first}}{{code|whitespace| }}{{code|operator|got one more}}{{code|punctuation|.}}{{code|whitespace|<BR/>}}{{code|keyword|That's what I did}}{{code|punctuation|!}}{{code|whitespace|<BR/>}}{{code|keyword|That's all about}}{{code|whitespace| }}{{code|method|how to add}}{{code|punctuation|!}}{{code|whitespace|<BR/><BR/>}}{{code|keyword|Your faithful student}}{{code|punctuation|,}}{{code|comment| Kyli Rouge}}{{code|punctuation|.}}}} |
=== Mirror in Java === |
=== Mirror in Java === |
||
Line 41: | Line 41: | ||
} |
} |
||
− | public static double howToAdd(double |
+ | public static double howToAdd(double first, double last) { |
double sum = 0; |
double sum = 0; |
||
− | while ( |
+ | while (first <= last) { |
sum = sum + theFirst;;; |
sum = sum + theFirst;;; |
||
− | + | first++; |
|
} |
} |
||
} |
} |
Revision as of 22:48, 25 October 2012
FiM++ (AKA Friendship Reports) is a programming language inspired by Friendship Reports, Java and Shakespeare, whose syntax is not dissimilar to that of ALGOL. The main goal of FiM++ is to be readable by humans, to the point that a well-written FiM++ program could be mistaken to be a mere letter.
Structure
The general structure of a FiM++ program is class-based. That is, code is organized in individual files, called classes. Within each file, there are imports that help reference other classes, the class itself, methods, literals, variables, and constants.
History
- Feb 23, 2011: The first ideas of a programming language pop up in a Google Code repository. This project is abandoned June 12 of that same year.
- Oct 4, 2012: Cereal Velocity makes a post about FiM++ on Equestria Daily.
- Oct 4, 2012: DeftCrow on deviantART creates the first real program in FiM++, 99 Jugs of Cider and Hello World. This works out some inconsistencies and sets the stage for a fully-fledged language.
- Oct 5, 2012: An admin on Equestria Forever named Twilight Sparkle makes a forum post about the aforementioned posts, also detailing some more propositional features of the language.
- Oct 11, 2012: Supuhstar (AKA Kyli Rouge) asks permission from DeftCrow and Cereal Velocity to make a formal document fully specifying the language.
- Oct 18, 2012: This wiki is created when the document becomes too daunting to scroll through.
Versions
Currently, there is only one official version, which is 1.0, codename “Sparkle”. That is the version that this wiki details.
Example Programs
A program that simply uses one method to print "Hello World" and exits:
Dear
Princess Celestia
:
Hello World
!
Today I learned
how to say hello world
!
I said
“Hello, World!”
!
That's all about
how to say hello world
.
Your faithful student
,
Kyli Rouge
.
A program that uses two methods, a mane method and a utility method, to add all the numbers from 1 to 100:
Dear
Princess Celestia
:
I can add
!
Today I learned
how to add a lot
.
Did you know that
the number
the answer
was
how to add
using
1
and
100
?
I said
the answer
!
That's all about
how to add a lot
.
I learned
how to add
with
a number
using
the number
first
and
the number
last
.
Did you know that
the number
sum
was
0
?
As long as
first
was no more than
last
,
sum
became
sum
plus
first
.
.
.
first
got one more
.
That's what I did
!
That's all about
how to add
!
Your faithful student
,
Kyli Rouge
.
Mirror in Java
FiM++ can be translated into Java relatively easily. Here's the above Hello World example in Java:
public class HelloWorld extends Object {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
And here's the above addition program:
public class ICanAdd extends Object {
public static void main(String[] args) {
double theAnswer = howToAdd(1, 100);
System.out.println(theAnswer);
}
public static double howToAdd(double first, double last) {
double sum = 0;
while (first <= last) {
sum = sum + theFirst;;;
first++;
}
}
}