An introduction to Sophia

What developers need to know about decentralized applications

Emil Wagner
© Shutterstock / rafael belda

Constructing decentralized applications is one of blockchain’s most significant advantages. It does, however, come with a set of very unique challenges. In this article, Emil Wagner gives you some guidelines on how to deal with those challenges.

One of blockchain’s most significant advantages is its ability to facilitate the construction of decentralized applications. They have several key advantages, chief among them enhanced security due to the fact that alterations to the network are only achieved through the approval of many actors. These applications don’t rely on a central authority, whether that’s a developer or a corporation, instead, they allow important decisions about the app’s development to be made by the community at large. In addition, as open-source code repositories, decentralized applications enable innovation from a broader spectrum of developers.

Challenges for developers

However, from a development standpoint, constructing this new type of applications is no small feat, and comes with a set of unique challenges. A large part of the difficulty stems from the fact that the applications team must create new UI and UX languages alongside the applications. Specifically, through our work on developing mobile decentralized applications, called æpps at æternity, this initial challenge is significant, since we are introducing certain functionalities for the first time ever. The difficulty is increased by the fact that these features are being implemented for mobile devices. Creating æpps requires substantially more concerted effort and perseverance from developers who must also comprehend the new type of infrastructure that supports them.

    Blockchain Whitepaper 2018

    Free: Blockchain Technology Whitepaper

    If building a blockchain from scratch is beyond your current scope, the blockchain technology whitepaper is worth a look. Experts from the field share their know-how, tips and tricks, development advice, and strategy for becoming a blockchain master.

The fact that it’s necessary to create corresponding UI/UX specifically for æpps relates to another challenge in the space: developer education. There has been a notable lack of development in the decentralized apps sphere to date, and so there has been a great influx of newcomers who are not aware of the specifics related to decentralized applications. It’s essential that the UI/UX is designed well-enough as to allow newcomers to use the apps. It’s inevitably quite challenging to implement all of this on a mobile device, particularly as different app stores have specific requirements and can unlist an app as and when they choose.

Technical issues with using æpps

As with the development of any cutting-edge technology, there are some technical issues associated with the use of æpps. Notably, when using decentralized applications, there are “fees” involved when carrying out tasks, such as sending a transaction, running a smart contract, or using an oracle. This, in turn, has an impact on UX and usually results in the app being slower to respond This is, of course, confusing and frustrating for the user. At æternity, we’re looking to solve this is by implementing state channels and Bitcoin-NG. State channels let two participants deposit funds in a direct channel to transfer funds between them as long as both sign every transaction and run smart contracts in the channel. This has several advantages, including increased privacy and efficiency of transactions. Bitcoin-NG meanwhile is a technology to improve the transaction throughput of the network. These technologies will increase the network response speed and improve UX.

SEE ALSO: Blockchain scalability for supply chains

Another significant issue is that program errors can be expensive for the user and can quickly result in them choosing to no longer use a decentralized app. Such instances must be avoided.  To address this, the æternity team has taken the strategic decision to use functional programming languages. They are considered much better when it comes to fault tolerance, the ability of the system to continue running even in the event of a failure. The æternity blockchain infrastructure is being developed on Erlang, one of the most popular functional programming languages. 90% of all internet traffic goes through Erlang controlled nodes.

Finally, the most popular smart contract language, Solidity, poses many problems for building decentralized, mobile, user-friendly apps. Solidity borrows syntax from another very popular language but works quite differently. This could be confusing to developers and result in unexpected behavior. It also encourages anti-patterns like modifiers (jumping around in code), which creates functions with side effects and makes it particularly grueling to create user-friendly apps. Functional programming could be the solution.

æternity’s approach to smart contracts

æternity has developed its own functional programming language, Sophia, to be used for smart contracts. The paradigms of functional programming — which treats computation as the evaluation of mathematical functions and avoids changeable data — help reduce many of the aforementioned coding side effects.

SEE ALSO: Make sure your blockchain smart contracts are secure: OpenZeppelin 2.0 soars high

Smart contracts written in the Sophia language are conceptually based on reasonml syntax and the ocaml programming language, and all of the contract state is managed in a single variable called “state.” The functions can only change state by returning an updated copy of the entire state. Sophia doesn’t borrow its syntax from a popular language, which avoids errors based on false assumptions assimilated from the original language.

For instance, a sample of Sophia code below counts how many times the tick function has been called and can return this value upon request:

contract Counter =
record state = { value : int }
function init(val) = { value = val }
function get() = state.value
function tick() = put(state{ value = state.value + 1 })

This function also shows:

  •       how to manage state
  •       how state is updated
  •       how state can be retrieved
  •       all of the state is stored in a single variable called state

The path forward

Decentralized applications have significant potential to improve security and efficiency of mobile applications, as well as enable new features that users love. However, there are a number of major challenges to be solved before they can achieve mainstream and widespread adoption. They must reach the industry standard in terms of  UX/UI and eliminate costly technical errors. With the introduction of functional programming languages like Sophia, we at æternity hope to contribute a piece to the puzzle of making æpps usable by a broader user base.


Emil Wagner

Emil Wagner is the lead of the aeternity aepps team and is really keen and actually the best person to pen the piece in general. He led app and web-app projects for companies like Sony, Telefonica, VW and Montblanc in the past and is thrilled by the opportunity to make blockchain technology accessible for everyone.

Leave a Reply

Be the First to Comment!

Notify of