Distributed Ledger Technology (DLT) in the enterprise space has seen a number of new players in recent years, providing greater variety for businesses to select an appropriate technology for their needs. Often, these choices are not made on the basis of the merits of the technology alone, but rather on existing business relationships and, sometimes, hype.
The most well-known DLT technologies available for enterprise solutions today include Hyperledger Besu (an Ethereum client, previously Pantheon), R3’s Corda, and Hyperledger Fabric. More recently, Digital Asset has released DAML which is not a distributed ledger, but rather a language which can be used on multiple ledgers. In each part of the Block8 Rates series, we will attempt to provide a direct comparison between two approaches to writing distributed applications.
In particular, we’ll be taking a look at writing smart contracts in R3’s Corda compared to Digital Asset’s DAML.
Other parts in this series:
With the evolving software technology landscape, a developer’s time is becoming ever more valuable, especially when it comes to investing in learning new skills. This part of our series looks at how easy DAML and Corda are to pick up and the quality of the available materials and documentation.
Corda has several structures which new users are introduced to - States, Contracts and Flows. Note that in the Corda documentation, there is a lack of complex workflow examples provided in Java. If you are familiar with Kotlin syntax, you may find it slightly easier to pick up as Corda itself has actually been completely developed in Kotlin.
We found that to model a moderately complex business workflow from zero knowledge of Corda to complete with exposed API endpoints, it took around two weeks.
DAML has only one key structure, “templates”, where each template has methods, which are called choices, and these choices define the allowable mutation code. Instances of templates are contracts, and methods can be executed on these contracts as defined in the template. Signatories and observers of a contract are also as defined in the template of the contract. The succinct nature of the language along with documentation in one specified language (as opposed to documentation split into Java/Kotlin) does indeed make it easier for developers to focus on modelling the business workflows.
To model the same moderately complex business workflow from zero knowledge of DAML to complete with API endpoints, it took around one week. It is worth noting that previous experience with functional programming languages such as Haskell is beneficial when writing more complex DAML contracts.
For the newer player in smart contract tech, DAML takes this one as the domain specific language design integrates all of the necessary features into one simple structure.
Corda has extensive documentation along with several YouTube tutorials. Some of the Youtube videos are outdated due to Corda updates and several of the documentation examples are only in Kotlin. If you plan to develop in Kotlin, documentation should be no problem, however, if you plan to use Java, you may have to do some extra digging with trial and error. The Slack channel is fairly active and you can generally get a response for your queries.
Corda allows for testing by setting up mock networks and executing flows within your IDE, then using asserts to ensure the transaction resulted in the output we expected. We can also spin up some nodes in separate terminals and emulate different users.
Once you have a conceptual model of a business workflow, you must then write the State, Contract and Flows to execute the workflow. It was fairly monotonous writing so many files compared to DAML.
There was also the issue of serialisation. One of our structures had a composition relationship, where we stored an ArrayList of an object in a larger structure. For example storing Brick objects as an ArrayList in a larger House object, where we can add and remove Bricks (note: this was not our actual implementation). This was not possible as it required us to write a custom serializer. Corda pervasively uses a custom form of type safe binary serialisation, which prevents us from modelling complex states. This can be bypassed by writing custom serializers which would require further learning, however, there was only one trivial example of custom serializers in the official Corda docs. To complete the analogy, we opted to disassociate the Bricks from the House and just store a reference to the House in the Brick objects.
The documentation for DAML was fairly succinct with regards to the actual writing of smart contracts and the DAML language. It became less so when trying to understand details about the DAML ledger. This is largely because there is no one Digital Asset Ledger. The DAML language is ledger-agnostic and runs on a wide range of infrastructures, from fully centralized to fully distributed, including the Corda ledger. That is why the key focus of our comparison is on the smart contracts rather than the ledger.
More recently, DAML has introduced an in-browser interactive learning environment to guide new users through several key concepts. This is a much more enjoyable experience than trawling through pages of documentation. Corda has also recently released a new training site, however, the user experience of the DAML learning environment is far superior.
In regards to modelling the same house and bricks representation, although we opted to store a simple reference in the bricks object, it is possible to model composition and more complex structures fairly easily. It is also worth noting that more complex DAML smart contracts, which are beyond just simple state changes, will require an understanding of Functional Programming concepts.
DAML’s better IDE integration and modelling simplicity proves it to be a winner in terms of ease of development and testing. Initially, our view was that Corda’s maturity and native JVM environment proved it to be stronger with documentation and resources. However, with DAML’s addition of the interactive learning environment, and their heavy focus on creating new developer resources, DAML takes the lead.
About the Authors:
Rao Zoraiz Mahmood
Software Engineer, Block8
Zoraiz Mahmood is a Software Engineer at Block8, working on emerging technology.
His current research and development interest focuses on protocol development for distributed systems (blockchain), and is currently writing a paper on the Performance Comparison of Blockchain Data Storage Models.
Zoraiz regularly creates blockchain technical and related content, having written multiple technical articles, hosted podcasts and produced YouTube videos.
When not generating value, Zoraiz can be found out and about exploring the Australian landscape.
Samuel Brooks is an expert in connecting next-gen technology with current-gen business problems, with particular specialisation in the development of distributed ledger systems, having designed many DLT-based solutions and authored and contributed to multiple public submissions from both industry and government.
He is also an active member of the Australian blockchain community, including regularly speaking at technology conferences, meetups and podcasts, and contributing to industry and International Standards committees.
Samuel holds a degree in Electrical Engineering from UNSW and has been working hands-on with blockchains since 2014.