Designing a language | Algorand Developer Portal

Designing a language

The first step to adding a new front end for Puya is designing the language itself.

Regardless of which option is chosen, the language will be composed of a set of supported syntax (likely a subset of the source language if based on an existing one), and a library of types and functions representing the full API of your solution.

Primitive and compound types

AWST defines a number of different primitive and compound types. You will need to decide how your language represents these types and how they interact. Notably your language will need to support a range of binary expressions for math operations on integers, and operations for slicing and dicing byte arrays. It should also define types for arrays and tuples.

Contract and logic signature paradigms

Next you should decide how your language will represent contracts and logic signatures. Algorand Python and Algorand TypeScript use classes to represent contracts - newing up a contract class is akin to creating the application with instance members used to define contract methods and state. For Algorand Python, logic signatures are implemented as a pure function whilst Algorand TypeScript uses a class again due to technical limitations of the language.

The paradigm your language uses should be tailored to what is idiomatic in the base language.

Other key abstractions

In no particular order, your language will need abstractions for:

Algorand Python’s algopy module and Algorand TypeScript’s @algorandfoundation/algorand-typescript modules are helpful resources for designing a public API. Both make use of a sanitised lang spec file to generate the operation types. The unsanitised lang spec file being an artifact generated by go-algorand.