Author

Topic: What is the best language to write a miner in? (Read 255 times)

member
Activity: 96
Merit: 10
November 10, 2022, 07:37:14 AM
#16
The one you're most comfortable writing with. Most of the time the language you use doesn't matter, most systems have APIs that allow you to call other programs in other languages too (like how python's os module lets you run command line tasks).

If you're fairly new to programming there's ups and downs to using langiages that are statically typed (like c based languages and java) and ones that are dynamically typed (like python).

If you find you're very comfortable (/enjoying) programming one specific language, whatever it is, write it in that. If you don't care, you could always try both types.


What is the best language for hash generation speed? Is it worth learning C++?


As already mentioned here, it all depends on your skills in this language. Python was recommended here before. I would still prefer this language. It makes it easier to manipulate data. And it's easier to learn.
full member
Activity: 225
Merit: 246
bitaxe.org
If you want to see how someone else did it in python, check this; https://github.com/ricmoo/nightminer

if you're trying to go soup to nuts you'll need to setup a stratum proxy to connect to your bitcoin node. I found that bfgminer (mentioned earlier) or ckpool (https://bitbucket.org/ckolivas/ckpool/src/master/) worked for this. 
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
I think I can understand it because I already know html/css/js/php/mysql web languages ​​and know python/c# and for learning blockchain mining I used python for test.
Oh dear. Web languages, Python and C# won't help you at all when trying to write highly optimized low-level code.

Anyhow, could you answer what your actual goal is in the first place? Is it just a coding exercise? If so, the answer is: 'The best language is the one you're comfortable with and that is fun to write'.
If you want to develop something that competes with existing software, maybe just fork what already exists and optimize it further.
If you want to use it for Bitcoin mining, don't even bother with programming languages and go for FPGA or ASIC design, which is a whole different beast; you'd be looking at learning and understanding chip design, then implement it in VHDL or Verilog, as tromp suggested.
member
Activity: 107
Merit: 168
Security Researcher and Writer
What is the best language to write a miner in?

If you're really expert and know what you're doing, for sure C is the most powerful programming language that allows you to think as a "machine". Assembly would be more performant but good luck not loosing your mind Cheesy

For people suggesting any OOP-based language or GC-based language, you're going to waste some helpful CPU burst on checking pointers, and allocations. C is a nightmare for pointers but it can allow you to write very efficient program without too much efforts. Unfortunately you need to master pointers management and you need to carefully think about the instruction cycle (fetch, decode, execute), pipelines and much more to waste CPU burst as few as possible.

I think I can understand it because I already know html/css/js/php/mysql web languages ​​and know python/c# and for learning blockchain mining I used python for test.

Yes, you might understand it without too much effort but the problem is optimizing that.
legendary
Activity: 3472
Merit: 10611
~
Can I have a couple of links to them? C is best learned by example.
@n0nce already posted two of them, both written in C:
https://github.com/luke-jr/bfgminer
https://github.com/cmmodtools/cgminer
legendary
Activity: 990
Merit: 1108
What is the best language to write a miner in?

Something like VHDL or Verilog [1].

[1] https://en.wikipedia.org/wiki/Hardware_description_language
newbie
Activity: 24
Merit: 2
What is the best language to write a miner in?

If you're really expert and know what you're doing, for sure C is the most powerful programming language that allows you to think as a "machine". Assembly would be more performant but good luck not loosing your mind Cheesy

For people suggesting any OOP-based language or GC-based language, you're going to waste some helpful CPU burst on checking pointers, and allocations. C is a nightmare for pointers but it can allow you to write very efficient program without too much efforts. Unfortunately you need to master pointers management and you need to carefully think about the instruction cycle (fetch, decode, execute), pipelines and much more to waste CPU burst as few as possible.

I think I can understand it because I already know html/css/js/php/mysql web languages ​​and know python/c# and for learning blockchain mining I used python for test.



What is the best language for hash generation speed? Is it worth learning C++?
If you don't already know the language you will not be able to write the most efficient code needed for mining in that language that you would be learning the basics for! Optimization is a complicated topic that you can start on at an advanced level.
Try using the existing code that other experts have already written.
Can I have a couple of links to them? C is best learned by example.

[moderator's note: consecutive posts merged]
legendary
Activity: 3472
Merit: 10611
What is the best language for hash generation speed? Is it worth learning C++?
If you don't already know the language you will not be able to write the most efficient code needed for mining in that language that you would be learning the basics for! Optimization is a complicated topic that you can start on at an advanced level.
Try using the existing code that other experts have already written.
member
Activity: 107
Merit: 168
Security Researcher and Writer
What is the best language to write a miner in?

If you're really expert and know what you're doing, for sure C is the most powerful programming language that allows you to think as a "machine". Assembly would be more performant but good luck not loosing your mind Cheesy

For people suggesting any OOP-based language or GC-based language, you're going to waste some helpful CPU burst on checking pointers, and allocations. C is a nightmare for pointers but it can allow you to write very efficient program without too much efforts. Unfortunately you need to master pointers management and you need to carefully think about the instruction cycle (fetch, decode, execute), pipelines and much more to waste CPU burst as few as possible.
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
What is the best language for hash generation speed? Is it worth learning C++?

It depends on your skills with the language.

It is possible to write some VERY inefficient and slow code in C, and some very fast and efficient code in other languages.  Choosing a language without having a good understanding of computing principles isn't going to get you the best possible results.
I believe if he had such understanding though, he wouldn't ask this question. So maybe best to use what's already available (if it's about performance), as I described above. Or use any language they like, if it's about education / learning, because performance doesn't matter.

We really need more information about the actual end goal, otherwise it's another https://xyproblem.info/.
legendary
Activity: 3472
Merit: 4801
What is the best language for hash generation speed? Is it worth learning C++?

It depends on your skills with the language.

It is possible to write some VERY inefficient and slow code in C, and some very fast and efficient code in other languages.  Choosing a language without having a good understanding of computing principles isn't going to get you the best possible results.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
What is the best language for hash generation speed? Is it worth learning C++?

Assuming mining difficulty is low enough for CPU mining. C++ for a command-line frontend is OK, but the mining library itself must be written in pure C (no STL constructs) or even better in assembly, for maximum performance.

I'd stay away from all other languages including Rust.
newbie
Activity: 24
Merit: 2
The one you're most comfortable writing with. Most of the time the language you use doesn't matter, most systems have APIs that allow you to call other programs in other languages too (like how python's os module lets you run command line tasks).

If you're fairly new to programming there's ups and downs to using langiages that are statically typed (like c based languages and java) and ones that are dynamically typed (like python).

If you find you're very comfortable (/enjoying) programming one specific language, whatever it is, write it in that. If you don't care, you could always try both types.


What is the best language for hash generation speed? Is it worth learning C++?
hero member
Activity: 882
Merit: 5834
not your keys, not your coins!
What is the best language to write a miner in?
Why would you want to write your own miner? There is open-source CPU, GPU and ASIC miner software for almost everything (and that you can adapt to your hardware if unsupported).

Recent topics about Bitcoin mining setup on Testnet.
bfgminer (CPU, GPU): https://bitcointalksearch.org/topic/guide-solo-mine-testnet-bitcoins-with-bfgminer-bitcoin-core-and-a-cpugpu-5415861
cgminer (ASIC): https://bitcointalksearch.org/topic/guide-solo-mine-testnet-bitcoins-with-cgminer-bitcoin-core-and-a-compac-f-5415335
copper member
Activity: 2856
Merit: 3071
https://bit.ly/387FXHi lightning theory
The one you're most comfortable writing with. Most of the time the language you use doesn't matter, most systems have APIs that allow you to call other programs in other languages too (like how python's os module lets you run command line tasks).

If you're fairly new to programming there's ups and downs to using langiages that are statically typed (like c based languages and java) and ones that are dynamically typed (like python).

If you find you're very comfortable (/enjoying) programming one specific language, whatever it is, write it in that. If you don't care, you could always try both types.
newbie
Activity: 24
Merit: 2
What is the best language to write a miner in?
Jump to: