Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: MrCrank on February 08, 2018, 09:28:42 AM



Title: Is Python good for bitcoin apps?
Post by: MrCrank on February 08, 2018, 09:28:42 AM
Hi,

I want know, Is Python good for bitcoin apps?

I want to try make easy bitcoin app and heard that Python is best for coding blockchain..
Is it really? (I choose new stack for code)

or best stack MEAN?

What language you use for coding?

Thanks.


Title: Re: Is Python good for bitcoin apps?
Post by: bob123 on February 08, 2018, 11:50:08 AM
I want know, Is Python good for bitcoin apps?

Depends on what you mean with "apps".
Python is a scripting language.
You won't be able to comfortably code "big" software using python

For small scripts, sure.. python is awesome IMO.



I want to try make easy bitcoin app and heard that Python is best for coding blockchain..
Is it really?

There is no "best for coding blockchain".
Blockchain is a technology. Bitcoin utilizes blockchain.

The best programming language to code scripts/programs is the one you are most comfortable with!

If you are just starting to program and you don't want to code a wallet like electrum from scratch i would say Python is pretty good to get started.
Its straight forward and lets you pretty much "do whatever you want" without having to worry about memory allocation, etc.. too much



What language you use for coding?

I personally use either C, Java or Python.
Most preferably i use python because.. well.. its basically like writing pseudo code.
Additionally you can basically modify strings/data in python any way you want without having to write 100's of lines just for a simple modifying function.


Title: Re: Is Python good for bitcoin apps?
Post by: jackg on February 08, 2018, 11:51:45 AM
Python is used a lot of programming apps as it's easier to program and is a bit more forgiving syntax wise than other programming languages are.

There are some useful code snippets on github depending on what specifically you're trying to program for? If you want to look into basic stuff, there's a Python module called Bitcoin-tools that might be helpful if you don't want to code from scratch.

As an extra note, Python is quite slow as a language to run (not entirely sure why) so you can't make really complex stuff using it, for that you'd turn to C/C#/C++.


Title: Re: Is Python good for bitcoin apps?
Post by: Julia_KA on February 08, 2018, 11:55:58 AM
Python is used a lot of programming apps as it's easier to program and is a bit more forgiving syntax wise than other programming languages are.

There are some useful code snippets on github depending on what specifically you're trying to program for? If you want to look into basic stuff, there's a Python module called Bitcoin-tools that might be helpful if you don't want to code from scratch.
Thank you for a cool tip! Will definitely check github out. I'm not that good at Python but it's interesting to see what people came up with. Thanks again!  :D


Title: Re: Is Python good for bitcoin apps?
Post by: bob123 on February 08, 2018, 12:43:22 PM
As an extra note, Python is quite slow as a language to run (not entirely sure why) ...

For the ones of you who are interested in why phyton is slower than other languages (C for example):

1) Python is more of a interpreted than compiled language. (This is dependend on the implementation. Bust mostly its interpreted)


2) Initialization of variables is dynamically, not statically.
In C the compiler knows the type of a variable by its definition.
In Python the interpreter only knows that assigned variables are objects. The interpreter has to create/initialize a new python object to hold the returned value when the code is already running.


3) Pythons object model leads to inefficient memory access
Regarding Arrays:
In C you have a pointer to a contiguous data buffer.
In Python (list) you have a pointer to a contiguous buffer of pointers, each of which points to a python object which has references to its data.
This make python more expensive in terms of storage and access time.



Title: Re: Is Python good for bitcoin apps?
Post by: bitcoinvamp on February 08, 2018, 05:41:00 PM
Hi,

I want know, Is Python good for bitcoin apps?

I want to try make easy bitcoin app and heard that Python is best for coding blockchain..
Is it really? (I choose new stack for code)

or best stack MEAN?

What language you use for coding?

Thanks.
I think choosing a language is not what matters but what matter is that in which language you are more comfortable and which language you know better. But i guess python is way more easy to operate than java , c++ or even C . I personally like to use either python or perl both are extremely easy to use compared to java and c++. Python is preferred more because it can be compiled into a executable code or even can run uncompiled. Python is way easier to understand even for beginners so choosing python over java and C++ will be a good choice.


