splang

From Esolang
Jump to navigation Jump to search

splang is an new esoteric programming language created and being developed by Cernam (talk). It is pronounced "splang", it really isn't difficult.



splang's logo is an animated svg, which will not render here. Check out the writeup, github, or PyPI page for the full logo.

splang's logo

Language Overview

splang is written in the form of a playlist. Each song's duration X:YZ, has YZ correspond to a specific opcode which enables a playlist to be treated as a sequence of instructions. As such, it is possible to create a playlist which is both an auditory experience as well as performs some computable action.

How it works

Keyterm Description
LS Last Second’s place, e.g. 3:45 → 5
FS First Second’s place, e.g. 3:45 → 4
TrackID The unique ID of a song in Spotify’s database.
(song + n) The song n positions after the current song in the playlist.
Stack A LIFO data structure, operates on single elements.
Heap A data structure that stores values at a specific index, operates on single elements.
RA Stack A LIFO data structure that stores return addresses for function calls.
Time Command Parameter(s) Description
0:00 NOP None No operation, does nothing.
0:01 HALT None Halts the program.
0:02 LABEL 1 Label, defines the (song + 1)’s trackID as a label.
0:03 JUMP 1 Jumps to the label defined by the (song + 1) trackID.
0:04 JUMPZ 1 Jumps to the label defined by the (song + 1) trackID if the top of the stack is 0.
0:05 JUMPNZ 1 Jumps to the label defined by the (song + 1) trackID if the top of the stack is not 0.
0:06 JUMPZ_HEAP 1 Jumps to the label if the value at the heap index defined by the (song + 1) trackID is 0.
0:07 JUMPNZ_HEAP 1 Jumps to the label if the value at the heap index defined by the (song + 1) trackID is not 0.
0:08 CALL 1 Pushes return address to RA stack and jumps to the label.
0:09 RETURN None Pops return address from RA stack and jumps to it.
0:10 ADD None Adds top two stack elements and pushes result.
0:11 SUB None Subtracts top two stack elements and pushes result.
0:12 MUL None Multiplies top two stack elements and pushes result.
0:13 DIV None Divides top two stack elements and pushes result.
0:14 MOD None Modulus (b mod a) of top two stack elements and pushes result.
0:15 POW None Raises top element to the power of second top and pushes result.
0:16 Not_implemented None Not implemented.
0:17 Not_implemented None Not implemented.
0:18 Not_implemented None Not implemented.
0:19 Not_implemented None Not implemented.
0:20 PUSH_LS 1 Pushes LS of (song + 1) duration to stack.
0:21 PUSH_FS 1 Pushes FS of (song + 1) duration to stack.
0:22 SHIFT_R_LS 1 Shifts top stack value right, adds LS of (song + 1).
0:23 SHIFT_L_LS 1 Shifts top stack value left, adds LS of (song + 1).
0:24 SHIFT_R_FS 1 Shifts top stack value right, adds FS of (song + 1).
0:25 SHIFT_L_FS 1 Shifts top stack value left, adds FS of (song + 1).
0:26 POP None Pops top element of stack.
0:27 DUP None Duplicates top element of stack.
0:28 SWAP None Swaps top two elements of stack.
0:29 Not_implemented None Not implemented.
0:30 STORE 1 Stores top stack element in heap at (song + 1) trackID index.
0:31 STORE_TOP None Stores top stack element in heap at index of second element.
0:32 LOAD 1 Loads value from heap at (song + 1) trackID index to stack.
0:33 LOAD_TOP None Loads value from heap at top stack index to stack.
0:34 INC_HEAP 1 Increments value in heap at (song + 1) trackID index.
0:35 DEC_HEAP 1 Decrements value in heap at (song + 1) trackID index.
0:36 INC None Increments top stack element.
0:37 DEC None Decrements top stack element.
0:38 Not_implemented None Not implemented.
0:39 Not_implemented None Not implemented.
0:40 STDIN_INT None Reads integer from stdin and pushes to stack.
0:41 STDIN None Reads string from stdin, pushes each char as ASCII to stack.
0:42 STDOUT_INT None Pops and prints top stack element as integer.
0:43 STDOUT None Pops and prints top stack element as ASCII character.
0:44 READ_CHAR 1 Reads first char of (song + 1)'s title, pushes ASCII to stack.
0:45 LISTEN 1 Sleeps for full duration of (song + 1).
0:46 Not_implemented None Not implemented.
0:47 Not_implemented None Not implemented.
0:48 Not_implemented None Not implemented.
0:49 Not_implemented None Not implemented.
0:50 AND None Logical AND of top two stack elements.
0:51 OR None Logical OR of top two stack elements.
0:52 XOR None Logical XOR of top two stack elements.
0:53 NOT None Logical NOT of top stack element.
0:54 EQUAL None Pushes 1 if top two stack elements are equal, else 0.
0:55 NOT_EQUAL None Pushes 1 if top two stack elements are not equal.
0:56 GREATER None Pushes 1 if top > second top stack element.
0:57 LESS None Pushes 1 if top < second top stack element.
0:58 GREATER_EQUAL None Pushes 1 if top >= second top stack element.
0:59 LESS_EQUAL None Pushes 1 if top <= second top stack element.

Examples

Check out the writeup for more details on how these playlists are computed in splang.

HelloWorld

HelloWorld Playlist

Fibonacci

Fibonacci Playlist

External Links

Github

If you are interested in contributing, splang's github is here.

Writeup

If you want a more detailed understanding of splang, check out the writeup here.

Installation

If you are interested in installing a splang interpreter, check out its PyPI page here.