5

When checking out open source projects related to Bitcoin, I see that many are written in, or make a large use of, Python language. I mostly use Ruby and have little experience in Python; so, I would like to know why this is the case.

On this Github search result, you can see that Python is ranked second when you search the keyword 'bitcoin'.

  • 1
    It's not limited to Bitcoin, but Python is generally popular in financial technology projects due to reasons mentioned in the answers. – Mikko Ohtamaa Oct 29 '14 at 12:23
  • I'll have to get a rundown on Ruby to let you know why Python is better but follow along with Richard Kiss' blog post in my answer to see how great Python is (use Python v 2.7) – Wizard Of Ozzie Oct 30 '14 at 1:23
  • There is now Python framework for developing cryptoasset applications: bitbucket.org/miohtama/cryptoassets (disclaimer: I am one of authors) – Mikko Ohtamaa Feb 6 '15 at 10:12
8

In comparison to languages like Java or C++, Python has several advantages for coding bitcoin projects:

  • Simplified rules of coding allows beginners and experienced alike to code and get results without getting bogged down in formatting etc
  • Shell allows on the fly calculations
  • Python code is easily read and as such can be edited to suit
  • Python can be compiled into an executable or run uncompiled

I suppose in essence, Python is great for small scripts/applications and these small applications often align with difficult Bitcoin protocol mechanisms which are greatly simplified.

The caveat of course is that most Bitcoin Python utilities (Pybitcointools, Pycoin, sx/libitcoin require Python version 2, whereas Python 3 is the current release and, mind-bogglingly, 3.x is not backwards compatible with Python 2

If you want to get a feel for what Python can offer check out either:

  • I think a lot of projects are moving toward Python 3 compatibility ATM, even if not there yet. – Mikko Ohtamaa Oct 29 '14 at 12:22
  • @MikkoOhtamaa yes, you're right. It just blew me away when I asked the question "why won't my Python 2 work in Python 3?" and the answer was a well accepted "no back comptability" – Wizard Of Ozzie Oct 30 '14 at 0:49
  • You can write Python which is directly compatible with Python 2 and Python 3. But most people didn't. Now the world is slowly transition to the phase the libraries run on both. – Mikko Ohtamaa Oct 30 '14 at 11:04
3

I'm using pycoin (https://github.com/richardkiss/pycoin) in a project right now actually, tring to verify the data that needs to be signed in a bitcoin transaction, so I think I can speak to this.

  • Python is good because it's easy to get projects up and running quickly.
  • There are libraries that take the work out of things like ECDSA.
  • Python is a more accessible language than trying to code in C++, with all those pointers and references, not to mention compiling. Running on an interpreted language like python has the advantage here.

The disadvantage, however, is that python will not be scalable enough for all applications. There's a reason why the Core client, for example, wasn't written in python.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.