I am working with a group of developers to create a new general smart contract library called Compose. One of our design objectives is to make the smart contract code within the library itself very readable and easy to understand. We feel it is a good thing (for a number of reasons) for the users of our smart contracts (other smart contract developers) to be able to quickly and easily read and understand our smart contracts.
To simplify, and make our contracts easier to read and understand, we limit what Solidity features can be used within the contracts in our library. For example we don’t allow inheritance in our contracts, we don’t allow modifiers, we don’t allow using for syntax, we don’t allow public or private functions, and we have other restrictions. Just limiting the number of features used simplifies the code and helps keep it consistent. Keep in mind these restrictions apply to the code within the library, they do not apply to the code written by users that use our library.
We believe that good software is software that can be understood, and that the difference between a good programmer and a bad programmer is understanding. And so we write our smart contract code in a way that is meant to be easily understood by others. And we have a thought about the future. In ten, thirty or one hundred years, how easily will people be able to read the source code of our deployed contracts?
I am wondering how some of the new features proposed for Core Solidity can help us write code that is easier to read and understand, than what we have now.
The Solidity blog post mentions these core features of Core Solidity:
- Generics / parametric polymorphism
- Traits (a.k.a. typeclasses)
- Hindley-Milner type inference (known from languages such as Rust or OCaml)
- First-class and anonymous (a.k.a. lambda) functions
- Algebraic data types
- Pattern matching with exhaustiveness checking
I am interested in future blog posts from the Solidity blog to explain and show examples of how these features can help us write code that is simpler, easier to read and understand, than what we have now.
Onchain Composability
Another core aspect of Compose is that it is designed for onchain composability. It uses EIP-2535 Diamonds for the creation of diamond contracts that can utilize and reuse already deployed facet contracts. Any number of diamond contracts can potentially mix and match with different onchain facet contracts. Facets are like onchain lego pieces that can be attached to various diamond contracts.
I would like to know if there are ideas or plans in Core Solidity, or aspects or ways to leverage Core Solidity for onchain composability, or make EIP-2535 Diamonds easier to implement, etc.