Prāsa Programming Language



Prāsa is an esoteric programming language that investigates the intersection of technology and cultural identity.



Culture and computing through cultural computing



Telugu is an alphasyllabary writing system with 16 vowels and 36 consonants, and a total of 576 syllable sounds.


telugu writing system

Telugu script |

source

telugu writing system

Telugu script |

source


With its expansive glyphs and distinct sounds, poetry in Telugu takes advantage of these systems and relies on rhymes and rhythms that can be performed.


At the same time, the grammar for writing poetry within Chandassu is also quite computational. There’s strict set of rules for writing poetry. Below is an example poem.



నిద్దుర మేలుకొమ్ము తరుణీ! అరుణారుణ రాగ మాలికల్

దిద్దుచునుండె బాలరవి దీప్తులు నీ నునుజెక్కుదోయిపై

ముద్దులు మూటగట్టెను ప్రముగ్ధ పయోరుహ పత్రనేత్ర!నీ

నిద్దపు నీలిముంగురులు నెన్నుదుటన్ నటనమ్మొనర్చుచున్



This is a poem that falls within the Vrutta Padyalu form, a category for 4 subforms with similar prose structure.



Translating poetic grammar as a programming language

1. Form

Prāsa’s movement is inspired by the Turing Tape, where the head can go from one cell to another. But unlike the TM, Prāsa’s tape only exists in the positive space. Cells start from 0 and can only move forward. Any new line that starts with an indentation indicates movement. Each level of indentation moves the cell that many cells forward.


This has been a key point within the process of building this language, as it connects the line from the technical function of the language to its form. Cell-based approach allows for a clear, yet strict set of rules to exist for this language, while leaving the space for creative freedom untouched.

Process sketch demonstrating the tokens in the language
Process sketch

Programs need not be linear, from left-to-right, top-to-bottom. Programs have the flexibility to start from the end of the cell and work its way backwards, or start from the center, move forward and come back again, or oscillate between the cells to play with the form of the program itself. Each empty space in Prāsa adds function. Meaning exists where words don’t.


Rise and fall rise and fall rise and fall. a song.

Excerpt from the HELLO, WORLD! program by Janani Venkateswaran

2. Grammar

In Prāsa, and in Telugu, syllables form the most foundational component. There’s long syllables, and short syllables



Then there are sets of gana. A set of 3 (sometimes 2) possible syllable sequences form a set. Short-long-short is the ja-ganam. Below are a list of all sets


sequencesnamesymbols
guruvu-laghuvu-laghuvubha-ganamU I I
laghuvu-guruvu-laghuvuja-ganamI U I
laghuvu-laghuvu-guruvusa-ganamI I I
laghuvu-guruvu-guruvuya-ganamI U U
guruvu-laghuvu-guruvura-ganamU I U
guruvu-guruvu-laghuvuta-ganamU U I
guruvu-guruvu-guruvuma-ganamU U U
laghuvu-laghuvu-laghuvuna-ganamI I I

Utpalamāla, Campakamāla, Mattēbham, and Śārdūlam are the four key forms of poetry within a category of poems called Vrutta Padyam. Prāsa uses these four grammatical forms within its implementation.


Utpalamāla

UII UIU III UII UII UIU IU
Length: 20

Campakamāla

III IUI UII IUI IUI IUI UIU
Length: 21

Mattēbham

IIU UII UIU III UUU IUU IU
Length: 20

Sārdūlam

UUU IIU IUI IIU UUI UUI U
Length: 19


To write a valid program in Prāsa, we are but forced to do the computation ourselves - an act of taking the agency back from the computer.


3. Outputs

Each cell value’s corresponding ASCII character is the output print.


Summing

With the Telugu Chandassu syllablic grammar implemented with the cell-based approach, computational values automatically fell into place. Number of syllables in a cell is the value of that cell. And since cells are defined by their indentations, two lines on the same level of indentation can be attributed to the same corresponding cell.


Scaling

Alphabets on the ASCII table do not start until 65. To make it easier to reach 65, while adding another level of complexity, Prāsa allows for multiplications in a cell. The intentions of this language have always been to stay as close to natural language as possible, and avoid any symbols that are characters that do not fit into standard written language. Parenthesis is a common-ground. They’re quite common in writing, and they can also bring in another layer of function to the language. If a cell starts with (, the number of syllables between the opening and closing parenthesis are multiplied to the original value of the cell. And if a cell doesn’t exist, then they are multiplied by 0. And so, all cells start with an initial value of 0. Since the Chandassu syllable length for any form of poem does not exceed 21, I’ve taken the creative freedom to push the number of syllables that can exist in a cell. As long as a consequent part of each cell matches with the pattern, it is valid. This also allows for more freedom into writing a program that can print out a value.

excerpt from the hello-world prasa program that demonstrates scaling values using parenthesis.
Scaling

4. Language

The current implementation of Prāsa is built on an approximation of the CMU English dictionary. Syllables in English do not follow a long-short pattern, but rather build on syllable stress. Primary stress syllables, or secondary/no stress syllables. Although they do not quite translate accurately, I have taken the creative freedom during this process to map them to their counterparts.


Most dictionary datasets I could find also do not provide the stress pattern. The CMU dictionary comes closest with an IPA translation for each word in the dictionary. However, to make the code-writing experience more intuitive, and to allow for an expansive approach, I have created an approximation of the dictionary that can split a word into each of its syllables, along with their syllable stress notation.


python code to approximate syllables from CMU dictionary

Python code to estimate the syllable sounds in the dictionary. Text version of the code can

accessed here

The syllables are only an approximation and have not been tested thoroughly.


But since the project relies on a dictionary format I have built, this also allows for extending the language into working with any language with its dictionary in the same structure.


RIVER:
{
  "sc": 2,
  "sp": "UI",
  "seg": [
	{
  	"syllable": "RI",
  	"position": 1,
  	"pattern": "U"
	},
	{
  	"syllable": "VER",
  	"position": 2,
  	"pattern": "I"
	}
  ]
}

keydesc
scsyllable count
spsyllable pattern
segsyllable-based segments
seg.syllablesyllable part
seg.positionposition of the syllable in the word
seg.patternU / I pattern for the syllable segment

Compiling it all

The interpreter is built in JavaScript, and is a recursive function that takes in a string of Prāsa code, and returns the output. The function iterates through each character in the string, and proceses it through the lexer, parser and evaluator functions.


The lexer looks for the following tokens in the input text.


typevalueline
INDENT00
WORDfrom0
WORDthe0
WORDriver0
INDENT11
WORDto1
WORDthe1
WORDsea1
INDENT02
BRACKET_BEGIN2
WORDwill2
WORDbe2
WORDfree2
BRACKET_END2


Tree visualization

A full documentation is available at prasa.software




Earlier prototypes of the implementation relied on the phonemes from the CMU Pronuncing Dictionary, with a higher accuracy of the syllable approximation than the current implementation. The language was also workshopped with a small group of participants at the Creative Computing Institute to gather feedback. Most of the feedback was about the experience with the editor, and not necessarily the language itself. The writing experience felt unintuitive, and forcing an unavoidable cross-checking with the reference page. With the subsequent version, I have implemented a debug panel, to mimic a traditional code editor. While all the necessary components were there, figuring out the syllable sequences for the input code still seemed to be lacking. Building upon the next round of feedback, the decision to rewrite the dictionary to approximate the syllable parts of every word was implemented. This supports an immediate feedback on the editor, with a space for dispalying errors in words with no additional clicks.

earlier version of the prasa editorearlier version of the prasa editor

Earlier versions of the editor.

The current implementation of the editor can be found at prasa.software/write