Title: Re: Is Python good for bitcoin apps?
Post by: TechPriest on February 08, 2018, 10:12:08 PM
But i guess python is way more easy to operate than java , c++ or even C . I personally like to use either python or perl both are extremely easy to use compared to java and c++
Python is good for script programs: parsers, bots and others.
But many "big" programs writed on Python. Pywallet, electrum and others.

Python is preferred more because it can be compiled into a executable code or even can run uncompiled.
Every code can be compiled into exe.
You can run code uncompiled only if you have python interpreter.

Python is way easier to understand even for beginners so choosing python over java and C++ will be a good choice.

It's hard to say what's "easier". It depends what you are learning before in your life.


Title: Re: Is Python good for bitcoin apps?
Post by: Welsh on February 08, 2018, 11:07:13 PM
Python is considered simple by nature and is a little easier to pick up than some programming languages which require a little bit more work to get things to work but, I believe you can learn more from actually running into more problems and figuring them out. The easy way isn't always the most beneficial.
 


Title: Re: Is Python good for bitcoin apps?
Post by: MrCrank on February 09, 2018, 01:53:02 AM
I want create script and use blockchain node API and create "little" online/offline game  :)

Thanks for answers.
I will try get few lessons "Python coding" and
after will make choose.


Title: Re: Is Python good for bitcoin apps?
Post by: GarrySingh on February 09, 2018, 05:49:14 AM
Hi,

I want know, Is Python good for bitcoin apps?

I want to try make easy bitcoin app and heard that Python is best for coding blockchain..
Is it really? (I choose new stack for code)

or best stack MEAN?

What language you use for coding?

Thanks.
According to me, if you have complete knowledge of even one kind of programming language, you won't find it difficult to understand a code in another language, I don't think it is necessary to learn python from scratch for this purpose.


Title: Re: Is Python good for bitcoin apps?
Post by: jackg on February 09, 2018, 04:26:41 PM
I want create script and use blockchain node API and create "little" online/offline game  :)

Thanks for answers.
I will try get few lessons "Python coding" and
after will make choose.


JSON and URLLIB (preisntalled in Python are helpful - if you are pulling info from it). I started fiddling with pulling block data from it.

They do have a limit of one request per 10 seconds which is quite slow if you want to pull quite a few blocks (I haven't tried going below it but now and again if you make 2 requests in the same 10 seconds it might go unnoticed).


Title: Re: Is Python good for bitcoin apps?
Post by: Welsh on February 10, 2018, 02:32:25 AM
I want create script and use blockchain node API and create "little" online/offline game  :)

Thanks for answers.
I will try get few lessons "Python coding" and
after will make choose.


You could tie into that via Python. I would imagine that there's several APIs out there which support the blockchain and Python. Bitcoin is written in c++ but, isn't one of the easiest languages to learn as it's quite awkward in certain areas.


Title: Re: Is Python good for bitcoin apps?
Post by: aplistir on February 10, 2018, 08:55:32 AM
I want know, Is Python good for bitcoin apps?

Python is excellent for bitcoin apps.
What makes is so good is that it already has good easy to use libraries for doing all the math behind bitcoin.
Support for: big numbers, SHA256, ripemod160, elliptic curve operations etc...

Those can be a real PITA if you have to write any of them in C++, or whatever.
Actually C++ also has some libraries you can use, but at least those that I have seen are quite difficult to use and complicated.

On python being slower... yes, compiled languages are faster, but you wont be needing to use the full capabilities of a computer for doing bitcoin operations. 

One example of a python program is Electrum


Title: Re: Is Python good for bitcoin apps?
Post by: bestr17 on February 10, 2018, 10:18:20 AM
I would say that if you plan on working on wallet software, learn javascript and how Node.js works.
If you would like to work on bitcoin's core components and someday be a Satoshi 2.0... then learning C++ is the way to go.
If you want to be and all-rounder. Python is an amazing language, and can do things all the way from powering wallets like Electrum and Armory, all the way to powering blockchain parsers and the like.

If I had to pick one, I'd say Python. It's easy to learn.


Title: Re: Is Python good for bitcoin apps?
Post by: bob123 on February 10, 2018, 11:14:03 AM
I would say that if you plan on working on wallet software, learn javascript..

No. Just no.

