Loading…

Want to know everything. Solidity

Continuing the topics of Blockchain and cryptocurrencies, we are going to discuss the programming languages that are used in this sphere. The majority of them are well-known ones: Java, C/C++, Python, Ruby, and so on. With their help, general interfaces and protocols are described. However, there are particular narrow tasks where it is ineffective to use those popular programming languages. For example, if we take into account smart contracts and Solidity programming language for Ethereum platform

.

Solidity

Ethereum and smart contract

Ethereum is a decentralised platform, virtual machine for online services listing. It is based on Blockchain, its main advantage is replacing the traditional law contracts with smart contracts.

A smart contract is a contract described by mathematical methods and does not provide you with several treatments. Thus, if one of the sides does not meet the contract conditions, it will lead to punitive sanctions without an ability to transfer the issue into a legal terrain.

Now let’s turn directly to the programming language.

Brief overview

Solidity is a JavaScript-like object-oriented programming language for smart contract development. It is cross-platform but is mostly used on Ethereum.

It was created in 2014 by the team of developers with Christian Rightwisner as a leader who followed the idea of Gavin Wood. The main goal of its syntax similarity to JavaScript is the quick adaptation for developers, who have developed similar protocols on it before. Solidity supports inheritance, including multiple one, even with C3 linearization.

According to TIOBE rating, this language appeared in the last month, having started from the 167th place.

Syntax

Compared to JS, there are several global differences:

Solidity is a static typing language, only types are dynamic. There is no language version yet (current one is 0.4.16). For this reason, most of the functionality features are shortened, and the amount of bugs is pretty high. However, Solidity perfectly solves the set tasks, and visually it is the same ECMAScript:

 

contract GavCoin

{

 mapping(address=>uint) balances;

 uint constant totalCoins = 100000000000;



 /// Endows creator of contract with 1m GAV.

 function GavCoin(){

     balances[msg.sender] = totalCoins;

 }



 /// Send $((valueInmGAV / 1000).fixed(0,3)) GAV from the account of $(message.caller.address()), to an account accessible only by $(to.address()).

 function send(address to, uint256 valueInmGAV) {

   if (balances[msg.sender] >= valueInmGAV) {

     balances[to] += valueInmGAV;

     balances[msg.sender] -= valueInmGAV;

   }

 }



 /// getter function for the balance

 function balance(address who) constant returns (uint256 balanceInmGAV) {

   balanceInmGAV = balances[who];

 }

}

Development environments and code editors

Regardless of the narrow application sphere, Solidity is available for a big amount of IDEs and editors. Here is the list of available options:

 

  • Remix;

  • IntelliJ IDEA;

  • Microsoft Visual Studio;

  • Sublime Text;

  • Etheratom;

  • Solium;

  • Emacs;

  • Vim Syntastic;

  • Ethereum Studio;

  • Atom Solidity Linter.

 

Some of them support the language out-of-the-box, other ones require it in a format of a plugin.

How to learn it

There are not official books on Solidity yet. For this reason, the best way to learn Solidity is to use the official release. Also, there is a paid 3-hour course on Udemy.

For those who do not know English well, but want to master this language, should use habrahabr (1,2,3).

Moreover, this topic attracts more and more new authors, webinars and articles in personal blogs appear quite often. You can periodically monitor popular platforms and you will be up-to-date on the application and development of the language.

Prospects

Solidity is one of 3 languages for EVM (others are Serpent, LLL и Mutan) and seems to be the most sophisticated. Ethereum capitalisation reaches the level of 4 billion US dollars for only 2 years. Depending on these facts, Solidity has a prospective future, for both the language itself and the developers, who learn it.


Leave a Comment