Bitcoin Forum
April 27, 2024, 05:23:25 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: why was bitcoin written in C++ instead of pure C?  (Read 424 times)
ekiro (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 101


View Profile
March 06, 2024, 06:17:38 AM
 #1

why
1714238605
Hero Member
*
Offline Offline

Posts: 1714238605

View Profile Personal Message (Offline)

Ignore
1714238605
Reply with quote  #2

1714238605
Report to moderator
TalkImg was created especially for hosting images on bitcointalk.org: try it next time you want to post an image
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714238605
Hero Member
*
Offline Offline

Posts: 1714238605

View Profile Personal Message (Offline)

Ignore
1714238605
Reply with quote  #2

1714238605
Report to moderator
Mia Chloe
Sr. Member
****
Offline Offline

Activity: 322
Merit: 493


Math + Code = Blockchain 😁


View Profile
March 06, 2024, 06:29:44 AM
Merited by pooya87 (2)
 #2

C++ is a more complex language more like an advanced c sharp. Plus it has some extra attributes and is kind of more reliable than C sharp.

▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
MΞTAWIN  THE FIRST WEB3 CASINO██████
██
██
██
██
██
██
██

██

██

██

██

██████
.
 PLAY NOW 
██████
██
██
██
██
██
██
██

██

██

██

██

██████
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10505



View Profile
March 06, 2024, 07:00:15 AM
Merited by vapourminer (1), Mia Chloe (1)
 #3

In a big application such as a Full Node with a lot of different parts, you don't need to write everything in such a high level language such as C (or even C++ for that matter if you ask me). Usage of C (and in some cases using assembly like in libsec256k1 used for cryptography) is most useful when you want as much efficiency as you can get.

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

Activity: 308
Merit: 267


Baba God Noni


View Profile
March 06, 2024, 07:22:53 AM
Last edit: March 06, 2024, 07:38:51 AM by Ruttoshi
 #4

Satoshi basic idea was to create a blockchain network that will make financial interactions easy, and make the process very fast. C++ is the best coding language for such

C++ algorithms can perform at the best level by maximizing resource use and giving the developer control over the CPU and memory use. This algorithm also allows the blockchain to accept or reject blocks, thus eradicating any forks in the blockchain. Using C++, therefore, helps the platform interact with different endpoints at fast rates.

C++ is the extension of C, and C is a low level programming. C++ has some extra features/libraries one can rely on. C++ is good with complex software.

https://cryptoadventure.com/why-satoshi-nakamoto-chose-c-to-program-bitcoin/


.
Duelbits
▄▄█▄▄░░▄▄█▄▄░░▄▄█▄▄
███░░░░███░░░░███
░░░░░░░░░░░░░
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░░░░███▄█░░░
░░██▌░░███░▀░░██▌
█░██░░███░░░██
█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀
.
REGIONAL
SPONSOR
███▀██▀███▀█▀▀▀▀██▀▀▀██
██░▀░██░█░███░▀██░███▄█
█▄███▄██▄████▄████▄▄▄██
██▀ ▀███▀▀░▀██▀▀▀██████
███▄███░▄▀██████▀█▀█▀▀█
████▀▀██▄▀█████▄█▀███▄█
███▄▄▄████████▄█▄▀█████
███▀▀▀████████████▄▀███
███▄░▄█▀▀▀██████▀▀▀▄███
███████▄██▄▌████▀▀█████
▀██▄█████▄█▄▄▄██▄████▀
▀▀██████████▄▄███▀▀
▀▀▀▀█▀▀▀▀
.
EUROPEAN
BETTING
PARTNER
Mia Chloe
Sr. Member
****
Offline Offline

Activity: 322
Merit: 493


Math + Code = Blockchain 😁


View Profile
March 06, 2024, 07:48:23 AM
Merited by Pmalek (2), vapourminer (1), Amphenomenon (1)
 #5

Satoshi basic idea was to create a blockchain network that will make financial interactions easy, and make the process very fast. C++ is the best coding language for such

C++ algorithms can perform at the best level by maximizing resource use and giving the developer control over the CPU and memory use. This algorithm also allows the blockchain to accept or reject blocks, thus eradicating any forks in the blockchain. Using C++, therefore, helps the platform interact with different endpoints at fast rates. 

https://cryptoadventure.com/why-satoshi-nakamoto-chose-c-to-program-bitcoin/


Aside from all these you mentioned, Satoshi pick C++ not only because it was the best but it was also the most efficient one for the job at that time.  C++ was picked because many developers at that time knew how to program with it and there were not much alternatives like SOLIDITY and move had not even been invented at that time. Others like Go and rust at that time were not too common.

The block chain is a whole lot of complex cryptographic data so  using C sharp as a base code will bring a lot of bugs because of its inefficiency to carry such heavy program. Plus C sharp doesn't contain certain complex attributes like C++

▄▄███████▄▄
▄██████████████▄
▄██████████████████▄
▄████▀▀▀▀███▀▀▀▀█████▄
▄█████████████▄█▀████▄
███████████▄███████████
██████████▄█▀███████████
██████████▀████████████
▀█████▄█▀█████████████▀
▀████▄▄▄▄███▄▄▄▄████▀
▀██████████████████▀
▀███████████████▀
▀▀███████▀▀
MΞTAWIN  THE FIRST WEB3 CASINO██████
██
██
██
██
██
██
██

██

██

██

██

██████
.
 PLAY NOW 
██████
██
██
██
██
██
██
██

██

██

██

██

██████
Flavatron
Jr. Member
*
Offline Offline

Activity: 38
Merit: 22


View Profile
March 06, 2024, 10:11:58 AM
Merited by BlackHatCoiner (4), vapourminer (2), ranochigo (2), ABCbits (2), NotATether (2), DdmrDdmr (1)
 #6

I think the OP asked about C, and C++ ... not c# which is totally different. For the most part, the performance of C and C++ are almost identical in most cases if you were not to use the Object Orientated features(like  inheritance, classes, templates, and some others). C# is a high level level language and not really comparable with either of the above, it's level of abstraction is probably on par with Python.

As others have said too, RUST( which in most cases is set to replace c++ by todays estimation, at least it's the plan for some, like the US Biden admin) wasn't even released in 2007. C++ was basically the defacto language for high performance applications.
BlackHatCoiner
Legendary
*
Online Online

Activity: 1498
Merit: 7294


Farewell, Leo


View Profile
March 06, 2024, 01:28:10 PM
Merited by Pmalek (2), apogio (1)
 #7

Because Bitcoin is complex, and complex projects are better to be programmed in object oriented programming. It also comes with rich libraries like STL, which reduce the overall chance for making a mistake, and it improves performance.

C is (usually) faster than C++, but I wouldn't want Bitcoin's source code to be a monster like the Linux kernel, even if it was slightly faster (which isn't necessarily to be the case).

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
promise444c5
Full Member
***
Offline Offline

Activity: 266
Merit: 128


Keep Promises !


View Profile
March 06, 2024, 02:20:23 PM
Last edit: March 08, 2024, 07:04:38 AM by promise444c5
Merited by _act_ (5), Justbillywitt (3), Pmalek (2), Mr.suevie (2), Kelward (2), vapourminer (1), DdmrDdmr (1)
 #8

I think the OP asked about C, and C++ ... not c# which is totally different. For the most part, the performance of C and C++ are almost identical in most cases if you were not to use the Object Orientated features(like  inheritance, classes, templates, and some others). C# is a high level level language and not really comparable with either of the above, it's level of abstraction is probably on par with Python.

As others have said too, RUST( which in most cases is set to replace c++ by todays estimation, at least it's the plan for some, like the US Biden admin) wasn't even released in 2007. C++ was basically the defacto language for high performance applications.
Yeah C# is more of object oriented  and it has some frameworks which are dedicated to almost every  aspect of development.
I've  tried python a little and I can't  compare it's level of OOP to that of C# although they kind of have some related calls but different implementation.

C++ and C# C are more  popular with Embedded  system, C++ provides much more scalability than C (which means it will be easy to read than C) but in term of performance  C performs morre faster


pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10505



View Profile
March 06, 2024, 04:04:14 PM
Merited by vapourminer (1), apogio (1)
 #9

Since C# was brought up let me add that C# depends on dotnet framework (today that's just called dotnet) by 2007/2008 there were only dotnet framework 3.5 and it was closed source. Microsoft only started releasing the source code on January 2008 which meant when Satoshi was coding Bitcoin it was neither mature nor reviewed enough to be used for something as critical as Bitcoin which relied on security.

Today that's different since dotnet is now open source and very mature which can compete with C++ even in speed and efficiency.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
apogio
Sr. Member
****
Online Online

Activity: 420
Merit: 948



View Profile WWW
March 06, 2024, 04:48:26 PM
 #10

why

Everything I wanted to add has already been mentioned. C++ is a smart choice in my opinion. Low level language with high compatibility and ease of writting. C can be a pain in the ...
Let me ask the obvious question.
Why do you think it should be written in C? What would be the benefits. I can't see any benefits apart from speed but C++ is also a very fast language.



DaveF
Legendary
*
Offline Offline

Activity: 3458
Merit: 6235


Crypto Swap Exchange


View Profile WWW
March 06, 2024, 05:25:46 PM
Merited by pooya87 (2), vapourminer (1), ABCbits (1)
 #11

Just putting it out there....it's what Satoshi knew and was comfortable with.

This question has also been asked many times though the years:

https://www.quora.com/Why-is-bitcoin-written-in-C
https://bitcoin.stackexchange.com/questions/48414/why-is-bitcoin-written-in-c
and so on.

In the end it really does not matter, since if the current devs wanted to switch they could.
But none of them seem to want to.

-Dave

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
odolvlobo
Legendary
*
Offline Offline

Activity: 4298
Merit: 3209



View Profile
March 07, 2024, 01:22:43 AM
 #12

Quote
why was bitcoin written in C++ instead of pure C?

I don't think satoshi has ever explained why he chose C++. Anyone can tell you why they would use C++ or C, but only satoshi can answer your question.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
NotATether
Legendary
*
Online Online

Activity: 1582
Merit: 6688


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 07, 2024, 07:59:24 AM
Merited by NeuroticFish (3), pooya87 (2), ABCbits (1)
 #13

I think the OP asked about C, and C++ ... not c# which is totally different. For the most part, the performance of C and C++ are almost identical in most cases if you were not to use the Object Orientated features(like  inheritance, classes, templates, and some others). C# is a high level level language and not really comparable with either of the above, it's level of abstraction is probably on par with Python.

Seriously though, try implementing a linked list or hash table in C. And then again for your second and third project. Then you will see why everyone uses STD for this kind of stuff.

There is only so much you can implement without using classes, if you don't want to fill up your program with messy structures and pointers like in the Linux kernel. It makes for an unmaintainable mess.

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

Activity: 38
Merit: 22


View Profile
March 07, 2024, 09:47:35 AM
 #14

I think the OP asked about C, and C++ ... not c# which is totally different. For the most part, the performance of C and C++ are almost identical in most cases if you were not to use the Object Orientated features(like  inheritance, classes, templates, and some others). C# is a high level level language and not really comparable with either of the above, it's level of abstraction is probably on par with Python.

Seriously though, try implementing a linked list or hash table in C. And then again for your second and third project. Then you will see why everyone uses STD for this kind of stuff.

There is only so much you can implement without using classes, if you don't want to fill up your program with messy structures and pointers like in the Linux kernel. It makes for an unmaintainable mess.



100%. I probably wasn't very clear in my answer, but what I was meaning is C and C++ are very much related( so much so that if certain OO features are not used, the performance is exactly the same). However you are most certainly right, and actually writing something(complex) without using OO = pain! Smiley
Flavatron
Jr. Member
*
Offline Offline

Activity: 38
Merit: 22


View Profile
March 07, 2024, 09:52:26 AM
Merited by vapourminer (1)
 #15

Because Bitcoin is complex, and complex projects are better to be programmed in object oriented programming. It also comes with rich libraries like STL, which reduce the overall chance for making a mistake, and it improves performance.

C is (usually) faster than C++, but I wouldn't want Bitcoin's source code to be a monster like the Linux kernel, even if it was slightly faster (which isn't necessarily to be the case).

True. There has been some momentum around moving the kernel over to Rust, in time.

https://www.zdnet.com/article/rust-in-linux-where-we-are-and-where-were-going-next/
ekiro (OP)
Full Member
***
Offline Offline

Activity: 154
Merit: 101


View Profile
March 07, 2024, 08:35:50 PM
 #16

I think the OP asked about C, and C++ ... not c# which is totally different. For the most part, the performance of C and C++ are almost identical in most cases if you were not to use the Object Orientated features(like  inheritance, classes, templates, and some others). C# is a high level level language and not really comparable with either of the above, it's level of abstraction is probably on par with Python.

Seriously though, try implementing a linked list or hash table in C. And then again for your second and third project. Then you will see why everyone uses STD for this kind of stuff.

There is only so much you can implement without using classes, if you don't want to fill up your program with messy structures and pointers like in the Linux kernel. It makes for an unmaintainable mess.


makes sense. thank god he didn't use java...
promise444c5
Full Member
***
Offline Offline

Activity: 266
Merit: 128


Keep Promises !


View Profile
March 08, 2024, 07:11:37 AM
 #17


 However you are most certainly right, and actually writing something(complex) without using OO = pain! Smiley


Lol  Grin this explains  why php has the frame work Laravel it more of OO features but some comes with OO =pain(may be not complex)

apogio
Sr. Member
****
Online Online

Activity: 420
Merit: 948



View Profile WWW
March 08, 2024, 07:55:23 AM
 #18

Seriously though, try implementing a linked list or hash table in C. And then again for your second and third project. Then you will see why everyone uses STD for this kind of stuff.

There is only so much you can implement without using classes, if you don't want to fill up your program with messy structures and pointers like in the Linux kernel. It makes for an unmaintainable mess.

makes sense. thank god he didn't use java...

Java is a more advanced C++. It's great for general purpose applications and of course it's easy to use and maintain. Most of the libraries you need are available in Java, so actually customization is minimal, most of the time.
On the other hand, NotATether is right about C. In C you can literally do anything you want, because you have direct access to the RAM (memory), using pointers and memory allocation functions (malloc, calloc etc). However, this "freedom" most of the time comes with an "unmaintainabe mess" (this phrase was perfectly used here).

ABCbits
Legendary
*
Offline Offline

Activity: 2856
Merit: 7407


Crypto Swap Exchange


View Profile
March 08, 2024, 10:40:54 AM
Merited by vapourminer (1)
 #19

Because Bitcoin is complex, and complex projects are better to be programmed in object oriented programming. It also comes with rich libraries like STL, which reduce the overall chance for making a mistake, and it improves performance.

C is (usually) faster than C++, but I wouldn't want Bitcoin's source code to be a monster like the Linux kernel, even if it was slightly faster (which isn't necessarily to be the case).
True. There has been some momentum around moving the kernel over to Rust, in time.

https://www.zdnet.com/article/rust-in-linux-where-we-are-and-where-were-going-next/

But so far, Rust (along with other language) remain to have small popularity[1]. In addition, previously Linux kernel already switch from C89 to C11[2].

--snip--
Java is a more advanced C++. It's great for general purpose applications and of course it's easy to use and maintain. Most of the libraries you need are available in Java, so actually customization is minimal, most of the time.
--snip--

Does your statement apply to Java in general or just newer Java version? I often hear Java 8.0 or older is hated due to various reasons.

[1] https://openhub.net/p/linux/analyses/latest/languages_summary
[2] https://www.zdnet.com/article/linus-torvalds-prepares-to-move-the-linux-kernel-to-modern-c/

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
apogio
Sr. Member
****
Online Online

Activity: 420
Merit: 948



View Profile WWW
March 08, 2024, 02:02:01 PM
 #20

Does your statement apply to Java in general or just newer Java version? I often hear Java 8.0 or older is hated due to various reasons.

[1] https://openhub.net/p/linux/analyses/latest/languages_summary
[2] https://www.zdnet.com/article/linus-torvalds-prepares-to-move-the-linux-kernel-to-modern-c/

I have been a Java software engineer since 2017. When I first started we used Java 6. Now we mainly use Java 11.

Certainly Java has evolved. Before Java 8 it was a bit frustrating and not feature rich.

Java 8 was a huge development in my opinion. Then Java 11 is also a big step up.

Nowadays, Java 19 has some significant new features.

What I love about Java is the platform independence and the fact that it is maintained very well. People keep using it and keep supporting its development.

Pages: [1] 2 »  All
  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!