Bitcoin Forum
May 05, 2024, 04:17:05 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the best language to write a miner in?  (Read 232 times)
HoBzY (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 2


View Profile
October 09, 2022, 04:40:16 PM
Last edit: December 06, 2022, 05:05:01 PM by HoBzY
 #1

What is the best language to write a miner in?
I HATE TABLES I HATE TABLES I HA(╯°□°)╯︵ ┻━┻ TABLES I HATE TABLES I HATE TABLES
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714925825
Hero Member
*
Offline Offline

Posts: 1714925825

View Profile Personal Message (Offline)

Ignore
1714925825
Reply with quote  #2

1714925825
Report to moderator
1714925825
Hero Member
*
Offline Offline

Posts: 1714925825

View Profile Personal Message (Offline)

Ignore
1714925825
Reply with quote  #2

1714925825
Report to moderator
1714925825
Hero Member
*
Offline Offline

Posts: 1714925825

View Profile Personal Message (Offline)

Ignore
1714925825
Reply with quote  #2

1714925825
Report to moderator
jackg
Copper Member
Legendary
*
Offline Offline

Activity: 2856
Merit: 3071


https://bit.ly/387FXHi lightning theory


View Profile
October 09, 2022, 05:03:57 PM
Merited by hugeblack (4), Welsh (3)
 #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.
n0nce
Hero Member
*****
Offline Offline

Activity: 882
Merit: 5818


not your keys, not your coins!


View Profile WWW
October 09, 2022, 05:12:11 PM
Merited by ABCbits (1)
 #3

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://bitcointalk.org/index.php?topic=5415861.0
cgminer (ASIC): https://bitcointalk.org/index.php?topic=5415335.0

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
HoBzY (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 2


View Profile
October 09, 2022, 05:27:25 PM
 #4

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++?
NotATether
Legendary
*
Online Online

Activity: 1596
Merit: 6728


bitcoincleanup.com / bitmixlist.org


View Profile WWW
October 09, 2022, 05:31:07 PM
Merited by Welsh (4), n0nce (2)
 #5

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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4616



View Profile
October 09, 2022, 06:45:30 PM
Merited by ABCbits (1)
 #6

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.
n0nce
Hero Member
*****
Offline Offline

Activity: 882
Merit: 5818


not your keys, not your coins!


View Profile WWW
October 09, 2022, 06:47:17 PM
 #7

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/.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
serhack
Member
**
Offline Offline

Activity: 107
Merit: 168

Security Researcher and Writer


View Profile WWW
October 09, 2022, 07:45:00 PM
 #8

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.

pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10549



View Profile
October 10, 2022, 04:35:13 AM
 #9

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.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
HoBzY (OP)
Newbie
*
Offline Offline

Activity: 24
Merit: 2


View Profile
October 10, 2022, 06:49:54 AM
Last edit: October 13, 2022, 12:33:46 PM by mprep
 #10

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]
tromp
Legendary
*
Offline Offline

Activity: 978
Merit: 1087


View Profile
October 10, 2022, 11:46:32 AM
 #11

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
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10549



View Profile
October 10, 2022, 01:38:25 PM
 #12

~
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

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
serhack
Member
**
Offline Offline

Activity: 107
Merit: 168

Security Researcher and Writer


View Profile WWW
October 10, 2022, 03:01:36 PM
 #13

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.

n0nce
Hero Member
*****
Offline Offline

Activity: 882
Merit: 5818


not your keys, not your coins!


View Profile WWW
October 10, 2022, 07:43:57 PM
 #14

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.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Skot
Full Member
***
Offline Offline

Activity: 212
Merit: 241

bitaxe.org


View Profile
October 12, 2022, 08:43:56 PM
 #15

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. 
Artem Sereda
Member
**
Offline Offline

Activity: 96
Merit: 10


View Profile
November 10, 2022, 12:37:14 PM
 #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.

VSYS.host — Anonymous Offshore Dedicated Servers & VPS with DDoS protection:UA/NL/US
SHKeeper.io — Self-Hosted & Open-Source Crypto Payment Processor
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!