-
What does the EVM do?
The Ethereum Virtual Machine or EVM is the runtime environment for smart contracts in Ethereum. It is not only sandboxed but actually completely isolated, which means that code running inside the EVM has no access to network, filesystem or other processes. Smart contracts even have limited access to other smart contracts.
-
What is the format of the instructions that the EVM can read?
Smart contracts are often written in a programming language called Solidity , a language similar to JavaScript and C++. Other languages for writing smart contracts include Vyper and Bamboo. Before Solidity was released, other languages like Serpent and Mutan were used.
-
What is the relationship between the programming language Solidity and Bytecode?
Solidity is compiled to bytecode that is executable on the EVM. Smart contract languages like Solidity cannot be executed by the EVM directly. Instead, they are compiled to low-level machine instructions called opcodes. Bytecode, also termed portable code or p-code, is a form of instruction set designed for efficient execution by a software interpreter.
-
Why can’t Bitcoin run the same type of complex programs like Ethereum can?
Bitcoin’s scripting language is not turing complete. A turing complete programming language is one that can be used to simulate any single-taped Turing machine. In other words, it can be used to solve any computation problem that a Turing machine can run given enough time and memory. By not being turing complete, Bitcoin script restricts what you can do. Ethereum is a cryptocurrency launched in 2015 and built from the ground up using its own blockchain technology. It was designed to be a more generalized protocol than Bitcoin’s blockchain, with the explicit goal of doing more than just creating and recording transfers of a blockchain network’s native tokens.
-
What is a Turing Complete programming language?
In computability theory, a system of data-manipulation rules such as a computer’s instruction set, a programming language, is said to be Turing-complete or computationally universal if it can be used to simulate any Turing machine. This means that this system is able to recognize or decide other data-manipulation rule sets. Turing completeness is used as a way to express the power of such a data-manipulation rule set. Virtually all programming languages today are Turing-complete. The concept is named after English mathematician and computer scientist Alan Turing.
A related concept is that of Turing equivalence – two computers P and Q are called equivalent if P can simulate Q and Q can simulate P.
A Turing machine can make decisions based on what it sees in memory - The ‘language’ that only supports +
, -
, *
, and /
on integers is not Turing complete because it can’t make a choice based on its input, but a Turing machine can.
A Turing machine can run forever - If we took Java, Javascript, or Python and removed the ability to do any sort of loop, GOTO, or function call, it wouldn’t be Turing complete because it can’t perform an arbitrary computation that never finishes. Coq is a theorem prover that can’t express programs that don’t terminate, so it’s not Turing complete.
A Turing machine can use infinite memory - A language that was exactly like Java but would terminate once it used more than 4 Gigabytes of memory wouldn’t be Turing complete, because a Turing machine can use infinite memory. This is why we can’t actually build a Turing machine, but Java is still a Turing complete language because the Java language has no restriction preventing it from using infinite memory. This is one reason regular expressions aren’t Turing complete.
A Turing machine has random access memory - A language that only lets you work with memory through push
and pop
operations to a stack wouldn’t be Turing complete. If I have a ‘language’ that reads a string once and can only use memory by pushing and popping from a stack, it can tell me whether every (
in the string has its own )
later on by pushing when it sees (
and popping when it sees )
. However, it can’t tell me if every (
has its own )
later on and every [
has its own ]
later on (note that ([)]
meets this criteria but ([]]
does not). A Turing machine can use its random access memory to track ()
's and []
's separately, but this language with only a stack cannot.
A Turing machine can simulate any other Turing machine - A Turing machine, when given an appropriate ‘program’, can take another Turing machine’s ‘program’ and simulate it on arbitrary input. If you had a language that was forbidden from implementing a Python interpreter, it wouldn’t be Turing complete.