Some reasons for javascript to suck hard:
  • JS supports "Number" as the only number format -> Supports only 64bit Doubles
    The problem with large intergers with floating point variables is, that you won't be able to represent large number correctly.
    99999999999999999 == 100000000000000000 evaluates to true in javascript.
    Its kinda suicide to use javascript for handling large numbers (private-/public keys).
  • JavaScript heavily depends on global variables.
    You not just can use them.. you have to use them. This makes it a pain in the ass to get a structure over a complex program (e.g. wallet)
  • There are a lot of traps you have to watch out in JS
    For example: -1 < Number.MIN_VALUE returns true, because Number.MIN_VALUE returns the lowest positive number and the real lowest number is -Number.MAX_VALUE
  • JS has a TON of vulnerabilities. You don't want to have security vulnerabilities in your wallet. To name the most common JS is so vulnerable to: XSS[1] and CSRF[2]


Those were a few reasons. There are way more.
But this should give a small insight why you shouldn't use javascript to code a wallet. In fact, you shouldn't use javascript at all.


[1] https://en.wikipedia.org/wiki/Cross-site_scripting (https://en.wikipedia.org/wiki/Cross-site_scripting)
[2] https://en.wikipedia.org/wiki/Cross-site_request_forgery (https://en.wikipedia.org/wiki/Cross-site_request_forgery)


Title: Re: Is Python good for bitcoin apps?
Post by: MysteryMiner on February 10, 2018, 11:35:44 AM
As a interpreted language instead of compiled, it is not good for anything serious. Python is modern day version of 90ties Visual Basic.


Title: Re: Is Python good for bitcoin apps?
Post by: bob123 on February 10, 2018, 05:25:05 PM
As a interpreted language instead of compiled, it is not good for anything serious. Python is modern day version of 90ties Visual Basic.

You do realize that:
1) Python scripts can be compiled and
2) Electrum is written in python

Your statement is completely senseless. Unless, of course, you consider electrum as "not serious".
Python is one of the (if not) the best scripting langauge to process/handle data and strings.
It provides a lot of useful functions which you would have to write yourself in other languages (e.g. C/C++/Java).


Title: Re: Is Python good for bitcoin apps?
Post by: jackg on February 10, 2018, 06:21:08 PM
As a interpreted language instead of compiled, it is not good for anything serious. Python is modern day version of 90ties Visual Basic.

You do realize that:
1) Python scripts can be compiled and
2) Electrum is written in python

Your statement is completely senseless. Unless, of course, you consider electrum as "not serious".
Python is one of the (if not) the best scripting langauge to process/handle data and strings.
It provides a lot of useful functions which you would have to write yourself in other languages (e.g. C/C++/Java).

I think MysteryMiner is referring to the main console only allowing interpreting of the software.

Microsoft and other companies have made powerful compilers of it though however and yes electrum is mostly written in Python. Even theymos says they like to use electrum for small amounts of bitcoins that he wants to transfer/store.


Title: Re: Is Python good for bitcoin apps?
Post by: MysteryMiner on February 10, 2018, 07:09:11 PM
As a interpreted language instead of compiled, it is not good for anything serious. Python is modern day version of 90ties Visual Basic.

You do realize that:
1) Python scripts can be compiled and
2) Electrum is written in python

Your statement is completely senseless. Unless, of course, you consider electrum as "not serious".
Python is one of the (if not) the best scripting langauge to process/handle data and strings.
It provides a lot of useful functions which you would have to write yourself in other languages (e.g. C/C++/Java).
Yes, I realize that
1) is true
2) also is true.

I consider Electrum as usable software, just as other software written in Python. But remember that a lot of hacking software in early 2000 was written in Visual Basic. It worked, but was nightmare, all those ocx files and also for just simple sending few magic packets and repeating it made like 700KB executable files while same functionality could be implemented in C/C++ that weighs less than 4KB.

Can You optimize Python program to take advantage of various CPU hardware features same as C with inline Assembler does? I doubt. Python is high-level programming/scripting language. By definition it cannot be as good and powerful as low level language like C and ASM. Only advantage of high level language is relatively fast development, ease of portability between Windows and *nix and it is friendly to noobish programmers.


Title: Re: Is Python good for bitcoin apps?
Post by: TechPriest on February 10, 2018, 09:19:54 PM
Only advantage of high level language is relatively fast development, ease of portability between Windows and *nix and it is friendly to noobish programmers.

