Science Fair Project Encyclopedia
FiPL
Fipl (Fish Programming Language) is an esoteric programming language, exploiting the "new programming paradigm" - "incidental programming". This language is mostly a joke, invented as a parody on a concept of programming language paradigm. Everything that's going on here happens inside the "Fish" - the colorful picture of fish with named scales, every one of which can be colored in any of 16777216 colors. When a scale changes its color this event is called an incident.
| Contents |
|
|
Overview
The language does not exist by itself, but it is a set of the following elements:
- FIDE – Fish Integrated Development Environment;
- FCW – Fish Colorful Workspace;
- FVM – Fish Virtual Machine;
- FiPL (pronounced F-ee-pl) – Fish Programming language;
Alltogether these elements are called FUPE - Fish Underwater Programming Environment.
Fish Colorful Workspace (FCW) may be seen as both the FUPE’s memory space and the IO console. It consists of 52 Fish scales numbered from 0 to 51 and 5 Fish tails numbered from 1 to 5. Scales and tails can be referred to following the convention: scale’s name is in the interval S0-S51, tail’s name is in the interval T1-T5.
In the figure below you can see the layout of the scales and tails on the FCW:
The FiPL language and its environment are explained in the book : "Fish Programming in a Nutshell"
Fish Virtual Machine
Fish Virtual Machine (FVM) is a driving force of the FUPE. It executes the program written in FiPL and displays the results on FCW.
The lifecycle of FVM consists of the infinite number of consequent stages, called Fish Cycles.
The first cycle of Fish’s life begins when the programmer starts a program (by pressing the Run button in FIDE, for example). The colors of all the FCW scales and tails at the first stage will be determined by the initial color assignments made by the programmer. If two assignments are made at the same cycle, they cannot influence one another. Let’s look at the example:
S1 is RED; T1 is like S1;
In an iterative language, one can expect T1 to become RED (like S1). But in the Fish language these two assignments are made on the same cycle; that means, change in the S1’s color will not alter the T1’s color. Instead, T1 will be assigned the previous color of S1. On the next cycle, S1 will become RED and T1 will be colored by the previous S1’s color.
FVM is said to perform an atomic execution within one cycle: everything happens simultaneously, as an atomic operation, and what matters to the next cycle is only the final color state of all the scales together.
Once, all the colors of FCW are determined and displayed, the Fish is advanced to the next cycle.
Fish Integrated Development Environment
FIDE (Fish Integrated Development Environment) which runs as an applet written in the Java programming language allows the user to edit the program, compile it and run. The results of the running program are immediately displayed on the Fish.
Short Language Description
Assignments
Assignments (is,are) are the basic constructions of FiPL that are used to assign colors to scales in the FCW and to declare all other language entities. For example:
S1 is (1,2,3); S2 is flip-flop of (1,1,1) and (2,2,2); I is incident when somebody becomes (R,G,B); S1,S2,S3 are buddies;
Buddies, Horde and All the Fish
- A most convenient way to refer to a number of scales is by organizing them into a group called horde. Then, these scales can be referred to by their horde’s name.
- Defining several scales to be buddies will make them to share the same color and the same behaviour. Any change of one of the buddies group member will immediately take effect on all other members of the group.
- All the fish keyword simply denotes all the FCW without tails, i.e. all scales. Thus the all-the-fish assignment will be applied to all the scales of FCW.
Examples:
S20,S25,S47 are horde DreamTeam; DreamTeam is RED; S10,S20,S30,S40,S50 are buddies; all the fish is haphazard;
Scale and Tail color arithmetic
FiPL has a plethora of predefined colors that can be used in the language constructions. The keywords for predefined colors are spelled in upper case with underscore separating words in a name of the color. For example:
ALICE_BLUE, DARK_GOLDEN_ROD, HONEY_DEW etc.
Otherwise, the arbitrary color can be defined with the syntax (R,G,B) where R, G and B are numbers within the interval 0-255 denoting the Red, Blue and Green components of the color accordingly. Thus, an assignment of a color to a scale or tale is performed like this:
S1 is (233,150,122); T1 is (255,239,213); S25 is DARK_SALMON;
There are only two operations allowed on the scales’ color: addition and subtraction. When an operation is performed, the R,G and B components of a scale(tail) are added(subtracted) one by one (only two terms are allowed per operation). The operations can be used as shown in the following examples:
S0 is like S0 + (35,47,64); S0 is like T1 – (45,87,90); T5 is SANDY_BROWN + (100,100,100); T2 is like S50 + TURQUOISE; S45 is SPRING_GREEN – PEACH_PUFF;
Flip-Flops and Haphazards
- Flip-flop is a scale that will periodically switch its color at every cycle. The switch will be performed between two colors specified in the flip-flop’s declaring statement. Flip-flops are important means for generating incidents. They may serve as a clock triggering incidents on each cycle of FVM.
- A scale declared as a haphazard will get randomly chosen color.
Examples:
S1 is flip-flop of FUCHSIA and TURQUOISE; S5 is haphazard;
Incidents, Aftermaths, Commands and Apprentices
Incidents, Aftermaths, Commands and Apprentices together form the most important FiPL construction. They are the driving force under the incidental programming.
Incident is the basic concept of the FVM lifecycle. It happens always when any scale’s color changes. Thus, at a single stage many incidents may happen simultaneously. However, not all of them will be treated. To treat an incident one should declare the aftermath or command of this incident, that is the actions that will take place after the incident occurs. Master of an incident is a scale that causes this incident.
Incidents are divided into concrete and abstract incidents. Concrete incident is the incident explicitly specifying its master. For example:
S0SpringGreen is incident when S0 becomes SPRING_GREEN;
Here S0 is a master of this incident. The incident itself occurs once S0 gets the SPRING_GREEN color.
For an incident to have a meaning is to declare an aftermath (or a command) of it, i.e. the set of actions that will take place once this incident occurs. Let’s consider the S0SpringGreen incident declared above. Thus, the following aftermath can be declared:
WhiteBlack is aftermath of S0SpringGreen as follows [
S1 will be WHITE;
S2 will be BLACK;
]
When S0SpringGreen occurs (i.e. S0 becomes SPRING_GREEN) S1 and S2 will be colored to WHITE and BLACK accordingly without any conditions.
The notion of command involves both master and apprentice roles. In this case an incident declared abstract, using the somebody keyword instead of specifying the master scale. For example:
MediumOrchid is incident when somebody becomes MEDIUM_ORCHID;
That means, any scale becoming MEDIUM_ORCHID will produce the MediumOrchid incident, but only those having apprentices will be able to issue a command. For example:
BeLikeYourMaster is command as follows [
apprentice will be like master;
]
Note, that the command itself is not related to any incident ! The declaration of apprentice will connect both incident and command together. For example:
S50 is apprentice of S49 doing BeLikeYourMaster after MediumOrchid;
This statement literally means: when S49 becomes MEDIUM_ORCHID it will issue the BeLikeYourMaster command for S50, then S50 becomes MEDIUM_ORCHID (like master, as the command says).
Thanks For All the Fish
Operator thanks for all the fish, once encountered, will completely stop the Fish Virtual Machine.
Examples
In the following example the FVM will stop once s50 eventually becomes TOMATO:
S1 is flip-flop of BLACK and WHITE; /* s1 serves as a clock */
BlackEvent is incident when S1 becomes BLACK;
Cycle1 is aftermath of BlackEvent as follows [
S50 is haphazard; /* change s50’s color */
]
WhiteEvent is incident when S1 becomes WHITE;
Cycle2 is aftermath of WhiteEvent as follows [
S50 is haphazard; /* change s50’s color again */
]
TomatoEvent is incident when S50 becomes TOMATO;
EndProgram is aftermath of TomatoEvent as follows [
thanks for all the fish; /* stop the FVM */
]
Now you will see how to organize a loop in FiPL:
/* Infinite loop of four steps */
s0 is (0,0,0);
Trigger1 is incident when s0 becomes (0,0,0);
Step1 is aftermath of Trigger1 as follows [
s0 is (1,0,0);
]
Trigger2 is incident when s0 becomes (1,0,0);
Step2 is aftermath of Trigger2 as follows [
s0 is (2,0,0);
]
Trigger3 is incident when s0 becomes (2,0,0);
Step3 is aftermath of Trigger3 as follows [
s0 is (3,0,0);
]
Trigger4 is incident when s0 becomes (3,0,0);
Step4 is aftermath of Trigger4 as follows [
s0 is (0,0,0); /* back to incident Trigger1 */
]
External Links
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details


