Inline assembly, good or bad practiceHow do you balance inline assembly blocks?How to take coins from a msg.sender? Or verify coins were sent?Understanding solidity inline assembly codeOut of gas exception when calculating Keccak256 inline solidity assemblyAccessing array elements with inline assemblySolidity to inline assemblyOptional Multi-Parameter Call to External ContractDecoding parameters with inline assembly in SoliditySolidity modifiers: good or bad?Question about inline assembly in Solidity

I have a domain, static IP address and many devices I'd like to access outside my house. How do I route them?

Alternative methods for solving a system of one linear one non linear simultaneous equations

How do changes to your speed that occur on your own turn affect your available movement?

Can a character with a low Intelligence score take the Ritual Caster feat and choose the Wizard class?

Are rockets faster than airplanes?

Are gangsters hired to attack people at a train station classified as a terrorist attack?

What the purpose of the fuel shutoff valve?

Why are angular mometum and angular velocity not necessarily parallel, but linear momentum and linear velocity are always parallel?

"It is what it is" in French

How may I shorten this shell script?

Considerations when providing money to one child now, and the other later?

How can I tell if there was a power cut when I was out?

Is there a way to shorten this while condition?

Sometimes you are this word with three vowels

Sci-fi short story: plants attracting spaceship and using them as a agents of pollination between two planets

The 50,000 row query limit is not actually a "per APEX call" as widely believed

Why are there not any MRI machines available in Interstellar?

Using "Kollege" as "university friend"?

Bug in Lualatex: not printing characters from calculation

Is there a way to factor age into the mass-luminosity relationship for stars?

Is an easily guessed plot twist a good plot twist?

How to correct errors in proofs of an accepted paper

What is the best word describing the nature of expiring in a short amount of time, connoting "losing public attention"?

What is "ass door"?



Inline assembly, good or bad practice


How do you balance inline assembly blocks?How to take coins from a msg.sender? Or verify coins were sent?Understanding solidity inline assembly codeOut of gas exception when calculating Keccak256 inline solidity assemblyAccessing array elements with inline assemblySolidity to inline assemblyOptional Multi-Parameter Call to External ContractDecoding parameters with inline assembly in SoliditySolidity modifiers: good or bad?Question about inline assembly in Solidity






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I often see inline assembly in Solidity contracts. I consider this a bad practice because of the poor readability, however this is my opinion only and there must be valid reasons to use it. There are no other means to reach the same results in pure Solidity code? and if not, doesn't this show a lack in the language design?