I counted four in your text. Also, i can tell about one more advantage: high level language is better for small projects, like blockchain parser or transaction accelerator or data storage.


Title: Re: Is Python good for bitcoin apps?
Post by: MysteryMiner on February 10, 2018, 09:54:28 PM
Only advantage of high level language is relatively fast development, ease of portability between Windows and *nix and it is friendly to noobish programmers.

I counted four in your text. Also, i can tell about one more advantage: high level language is better for small projects, like blockchain parser or transaction accelerator or data storage.
Portability and noob friendliness is not advantages. I do not care about other OS than one running on my computer. Fast development also does not matter. Once a software is written, it is.


Title: Re: Is Python good for bitcoin apps?
Post by: MrCrank on February 11, 2018, 04:13:47 PM
Thanks to all for details info and your adiveces.
I choose Python for start :)

P.s. I want to create "small" project, this will be not highload and scale project.


Title: Re: Is Python good for bitcoin apps?
Post by: vv181 on February 12, 2018, 07:37:35 AM
I want create script and use blockchain node API and create "little" online/offline game  :)

Thanks for answers.
I will try get few lessons "Python coding" and
after will make choose.

The variety of library that Python have give you a lot of API support to play around, I'm sure it will give you a lot of option. But I doubt Python would be good for a game, I'm sure there are better programming languages for it, and also the leading game engines don't support Python.

Thanks to all for details info and your adiveces.
I choose Python for start :)

P.s. I want to create "small" project, this will be not highload and scale project.
That is the beauty of Python its good for the small project, but when the project getting bigger the performance will be decreased.


Title: Re: Is Python good for bitcoin apps?
Post by: MrCrank on February 12, 2018, 07:57:30 AM
I want create script and use blockchain node API and create "little" online/offline game  :)

Thanks for answers.
I will try get few lessons "Python coding" and
after will make choose.

The variety of library that Python have give you a lot of API support to play around, I'm sure it will give you a lot of option. But I doubt Python would be good for a game, I'm sure there are better programming languages for it, and also the leading game engines don't support Python.

Thanks to all for details info and your adiveces.
I choose Python for start :)

P.s. I want to create "small" project, this will be not highload and scale project.
That is the beauty of Python its good for the small project, but when the project getting bigger the performance will be decreased.

Python don't support game engines? :(
I don't know about it..  Unity is best easy engine.
need find info about game engines support Python


Title: Re: Is Python good for bitcoin apps?
Post by: ivannnn on February 18, 2018, 10:37:59 AM
I am agreed the following opinions.   Python is a scrpit lang, not for big program.


I want know, Is Python good for bitcoin apps?

Depends on what you mean with "apps".
Python is a scripting language.
You won't be able to comfortably code "big" software using python

For small scripts, sure.. python is awesome IMO.



I want to try make easy bitcoin app and heard that Python is best for coding blockchain..
Is it really?

There is no "best for coding blockchain".
Blockchain is a technology. Bitcoin utilizes blockchain.

The best programming language to code scripts/programs is the one you are most comfortable with!

If you are just starting to program and you don't want to code a wallet like electrum from scratch i would say Python is pretty good to get started.
Its straight forward and lets you pretty much "do whatever you want" without having to worry about memory allocation, etc.. too much



What language you use for coding?

I personally use either C, Java or Python.
Most preferably i use python because.. well.. its basically like writing pseudo code.
Additionally you can basically modify strings/data in python any way you want without having to write 100's of lines just for a simple modifying function.


Title: Re: Is Python good for bitcoin apps?
Post by: nongmo on February 19, 2018, 01:32:21 PM
python works,
java
Javascript

but to make apps or or software with GUI
java to android
objective C to IOS

crypto kittes was built in Javascipt using the ethereum network so if you want to down that route google that.

javascript can be ported to most of these but that can be said to with most languages now in 2018.

just go for a language you belive in or that looks and feels good to you.



Title: Re: Is Python good for bitcoin apps?
Post by: icohdcoin on February 19, 2018, 09:12:28 PM
There are a lot of bitcoin projects built with Python.

Large ones (Electrum, Armory), libraries and utility scripts.

If I am starting a larger bitcoin project I would probably prefer a language with static type checking but still has similar memory safety (like C# or Java/Kotlin)