On January 27 of this year, the most recent version of the Ethereum network programming language was released, which facilitates the creation of Solidity smart contracts. This new version, although it brought with it a number of somewhat minor improvements, compared to version 0.8 released in December, offers optimization adjustments both within the compiler and the language.
The new version of Solidity was released within the official blog of the programming language. In this article, the changes, corrections and new sentences that would come into operation from version 0.8.1 were listed.
The changes in the language require that those users who wish to use it update their compiler to the new version 0.8.1.
Notable changes in Solidity 0.8.1
The Solidity blog establishes three notable changes for the language:
Improved compilation SMTChecker which allows finding errors within the smart contract when compiling. It works by checking the code against a predetermined list of errors to check if there are any present. With the new optimization, you can define which specific errors you want to test, avoiding an overload and optimizing memory usage.
Another change at the compiler level was the improvement of the address code generator, which reduces memory usage.
Regarding the use of the programming language, in the new version of Solidity it is now possible to use the statement Catch panic ( unit code ). This function seeks to improve a error introduced in the previous version (0.8) allowing to control the errors that cause the execution of a contract to stop abruptly.
Why is a programming language like Solidity optimized
In software development it is normal that new errors are found every day, and updates are released that correct them, as happened with this new version of Solidity. However, the objective that the optimization of programming languages seeks is the adequate management of resources.
In a PC software, when we talk about resources, we we mean hard disk, ram memory, video memory, processor. All hardware tasked with making the software run properly. A properly optimized application adequately uses all these resources, allowing other programs to work in parallel, including the operating system.
Now, When we talk about resources within a smart contract, this refers to the power of mining. Since each contract is within the Ethereum network, mining commissions are paid to be able to execute the instructions Either a transaction or a smart contract.
In a poorly optimized language within a cryptocurrency network, commissions increase, since, as there is no good resource management, Greater computing power is required to execute transactions.
Similarly, as reported by CriptoNoticias, in addition to Solidity, there are alternatives to develop within the Ethereum ecosystem. One of them is Fe, based on Rust, which is presented as a simpler option for smart contracts
Importance of control structures in Solidity
It could be assumed that at some point in your life has closed an application, be it on your pc or mobile phone. This usually occurs due to errors not foreseen by the programmers.
Within the world of programming there are statements of control structures, which basically allow to control the behavior of the system as the user interacts with it.
Among these sentences we can find the try / catch type. These allow you to manage the expected errors as follows:
- Try (tries): Sets the instructions that should be executed.
- Catch (capture): In case of an unforeseen error when executing the statements within the Try, it will execute the statements within the Catch.
Within the types of Try / Catch are the catch panic , which allow to manage errors not anticipated by programmers. These types of errors are usually caused by the interaction between the user and the software, such as a division by zero. This statement allows capturing and debugging errors that are outside of what the programmer intended, avoiding abrupt closings of the smart contract.
One case in which this type of statement is often used is when there are requests for external connection. For example, when a contract requests information from an oracle (which is another smart contract) of some result. The code to establish this connection is done within a try / catch . In case the connection fails, the first catch would catch the error, but, in case there is a much bigger problem not anticipated, the catch panic would catch the error and allow it to be handled.