Fysh

From Esolang
Jump to navigation Jump to search
Not to be confused with ><>.

Fysh is an esoteric programming language that embraces creativity and a playful aquatic theme. It uses fish-related symbols and terms to represent programming concepts, making coding a fun and engaging experience. It was invented by User:Pointless & User:PinesLover69 in 2024.

For a cleaner documentation check out the GitHub README

πŸ‘©β€πŸ’» How to Compile and Run Fysh

βš™οΈ Option 1: Using The Online Interpreter

1. Visit The Official Webpage

2. Press Play

  • Write your code and press the swim button


βš™οΈ Option 2: Using VSCode

1. Download the Fysh VSCode Extension

  • Install the Fysh extension from the VSCode marketplace.

2. Create a .fysh File

  • Open VSCode and create a new file with the extension .fysh.

3. Write Your Code

  • Start coding in Fysh!

4. Run Your Code

  • Press the run button provided by the extension to execute your program.


βš™οΈ Option 3: Using Command Line

1. Install the Latest Version of Fysh

  • Use the Go command to install Fysh:
go install github.com/Fysh-Fyve/fysh/pkg/go-fysh/cmd@latest

2. Execute Your Fysh Program

  • Run your program using the generated Fysh interpreter:
fysh <filename>.fysh


πŸ™ Fyshing Manual

πŸ’¬ Chapter 1: Comments

πŸ”‰ Single-line Comments

Single-line comments start with navigator fish ><//>.

><//> What's cookin' good lookin'?

πŸ”Š Multi-line Comments

For longer explanations, multiline comments are used. They are enclosed with ></*> and <*\><

></*>
How to grill a Fysh:
1. Catch a Fysh
2. Grill the Fysh
3. Eat the Fysh
<*/><


🐠 Chapter 2: Fysh Syntax

🐟 Variables

In Fysh, variables are declared using the syntax ><variableName>. Every line of Fysh code ends with a tilde ~.

Example:

><Steven> ~

πŸ‘‰πŸ» Assigning Values

Variables can be assigned values using either the β‰ˆ or = operator.

Example: Steven is assigned the value of CoolFysh:

><Steven> β‰ˆ ><CoolFysh> ~

πŸ”Ÿ Binary Scales

A fysh's scales represents it's binary value ><})}>:

  • Scales Representing Binary 1: { and }
  • Scales Representing Binary 0: ( and )
Note: The direction of the scales does not matter. { and } both represent binary 1, and ( and ) both represent binary 0.

Example:

Here we assign the binary value 0b101 (5 in decimal) to Steven:

><steven> β‰ˆ ><})}> ~ 

πŸ‘οΈ Optional Visuals

><})}> is blind, but we can give it eyes... multiple eyes! πŸŸπŸ‘€

Valid Eye Symbols: o, Β°

