<p>Yes, it is possible. A cryptocurrency is essentially a set of rules and network protocols that nodes can use to talk to one another to implement those rules. The reference implementation Bitcoin-Qt is implemented in C++, but there are other implementations (eg. Java). </p>

<p>The tricky part about implementing a client for an existing cryptocurrency in another programming language is that you must be careful to implement the rules in <em>exactly</em> the same way as all other implementations. If there are any changes (even such as fixing bugs present in the original) then the blockchain may fork and your client would need a patch to continue participating.</p>

<p>If you're creating a new cryptocurrency from scratch, of course you don't need to be concerned with replicating bugs in an existing client. However, you run the risk of introducing a whole new set of bugs.</p>

CC BY-SA 3.0
2014-02-10T01:47:43.633Z
The part of "even fixing bugs present in the original". At the end of Jan/14 the Dogecoin network forked into THREE different chains as a result of someone fixing a bug in the code - when changing the code to create Dogecoin, a part related to the size of blocks and the max. number of coins had been omitted in the required changes. "Fixing" it (i.e. applying the supposedly needed changes) resulted in chaos :(
Joe Pineda
CC BY-SA 3.0
2014-02-08T23:01:22.090Z
2014-02-08T23:01:22.090Z
Greg Hewgill
<p>I'm not sure if you mean a scripting language replacing C++ or replacing bitcoin's scripting language.
If you mean replacing C++, of course, php, python, ruby, javascript and, in general, most programming languages are as turing complete as C or C++. You can do anything doable with any of them. There's already bitcoin full nodes implemented in other languages such as java, I don't think python is too far from that if it's not implemented already.</p>

<p>If you mean the bitcoin's scripting language (<a href="https://en.bitcoin.it/wiki/Script" rel="nofollow">https://en.bitcoin.it/wiki/Script</a>), again, yes, it could be anything you want.
If you were going to replace bitcoin's scripts with a turing complete language, there's some risk you need to address. Here's a list of some potential attacks to the network abusing turing completeness:</p>

<p><a href="https://bitcointalk.org/index.php?topic=278122.0" rel="nofollow">https://bitcointalk.org/index.php?topic=278122.0</a></p>

<p>Most of Bitcoin's script operation are actually "disabled" for security reasons and re-enabling them would probably require a softfork or even a hardfork.</p>

<p>Aside from that, there's many reasons why you would want the scripting language to be very simple, because you want all the different implementations of the script interpreter to behave in exactly the same way, even optimized interpreters.</p>

<p>Here's a couple of critical requirements for a language:</p>

<p>"b. The script must be simple, as thousands of nodes world-wide running
multiple implementations will need to reach global consensus over not
just the outcome of a script, but also some aspects of the execution
(e.g. an instruction counter). Consensus failures whether due to bugs
or faulty designs can lead to unsecured payment networks and possible
losses in the millions of dollars or more. Interpreter escape would be
absolutely catastrophic. So simple, minimal, but expressive
architectures with simple fail-safe implementations are to be
preferred over complex but user-friendly (RISC is better than CISC).</p>

<p>c. The language must support the various cryptographic primitives
necessary for performing core bitcoin functions. Mostly this just
means adding a handful of builtin words for performing strong
cryptographic hashes and elliptic curve signature verification, but
there are some requirements on the language design as well, chiefly in
making decisions about how the stack is represented for hash
operations and in supporting authenticated data structures as
primitive types for external state."</p>

<p>Taken from:
<a href="https://groups.yahoo.com/neo/groups/concatenative/conversations/messages/4950" rel="nofollow">https://groups.yahoo.com/neo/groups/concatenative/conversations/messages/4950</a></p>

<p>Basically, it would be a bad idea to use directly a language as powerful as python for the scripting, but you could have a more simple language, let's call it secureScript and build a compiler from python to secureScript.</p>

CC BY-SA 3.0
2014-02-09T14:06:12.013Z
2014-02-09T14:06:12.013Z
jtimon
<p>Yes it is completely possible. Bitcoin is not using any special features in the C++ program that aren't possible in other programs. If your programming language can do the following you are good to go. Although I suspect any programming language will pass this test.</p>

<ul>
<li>Ability to communicate with other computers over a network</li>
<li>Ability to store data</li>
<li>Ability to do basic math as well as advanced math needed for cryptographic functions</li>
</ul>

<p>That's it really, you can probably make a Bitcoin clone in any language, the only thing that stands in your way is inefficiency. C++ is really fast and does the calculations Bitcoin needs with milliseconds. JavaScript may be significantly slower but still usable.</p>

CC BY-SA 3.0
2014-02-09T03:42:30.237Z
2014-02-09T03:42:30.237Z
John T
<p>Just wondering if this is even possible.  If so, are there any practical reasons not to?</p>

CC BY-SA 3.0
2014-02-09T14:07:27.940Z
You should state whether you mean replacing the programming language implementing Bitcoin (C++) or the internal scripting language.
jtimon
CC BY-SA 3.0
2014-02-09T16:28:21.120Z
All languages that are turing complete are turing complete
Loourr
<development>
Would it be theoretically possible to make a Cryptocurrency in a scripting language like PHP, Python, or Ruby?
diodepain
# Would it be theoretically possible to make a Cryptocurrency in a scripting language like PHP, Python, or Ruby?

(Asked by: username_0 on 2014-02-08)

Just wondering if this is even possible. If so, are there any practical reasons not to?

**Tags:** development

> **Comments:**
> **username_1**: You should state whether you mean replacing the programming language implementing Bitcoin (C++) or the internal scripting language.  
> **username_2**: All languages that are turing complete are turing complete  

---

## 3 answers

### Answer by username_3 on 2014-02-08. Score: 3

Yes, it is possible. A cryptocurrency is essentially a set of rules and network protocols that nodes can use to talk to one another to implement those rules. The reference implementation Bitcoin-Qt is implemented in C++, but there are other implementations (eg. Java).

The tricky part about implementing a client for an existing cryptocurrency in another programming language is that you must be careful to implement the rules in *exactly* the same way as all other implementations. If there are any changes (even such as fixing bugs present in the original) then the blockchain may fork and your client would need a patch to continue participating.

If you're creating a new cryptocurrency from scratch, of course you don't need to be concerned with replicating bugs in an existing client. However, you run the risk of introducing a whole new set of bugs.

> **Comments:**
> **username_4**: The part of "even fixing bugs present in the original". At the end of Jan/14 the Dogecoin network forked into THREE different chains as a result of someone fixing a bug in the code - when changing the code to create Dogecoin, a part related to the size of blocks and the max. number of coins had been omitted in the required changes. "Fixing" it (i.e. applying the supposedly needed changes) resulted in chaos :(  

---

### Answer by username_1 on 2014-02-09. Score: 1

I'm not sure if you mean a scripting language replacing C++ or replacing bitcoin's scripting language.
If you mean replacing C++, of course, php, python, ruby, javascript and, in general, most programming languages are as turing complete as C or C++. You can do anything doable with any of them. There's already bitcoin full nodes implemented in other languages such as java, I don't think python is too far from that if it's not implemented already.

If you mean the bitcoin's scripting language (<https://en.bitcoin.it/wiki/Script>), again, yes, it could be anything you want.
If you were going to replace bitcoin's scripts with a turing complete language, there's some risk you need to address. Here's a list of some potential attacks to the network abusing turing completeness:

<https://bitcointalk.org/index.php?topic=278122.0>

Most of Bitcoin's script operation are actually "disabled" for security reasons and re-enabling them would probably require a softfork or even a hardfork.

Aside from that, there's many reasons why you would want the scripting language to be very simple, because you want all the different implementations of the script interpreter to behave in exactly the same way, even optimized interpreters.

Here's a couple of critical requirements for a language:

"b. The script must be simple, as thousands of nodes world-wide running
multiple implementations will need to reach global consensus over not
just the outcome of a script, but also some aspects of the execution
(e.g. an instruction counter). Consensus failures whether due to bugs
or faulty designs can lead to unsecured payment networks and possible
losses in the millions of dollars or more. Interpreter escape would be
absolutely catastrophic. So simple, minimal, but expressive
architectures with simple fail-safe implementations are to be
preferred over complex but user-friendly (RISC is better than CISC).

c. The language must support the various cryptographic primitives
necessary for performing core bitcoin functions. Mostly this just
means adding a handful of builtin words for performing strong
cryptographic hashes and elliptic curve signature verification, but
there are some requirements on the language design as well, chiefly in
making decisions about how the stack is represented for hash
operations and in supporting authenticated data structures as
primitive types for external state."

Taken from:
<https://groups.yahoo.com/neo/groups/concatenative/conversations/messages/4950>

Basically, it would be a bad idea to use directly a language as powerful as python for the scripting, but you could have a more simple language, let's call it secureScript and build a compiler from python to secureScript.


---

### Answer by username_5 on 2014-02-09. Score: 1

Yes it is completely possible. Bitcoin is not using any special features in the C++ program that aren't possible in other programs. If your programming language can do the following you are good to go. Although I suspect any programming language will pass this test.

* Ability to communicate with other computers over a network
* Ability to store data
* Ability to do basic math as well as advanced math needed for cryptographic functions

That's it really, you can probably make a Bitcoin clone in any language, the only thing that stands in your way is inefficiency. C++ is really fast and does the calculations Bitcoin needs with milliseconds. JavaScript may be significantly slower but still usable.


---