share|improve this question




























    4















    I often see inline assembly in Solidity contracts. I consider this a bad practice because of the poor readability, however this is my opinion only and there must be valid reasons to use it. There are no other means to reach the same results in pure Solidity code? and if not, doesn't this show a lack in the language design?










    share|improve this question
























      4












      4








      4


      1






      I often see inline assembly in Solidity contracts. I consider this a bad practice because of the poor readability, however this is my opinion only and there must be valid reasons to use it. There are no other means to reach the same results in pure Solidity code? and if not, doesn't this show a lack in the language design?










      share|improve this question














      I often see inline assembly in Solidity contracts. I consider this a bad practice because of the poor readability, however this is my opinion only and there must be valid reasons to use it. There are no other means to reach the same results in pure Solidity code? and if not, doesn't this show a lack in the language design?







      solidity






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 14 at 17:34









      Davide CDavide C

      4644 silver badges15 bronze badges




      4644 silver badges15 bronze badges




















          2 Answers
          2






          active

          oldest

          votes


















          3














          I think there're some points that we need to use assembly in the documents



          1. smth that cannot be done by plain Solidity



          https://solidity.readthedocs.io/en/v0.5.3/assembly.html#example



          pragma solidity >=0.4.0 <0.6.0;

          library GetCode
          function at(address _addr) public view returns (bytes memory o_code)
          assembly
          // retrieve the size of the code, this needs assembly
          let size := extcodesize(_addr)
          // allocate output byte array - this could also be done without assembly
          // by using o_code = new bytes(size)
          o_code := mload(0x40)
          // new "memory end" including padding
          mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
          // store length in memory
          mstore(o_code, size)
          // actually retrieve the code, this needs assembly
          extcodecopy(_addr, add(o_code, 0x20), 0, size)





          2. Optimize code to produce efficient code



          pragma solidity >=0.4.16 <0.6.0;

          library VectorSum
          // This function is less efficient because the optimizer currently fails to
          // remove the bounds checks in array access.
          function sumSolidity(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          o_sum += _data[i];


          // We know that we only access the array in bounds, so we can avoid the check.
          // 0x20 needs to be added to an array because the first slot contains the
          // array length.
          function sumAsm(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          assembly
          o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))




          // Same as above, but accomplish the entire code within inline assembly.
          function sumPureAsm(uint[] memory _data) public pure returns (uint o_sum)
          assembly
          // Load the length (first 32 bytes)
          let len := mload(_data)

          // Skip over the length field.
          //
          // Keep temporary variable so it can be incremented in place.
          //
          // NOTE: incrementing _data would result in an unusable
          // _data variable after this assembly block
          let data := add(_data, 0x20)

          // Iterate until the bound is not met.
          for
          let end := add(data, mul(len, 0x20))
          lt(data, end)
          data := add(data, 0x20)

          o_sum := add(o_sum, mload(data))






          And due to it's low level then we only use then we need and confident to use it as warning from solidity document




          Inline assembly is a way to access the Ethereum Virtual Machine at a
          low level. This bypasses several important safety features and checks
          of Solidity. You should only use it for tasks that need it, and only
          if you are confident with using it.







          share|improve this answer


















          • 3





            That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

            – Davide C
            Jul 15 at 22:20











          • For security critical applications assembly is not a good idea.

            – ferit
            Jul 16 at 18:35











          • I assume all smart contracts are security critical applications.

            – Davide C
            Jul 17 at 20:09



















          3














          In mainstream languages such as C++ when one needs to do something not achievable via core language, he usually calls library function, either from standard or third-party library. This function may be implemented in assembly or in a high-level language different from the language the function is called from. Whoever calls the function usually don't care about what language the function is implemented in.



          For Solidity the situation should not be different. If you need something not available in core language, try to find library for this.



          When we talk about optimizations, starting from version 0.5.0 Solidity permanently disabled so called loose assembly that gives developer full control over generated byte code. What is left is so called functional-style assembly, that allows developer to include sophisticated opcodes such as CREATE2, but does not allow him to directly control stack or execution flow. Compilation output of functional style assembly is then processed by Solidity optimizer. Thus inline assembly in Solidity is not suitable for manual optimizations anymore.






          share|improve this answer























          • mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

            – Davide C
            Jul 15 at 22:22











          • Sorry, but I don't get your point. How the former implies the letter?

            – Mikhail Vladimirov
            Jul 16 at 19:14













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "642"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f72895%2finline-assembly-good-or-bad-practice%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          I think there're some points that we need to use assembly in the documents



          1. smth that cannot be done by plain Solidity



          https://solidity.readthedocs.io/en/v0.5.3/assembly.html#example



          pragma solidity >=0.4.0 <0.6.0;

          library GetCode
          function at(address _addr) public view returns (bytes memory o_code)
          assembly
          // retrieve the size of the code, this needs assembly
          let size := extcodesize(_addr)
          // allocate output byte array - this could also be done without assembly
          // by using o_code = new bytes(size)
          o_code := mload(0x40)
          // new "memory end" including padding
          mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
          // store length in memory
          mstore(o_code, size)
          // actually retrieve the code, this needs assembly
          extcodecopy(_addr, add(o_code, 0x20), 0, size)





          2. Optimize code to produce efficient code



          pragma solidity >=0.4.16 <0.6.0;

          library VectorSum
          // This function is less efficient because the optimizer currently fails to
          // remove the bounds checks in array access.
          function sumSolidity(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          o_sum += _data[i];


          // We know that we only access the array in bounds, so we can avoid the check.
          // 0x20 needs to be added to an array because the first slot contains the
          // array length.
          function sumAsm(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          assembly
          o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))




          // Same as above, but accomplish the entire code within inline assembly.
          function sumPureAsm(uint[] memory _data) public pure returns (uint o_sum)
          assembly
          // Load the length (first 32 bytes)
          let len := mload(_data)

          // Skip over the length field.
          //
          // Keep temporary variable so it can be incremented in place.
          //
          // NOTE: incrementing _data would result in an unusable
          // _data variable after this assembly block
          let data := add(_data, 0x20)

          // Iterate until the bound is not met.
          for
          let end := add(data, mul(len, 0x20))
          lt(data, end)
          data := add(data, 0x20)

          o_sum := add(o_sum, mload(data))






          And due to it's low level then we only use then we need and confident to use it as warning from solidity document




          Inline assembly is a way to access the Ethereum Virtual Machine at a
          low level. This bypasses several important safety features and checks
          of Solidity. You should only use it for tasks that need it, and only
          if you are confident with using it.







          share|improve this answer


















          • 3





            That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

            – Davide C
            Jul 15 at 22:20











          • For security critical applications assembly is not a good idea.

            – ferit
            Jul 16 at 18:35











          • I assume all smart contracts are security critical applications.

            – Davide C
            Jul 17 at 20:09
















          3














          I think there're some points that we need to use assembly in the documents



          1. smth that cannot be done by plain Solidity



          https://solidity.readthedocs.io/en/v0.5.3/assembly.html#example



          pragma solidity >=0.4.0 <0.6.0;

          library GetCode
          function at(address _addr) public view returns (bytes memory o_code)
          assembly
          // retrieve the size of the code, this needs assembly
          let size := extcodesize(_addr)
          // allocate output byte array - this could also be done without assembly
          // by using o_code = new bytes(size)
          o_code := mload(0x40)
          // new "memory end" including padding
          mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
          // store length in memory
          mstore(o_code, size)
          // actually retrieve the code, this needs assembly
          extcodecopy(_addr, add(o_code, 0x20), 0, size)





          2. Optimize code to produce efficient code



          pragma solidity >=0.4.16 <0.6.0;

          library VectorSum
          // This function is less efficient because the optimizer currently fails to
          // remove the bounds checks in array access.
          function sumSolidity(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          o_sum += _data[i];


          // We know that we only access the array in bounds, so we can avoid the check.
          // 0x20 needs to be added to an array because the first slot contains the
          // array length.
          function sumAsm(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          assembly
          o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))




          // Same as above, but accomplish the entire code within inline assembly.
          function sumPureAsm(uint[] memory _data) public pure returns (uint o_sum)
          assembly
          // Load the length (first 32 bytes)
          let len := mload(_data)

          // Skip over the length field.
          //
          // Keep temporary variable so it can be incremented in place.
          //
          // NOTE: incrementing _data would result in an unusable
          // _data variable after this assembly block
          let data := add(_data, 0x20)

          // Iterate until the bound is not met.
          for
          let end := add(data, mul(len, 0x20))
          lt(data, end)
          data := add(data, 0x20)

          o_sum := add(o_sum, mload(data))






          And due to it's low level then we only use then we need and confident to use it as warning from solidity document




          Inline assembly is a way to access the Ethereum Virtual Machine at a
          low level. This bypasses several important safety features and checks
          of Solidity. You should only use it for tasks that need it, and only
          if you are confident with using it.







          share|improve this answer


















          • 3





            That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

            – Davide C
            Jul 15 at 22:20











          • For security critical applications assembly is not a good idea.

            – ferit
            Jul 16 at 18:35











          • I assume all smart contracts are security critical applications.

            – Davide C
            Jul 17 at 20:09














          3












          3








          3







          I think there're some points that we need to use assembly in the documents



          1. smth that cannot be done by plain Solidity



          https://solidity.readthedocs.io/en/v0.5.3/assembly.html#example



          pragma solidity >=0.4.0 <0.6.0;

          library GetCode
          function at(address _addr) public view returns (bytes memory o_code)
          assembly
          // retrieve the size of the code, this needs assembly
          let size := extcodesize(_addr)
          // allocate output byte array - this could also be done without assembly
          // by using o_code = new bytes(size)
          o_code := mload(0x40)
          // new "memory end" including padding
          mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
          // store length in memory
          mstore(o_code, size)
          // actually retrieve the code, this needs assembly
          extcodecopy(_addr, add(o_code, 0x20), 0, size)





          2. Optimize code to produce efficient code



          pragma solidity >=0.4.16 <0.6.0;

          library VectorSum
          // This function is less efficient because the optimizer currently fails to
          // remove the bounds checks in array access.
          function sumSolidity(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          o_sum += _data[i];


          // We know that we only access the array in bounds, so we can avoid the check.
          // 0x20 needs to be added to an array because the first slot contains the
          // array length.
          function sumAsm(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          assembly
          o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))




          // Same as above, but accomplish the entire code within inline assembly.
          function sumPureAsm(uint[] memory _data) public pure returns (uint o_sum)
          assembly
          // Load the length (first 32 bytes)
          let len := mload(_data)

          // Skip over the length field.
          //
          // Keep temporary variable so it can be incremented in place.
          //
          // NOTE: incrementing _data would result in an unusable
          // _data variable after this assembly block
          let data := add(_data, 0x20)

          // Iterate until the bound is not met.
          for
          let end := add(data, mul(len, 0x20))
          lt(data, end)
          data := add(data, 0x20)

          o_sum := add(o_sum, mload(data))






          And due to it's low level then we only use then we need and confident to use it as warning from solidity document




          Inline assembly is a way to access the Ethereum Virtual Machine at a
          low level. This bypasses several important safety features and checks
          of Solidity. You should only use it for tasks that need it, and only
          if you are confident with using it.







          share|improve this answer













          I think there're some points that we need to use assembly in the documents



          1. smth that cannot be done by plain Solidity



          https://solidity.readthedocs.io/en/v0.5.3/assembly.html#example



          pragma solidity >=0.4.0 <0.6.0;

          library GetCode
          function at(address _addr) public view returns (bytes memory o_code)
          assembly
          // retrieve the size of the code, this needs assembly
          let size := extcodesize(_addr)
          // allocate output byte array - this could also be done without assembly
          // by using o_code = new bytes(size)
          o_code := mload(0x40)
          // new "memory end" including padding
          mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
          // store length in memory
          mstore(o_code, size)
          // actually retrieve the code, this needs assembly
          extcodecopy(_addr, add(o_code, 0x20), 0, size)





          2. Optimize code to produce efficient code



          pragma solidity >=0.4.16 <0.6.0;

          library VectorSum
          // This function is less efficient because the optimizer currently fails to
          // remove the bounds checks in array access.
          function sumSolidity(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          o_sum += _data[i];


          // We know that we only access the array in bounds, so we can avoid the check.
          // 0x20 needs to be added to an array because the first slot contains the
          // array length.
          function sumAsm(uint[] memory _data) public pure returns (uint o_sum)
          for (uint i = 0; i < _data.length; ++i)
          assembly
          o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))




          // Same as above, but accomplish the entire code within inline assembly.
          function sumPureAsm(uint[] memory _data) public pure returns (uint o_sum)
          assembly
          // Load the length (first 32 bytes)
          let len := mload(_data)

          // Skip over the length field.
          //
          // Keep temporary variable so it can be incremented in place.
          //
          // NOTE: incrementing _data would result in an unusable
          // _data variable after this assembly block
          let data := add(_data, 0x20)

          // Iterate until the bound is not met.
          for
          let end := add(data, mul(len, 0x20))
          lt(data, end)
          data := add(data, 0x20)

          o_sum := add(o_sum, mload(data))






          And due to it's low level then we only use then we need and confident to use it as warning from solidity document




          Inline assembly is a way to access the Ethereum Virtual Machine at a
          low level. This bypasses several important safety features and checks
          of Solidity. You should only use it for tasks that need it, and only
          if you are confident with using it.








          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 15 at 6:12









          Ha ĐANGHa ĐANG

          1,5982 silver badges13 bronze badges




          1,5982 silver badges13 bronze badges







          • 3





            That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

            – Davide C
            Jul 15 at 22:20











          • For security critical applications assembly is not a good idea.

            – ferit
            Jul 16 at 18:35











          • I assume all smart contracts are security critical applications.

            – Davide C
            Jul 17 at 20:09













          • 3





            That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

            – Davide C
            Jul 15 at 22:20











          • For security critical applications assembly is not a good idea.

            – ferit
            Jul 16 at 18:35











          • I assume all smart contracts are security critical applications.

            – Davide C
            Jul 17 at 20:09








          3




          3





          That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

          – Davide C
          Jul 15 at 22:20





          That's the point, the recent 0x vulnerability was caused by assembly code put there to optimize space. It seems to me that security is king and accessing to assembly code is error prone even for the top developers.

          – Davide C
          Jul 15 at 22:20













          For security critical applications assembly is not a good idea.

          – ferit
          Jul 16 at 18:35





          For security critical applications assembly is not a good idea.

          – ferit
          Jul 16 at 18:35













          I assume all smart contracts are security critical applications.

          – Davide C
          Jul 17 at 20:09






          I assume all smart contracts are security critical applications.

          – Davide C
          Jul 17 at 20:09














          3














          In mainstream languages such as C++ when one needs to do something not achievable via core language, he usually calls library function, either from standard or third-party library. This function may be implemented in assembly or in a high-level language different from the language the function is called from. Whoever calls the function usually don't care about what language the function is implemented in.



          For Solidity the situation should not be different. If you need something not available in core language, try to find library for this.



          When we talk about optimizations, starting from version 0.5.0 Solidity permanently disabled so called loose assembly that gives developer full control over generated byte code. What is left is so called functional-style assembly, that allows developer to include sophisticated opcodes such as CREATE2, but does not allow him to directly control stack or execution flow. Compilation output of functional style assembly is then processed by Solidity optimizer. Thus inline assembly in Solidity is not suitable for manual optimizations anymore.






          share|improve this answer























          • mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

            – Davide C
            Jul 15 at 22:22











          • Sorry, but I don't get your point. How the former implies the letter?

            – Mikhail Vladimirov
            Jul 16 at 19:14















          3














          In mainstream languages such as C++ when one needs to do something not achievable via core language, he usually calls library function, either from standard or third-party library. This function may be implemented in assembly or in a high-level language different from the language the function is called from. Whoever calls the function usually don't care about what language the function is implemented in.



          For Solidity the situation should not be different. If you need something not available in core language, try to find library for this.



          When we talk about optimizations, starting from version 0.5.0 Solidity permanently disabled so called loose assembly that gives developer full control over generated byte code. What is left is so called functional-style assembly, that allows developer to include sophisticated opcodes such as CREATE2, but does not allow him to directly control stack or execution flow. Compilation output of functional style assembly is then processed by Solidity optimizer. Thus inline assembly in Solidity is not suitable for manual optimizations anymore.






          share|improve this answer























          • mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

            – Davide C
            Jul 15 at 22:22











          • Sorry, but I don't get your point. How the former implies the letter?

            – Mikhail Vladimirov
            Jul 16 at 19:14













          3












          3








          3







          In mainstream languages such as C++ when one needs to do something not achievable via core language, he usually calls library function, either from standard or third-party library. This function may be implemented in assembly or in a high-level language different from the language the function is called from. Whoever calls the function usually don't care about what language the function is implemented in.



          For Solidity the situation should not be different. If you need something not available in core language, try to find library for this.



          When we talk about optimizations, starting from version 0.5.0 Solidity permanently disabled so called loose assembly that gives developer full control over generated byte code. What is left is so called functional-style assembly, that allows developer to include sophisticated opcodes such as CREATE2, but does not allow him to directly control stack or execution flow. Compilation output of functional style assembly is then processed by Solidity optimizer. Thus inline assembly in Solidity is not suitable for manual optimizations anymore.






          share|improve this answer













          In mainstream languages such as C++ when one needs to do something not achievable via core language, he usually calls library function, either from standard or third-party library. This function may be implemented in assembly or in a high-level language different from the language the function is called from. Whoever calls the function usually don't care about what language the function is implemented in.



          For Solidity the situation should not be different. If you need something not available in core language, try to find library for this.



          When we talk about optimizations, starting from version 0.5.0 Solidity permanently disabled so called loose assembly that gives developer full control over generated byte code. What is left is so called functional-style assembly, that allows developer to include sophisticated opcodes such as CREATE2, but does not allow him to directly control stack or execution flow. Compilation output of functional style assembly is then processed by Solidity optimizer. Thus inline assembly in Solidity is not suitable for manual optimizations anymore.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jul 15 at 6:43









          Mikhail VladimirovMikhail Vladimirov

          2,4735 silver badges17 bronze badges




          2,4735 silver badges17 bronze badges












          • mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

            – Davide C
            Jul 15 at 22:22











          • Sorry, but I don't get your point. How the former implies the letter?

            – Mikhail Vladimirov
            Jul 16 at 19:14

















          • mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

            – Davide C
            Jul 15 at 22:22











          • Sorry, but I don't get your point. How the former implies the letter?

            – Mikhail Vladimirov
            Jul 16 at 19:14
















          mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

          – Davide C
          Jul 15 at 22:22





          mainstream languages are not good for smart contracts imho. This is why I think inline assembly is a poor choice.

          – Davide C
          Jul 15 at 22:22













          Sorry, but I don't get your point. How the former implies the letter?

          – Mikhail Vladimirov
          Jul 16 at 19:14





          Sorry, but I don't get your point. How the former implies the letter?

          – Mikhail Vladimirov
          Jul 16 at 19:14

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Ethereum Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f72895%2finline-assembly-good-or-bad-practice%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?