Note: This is completely optional and purely for aesthetics.
><steven> β‰ˆ ><})}Β°>   ~
><steven> β‰ˆ ><{({Β°>   ~
><steven> β‰ˆ ><{({o>   ~ 
><steven> β‰ˆ ><{({°°>  ~
><steven> β‰ˆ ><{({oΒ°>  ~
><steven> β‰ˆ ><}({Β°oΒ°> ~


βž• Chapter 3: Arithmetics

βž• Addition

To add two fyshes, place variables or values next to each other. The value of a school of Fysh is the sum of each member.

Example: steven = 4 + 1 (binary: 0b100 + 0b001)

><steven> β‰ˆ ><{((Β°> ><(({Β°> ~

In this example:

  • ><{((Β°> represents 0b100 (4)
  • ><(({Β°> represents 0b001 (1)
  • steven is assigned 4 + 1 = 5

βž– Subtraction

Some fysh are negative and start to swim away. Fysh swimming to the left take away from the school's value.

Note: Fysh swim to the left flips the sign of the fysh. So a negative variable swimming left will become positive.

Example: steven = 7 - 2 (binary: 0b111 * 0b010)

><steven> β‰ˆ ><{{{Β°> <Β°)})>< ~ 

❀️ Multiplication

Fysh often get lonely. This loneliness causes fysh to meet new fysh and proliferate, quickly multiplying their numbers.

Note: Every possible representation of a heart is valid for multiplication. If there's a heart that doesn't work, please let us know.

Example: steven = 6 * 7 (binary: 0b110 * 0b111)

><steven> = ><{{(Β°> <3 ><{{{Β°> ~
><steven> β‰ˆ ><{{(Β°> β™‘ ><{{{Β°> ~
><steven> β‰ˆ ><{{(Β°> πŸ’˜ ><{{{Β°> ~

πŸ’” Division

Not every fysh story is a happy one. At times, separation is inevitable, and their division breaks their hearts, causing their numbers to dwindle. Division is represented by a broken heart </3 or πŸ’”.

Example: Steven = 25 / 5 (binary: 0b11001 / 0b101)

><steven> β‰ˆ ><{{(({Β°> </3 ><{({Β°> ~
><steven> β‰ˆ ><{{(({Β°> πŸ’” ><{({Β°> ~

🎣 Fysh Bowls (Parentheses)

Fysh are often abducted and kept in small glass fysh bowls for the amusement of land-dwellers. These bowls are represented by ( ). This is used to group fysh together, allowing their operations to be performed first.

Example: steven = 5 / (5 * 4) (binary: 0b101 / (0b101 * 0b100))

><steven> β‰ˆ ><{({Β°> πŸ’” ( ><{({Β°> <Β°}))>< ) ~

πŸ“ˆ Increment

As life goes on, we learn from our mistakes and improve. Steven’s self help journey allowed them to grow an extra tail, incrementing their value by 1.

Example: steven = steven + 1

>><steven> ~

πŸ“‰ Decrement

Sometimes we feel like a fyshup, a failure. And that's ok, it’s a part of being fysh. However for some fysh, this feeling is too much to handle and is internalized. They haven’t received the emotional support they need and have gone on a downward spiral, causing them to feel worthless. They begin to retreat and try to swim away in the opposite direction causing their value to decrement by 1.

Example: steven = steven - 1

<steven><< ~

🍒 Random Number Generation

The random number generator is represented with a grilled fysh. It generates a random signed 32-bit number that determines the doneness of the fysh.

Example:

><###> ~


πŸ“Š Chapter 4: Data Types

πŸ“ Integers

Fysh with binary scales ><})}> are integers.

Example: Steven = 5 (binary: 0b101)

><steven> β‰ˆ ><{({Β°> ~

🦴 Floats with One Bone

Some people like to play with their food, so they pick away at steven, leaving only a fraction of them behind. This exposes the bones (-) of the fysh. Bones help to separate the integer and decimal parts of the fysh.

Example:

><steven> β‰ˆ ><{{{-{({Β°> ~

Explanation:

  • ><{{{- represents the integer part 7 (binary: 0b111)
  • -{({Β°> represents the fractional part 0.5 (binary: 0b101)
  • Steven's value is 7 + 0.5 = 7.5.

🦴🦴🦴 Floats with Multiple Bones

When multiple bones are present, the additonal values are added at the end of the decimal part. Steven's value is 2 + 0.15 + 0.005 = 15.155.

Example:

><steven> β‰ˆ ><{(-{{{{-{{{Β°> ~

Explanation:

  • ><{(- represents the integer part 2 (binary: 0b10)
  • -{{{{- represents the fractional part 0.15 (binary: 0b1111)
  • -{{{Β°> represents the additional fractional part 0.007 (binary: 0b111)
  • steven's value is 2 + 0.15 + 0.007 = 2.157.

🫧 Bubbles (Strings)

Fysh blow bubbles, and these bubbles can be used to represent strings. Bubble strings are enclosed in 🫧 or *.

Example:

><steven> β‰ˆ 🫧Hello, World!🫧 ~
><steven> = *Hello, World!* ~

πŸ“¦ Arrays and Traversal

Arrays are represented by a fysh tank [ ]. Each item is separated by fysh food *.

Example: steven = [6,2] (binary: [0b110, 0b010])

><steven> β‰ˆ [><{{(Β°> * ><({(Β°>] ~

To access array elements, use the array variable followed by [index].

Note: Array indexes start at 0.

Example: steven[1] (accessing the second element of steven)

><steven>[><(({Β°>] ~

βš“ Chapter 5: Output

⛓️ Output Value

To output the value of a variable, use an anchor (+o or βš“.

Example: Output the value of Steven:

(+o ><{({Β°> ~


🧠 Chapter 6: Fysh Logic and Operations

🐸 Tadpoles

The greater than and less than operations are represented by tadpoles ~o and o~. Tadpoles swim towards the bigger Fysh, indicating the direction of the comparison.

Example:

><//> Greater/Less than
><steven> o~ ><{({Β°> ~    ><//> Steven > 1
><steven> ~o ><{{{Β°> ~    ><//> Steven < 7

><//> Greater/Less than or equal to (replace ~ with β‰ˆ or =)
><steven> oβ‰ˆ ><{({Β°> ~    ><//> Steven >= 1
><steven> =o ><{{{Β°> ~    ><//> Steven <= 7

πŸ€” Logical Operations

Fysh supports standard logical operations:

  • AND: &&
  • OR: ||
  • NOT: !!

Example:

><steven> && ><Alive> ~   ><//> Steven and Alive
><steven> || ><Alive> ~   ><//> Steven or Alive
!! ><steven> ~            ><//> Not Steven

πŸ”§ Bitwise Operations

Steven is bored and looking to have their bits rearranged. At Fysh, we're here to help! Steven has been provided with a variety of tools and bitwise manipulations to satisfy their bit busting needs:

  • AND (&)
  • OR (|)
  • XOR (^)
  • NOT (!)
Note: Currently does not support floats
><steven> & ><(({Β°> ~  ><//> Steven and 1
><steven> | ><(({Β°> ~  ><//> Steven or 1
><steven> ^ ><(({Β°> ~  ><//> Steven xor 1
! ><steven> ~          ><//> Not Steven

πŸ”„ Logical Shift Operations

You can even use logical shifts! Steven shifts their bits to the left then right by 1.

  • Left shift (<<):
  • Right shift (>>):
Note: Currently does not support floats

Example:

><steven> << ><(({Β°> ~   ><//> Steven left shift 1
><steven> >> ><(({Β°> ~   ><//> Steven right shift 1


πŸ”„ Chapter 7: Control Structures

πŸ” While Loops

While loops can be represented using whirlpools:

  • @
  • πŸŒ€
  • ><(((@>

The condition stored in either:

  • ( ) fysh bowl
  • [ ] fysh tank

The loop body is enclosed between ><> and <><.

Example:

πŸŒ€ [><steven> o~ ><{((Β°>]            ><//> while steven > 4
><>
    <steven><< ~                    ><//> steven--
<><

@ (><steven> ~o ><{((Β°>)            ><//> while steven < 4
><>
    >><steven> ~                    ><//> steven++
<><

><(((@> [><steven> oβ‰ˆ ><{((Β°>]      ><//> while steven >= 4
><>
    <steven><< ~                    ><//> steven--
<><

❓ Conditional Statements

Conditional statements run based on how each Fysh feels

😊 if Statements: The Happy Fysh ><(((^>

These Fysh are overjoyed because they're the center of attentionβ€”they feel wanted and loved.

Example:

><(((^> [><steven> o~ ><{((Β°>]     ><//> if steven > 4
><>
    <steven><< ~                   ><//> steven--
<><
😡 else Statement: The Sad (Dead) Fysh ><(((*>

These fysh feel like they're an afterthought and are often left behind. This makes them feel sad and dead inside.

Example:

><(((*>                      ><//> else
><>
    ><steven> β‰ˆ ><(((Β°> ~    ><//> steven = 0
<><
😐 else if Statement: The Middle Child ><(((*> ><(((^>

These fysh are a combination of a dead and a happy fish, symbolizing the middle child. Not the first choice but not the last.

><(((*> ><(((^> [><steven> ~o ><{((Β°>]     ><//> else if steven < 4
><>
    >><steven> ~                           ><//> steven++
<><


πŸ§‘β€πŸ”§ Chapter 8: Functions

✏️ Defining Functions

Functions (subroutines) are defined using a submarine >(functionName), with parameters ><param>. The function body is enclosed between ><> and <><. To return a value, use a squid <~ or πŸ¦‘.

Example:

>(add) ><param1> ><param2>       ><//> def add(param1, param2)
><>
    <~ ><param1> β™‘ ><param2> ~  ><//> Return the product of param1 and param2
<><

πŸ“ž Calling Functions

To call a function, place the submarine in a fish tank [ ], along with its arguments, separated by fish food -.

Note: The submarine can be placed anywhere in the fish tank as long as the arguments are in the correct order.

Example:

[>(submarine) ><fysh1> * ><fysh2>] ~     ><//> submarine(fysh1, fysh2)


πŸ“ˆ Examples

❗Factorial Example

This program calculates the factorial of a number, in this case, 5. The factorial of 5 is 120.

><//> Factorial Example

><number>    β‰ˆ ><{({Β°> ~                        ><//> number = 5
><factorial> β‰ˆ ><(({Β°> ~                        ><//> factorial = 1

πŸŒ€ [><number> o~ ><(({Β°>]
><>
    ><factorial> β‰ˆ ><factorial> β™‘ ><number> ~   ><//> factorial = factorial * number
    <number><< ~                                ><//> number--
<><

βš“ ><factorial> ~                               ><//> print(factorial)

Explanation:

1. Variable Declarations:

  • ><number> β‰ˆ ><{({Β°> ~ assigns 5 to number.
  • ><factorial> β‰ˆ ><(({Β°> ~ assigns 1 to factorial.

2. While Loop:

  • πŸŒ€ [><number> o~ ><(({Β°>] loops while number > 1.
  • Inside the loop:
    • Multiply factorial by number.
    • Decrement number.

3. Output:

  • βš“ ><factorial> ~ outputs the calculated factorial.

πŸ”Fibonacci Example

This program calculates the nth Fibonacci number, in this case, the 7th. The 7th Fibonacci number is equal to 13.

><//> Fibonacci Example

>(fib) ><n>                            ><//> def fib(n)
><>
    ><(((^> [><n> ~o ><({(Β°>]          ><//> if n < 2
    ><>
        πŸ¦‘ ><n> ~                      ><//> Return 'n' if 'n' < 2
    <><
    ><(((*>                            ><//> else
    ><>
        ><a> β‰ˆ [>(fib) ><n> <({><] ~   ><//> a = fib(n * 1)
        ><b> β‰ˆ [>(fib) ><n> <{(><] ~   ><//> b = fib(n * 2)
        πŸ¦‘ ><a> ><b> ~                 ><//> Return a + b
    <><
<><

><result> β‰ˆ [>(fib) ><{{{Β°>] ~         ><//> result = fib(7)
βš“ ><result> ~                         ><//> print(result)

Explanation:

1. Function Definition:

  • >(fib) ><n> defines the function fib with parameter n.
  • If n is less than 2:
    • Return n.
  • Else:
    • Compute a = fib(n * 1).
    • Compute b = fib(n * 2).
    • Return a + b.

2. Function Call:

  • ><result> β‰ˆ [>(fib) ><{{{Β°>] ~ calls fib(7) and assigns the result to result. result = fib(7)

3. Output:

  • βš“ ><result> ~ outputs the 7th Fibonacci number (13).

External Resources


Happy Fyshing! 🐟