Hacker News new | ask | show | jobs
by loandigger 1473 days ago
From a traditional Dev perspective, blockchain programming can seem really weird.

No decimals, no patches or point upgrades to deployed smart contracts (for the most part anyway), constructor event only gets called once during deploy, code implicitly has "owners" with specific execution rights, etc.

But this is what I have found to be the strangest part:

On most worldwide public blockchains, your programs are deployed to run on servers supplied by other people. They expect to be compensated for supplying this CPU power. Your programs are charged gas and mining fees when they execute. This is usually paid for by the person initiating the transaction with your program.

This produces two weird side effects:

1) Your development environment (e.g. hardhat, ganache) will "charge" you the same fees, even when you are running entirely on your own laptop. Many times when you hit the deploy button, your own laptop will puke because your dev wallet doesn't have enough coin in it to pay the compile fees. ON YOUR OWN MACHINE!

2) When optimizing your code, you no longer refactor to improve speed or code maintainability, but mainly to reduce the fees charged when executing. Solidity even has a "price sheet" of fees for operations like addition, subtraction or allocating memory. This new way of thinking can seem strange to experienced devs because of all the easy fixes you plainly see that have to be left in the code base. Counter-intuitive.

2 comments

> 2) When optimizing your code, you no longer refactor to improve speed or code maintainability, but mainly to reduce the fees charged when executing. Solidity even has a "price sheet" of fees for operations like addition, subtraction or allocating memory. This new way of thinking can seem strange to experienced devs because of all the easy fixes you plainly see that have to be left in the code base. Counter-intuitive.

That makes me think of the game Shenzhen I/O: each component cost money, each executed line of code draw power, you have to optimize your circuit to match your assigned power and price goals.

Another side effect is that you have to now think of separating the expensive parts of the code from the non expensive parts because that code has to be offloaded from the blockchain itself into side chains or something else.

Security is another aspect that has to be brutally evaluated, even at the OPCODE level. This is really strange.

TL;DR it's almost like writing assembly level code with a 1000% emphasis on security, despite writing code in a high level language.