dType — Decentralized Type System & Functional Programming on Ethereum
--
In my previous article, A Vision of a System Registry for The World Computer, I talked about the vision behind dType, a Decentralized Type System for Ethereum. Now, we are going to explore the protocol in more detail and see how a global functional programming protocol can be built on top of it.
dType aims to bring consensus on data types and foster interoperability. You can read our draft ERC proposal and you can leave feedback in the corresponding GitHub issue. Make sure you check out our proof of concept implementation.
Typing in Ethereum Now
We know what a type system is: a system that allows you to assign a specific type to a variable, expression, function, etc. and performs a compile and/or run-time check to see if that rule is respected. This eliminates a set of bugs determined by improperly connecting various interfaces in your code.
Solidity is a statically typed language. Aside from providing elementary types such as string
or address
natively, it also allows the developer to construct complex ones, using struct
.
What happens now, is that each developer is free to make his own complex types, depending on his needs. This is awesome! But what happens if you want to build the even more awesome World Computer, where you have projects neatly cooperating with each other? You end up with a lot of projects where each defines its own types in their own encapsulation. To make any two projects interoperate requires a deeper knowledge of those projects and maybe even source code changes.
Decentralized Typing with a Global Registry
This is where a Decentralized Type System comes in handy. The community can discuss and reach consensus on what types to create and use and everyone can benefit from using these well known and tested types. It becomes easier to see what contracts and external functions use a certain type and easier to interconnect the projects and analyze blockchain data.
The Decentralized Type System that we are proposing contains a dType Registry contract, that has a reference to all accepted types and the contracts that implement them.