Author

Topic: why was bitcoin written in C++ instead of pure C? (Read 427 times)

member
Activity: 312
Merit: 30
it used vectors from the start. it's stl and part of c++.you can check say base58 lib. no one can tell if he's good enough in C to do it that way
full member
Activity: 266
Merit: 119
Keep Promises !

newer languages like c++ build on existing languages and make it easier for developers to achieve what they want with less work involved.


Newer Languages  Roll Eyes
C++ has been in existence since 1979 although there were later ammendments for release.
Rust is  newer maybe that's what you meant

Unity=> C# (less work ,less speed)
UnrealEngine => C++ (more work , more speed)
member
Activity: 88
Merit: 10
im no programming expert but this is my take...

asking this is like asking why anyone creates anything in their language of choice and not in assembly...

newer languages like c++ build on existing languages and make it easier for developers to achieve what they want with less work involved.

its the same reason developers choose unreal engine or unity to build their games and not their own because simply its less work to achieve their goal.
full member
Activity: 266
Merit: 119
Keep Promises !


What do you mean "migrated"? And more importantly what do you mean "mini C"?

Migration from C to Java is almost impossible. Most of the time the apps that are written in C, will remain in C, or they will be re-writen in Java from scratch.
Although I don't use Java or have knowledge about it wither ....... just saying it's implementation is just like C  so I called it mini C(not interm of it's functionality though).
 "Migrated"=>  migrate to other language  but it was added to their skill stack (forgot to add that earlier).
sr. member
Activity: 406
Merit: 896
Never used java maybe because while I was starting my learning the horror I heard about it made me ran away from it Cheesy(poor me!) but I could say 70% out of known people  migrated  due to its implementation just like a mini C language

What do you mean "migrated"? And more importantly what do you mean "mini C"?

Migration from C to Java is almost impossible. Most of the time the apps that are written in C, will remain in C, or they will be re-writen in Java from scratch.
full member
Activity: 266
Merit: 119
Keep Promises !
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.
Never used java maybe because while I was starting my learning the horror I heard about it made me ran away from it Cheesy(poor me!) but I could say 70% out of known people  migrated  due to its implementation just like a mini C language
sr. member
Activity: 406
Merit: 896
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.
legendary
Activity: 2856
Merit: 7410
Crypto Swap Exchange
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/
sr. member
Activity: 406
Merit: 896
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).
full member
Activity: 266
Merit: 119
Keep Promises !

 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)
full member
Activity: 154
Merit: 101
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...
jr. member
Activity: 38
Merit: 21
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/
jr. member
Activity: 38
Merit: 21
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
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
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.
legendary
Activity: 4298
Merit: 3209
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.
legendary
Activity: 3458
Merit: 6231
Crypto Swap Exchange
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
sr. member
Activity: 406
Merit: 896
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.


legendary
Activity: 3444
Merit: 10537
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.
full member
Activity: 266
Merit: 119
Keep Promises !
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

legendary
Activity: 1512
Merit: 7340
Farewell, Leo
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).
jr. member
Activity: 38
Merit: 21
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.
sr. member
Activity: 308
Merit: 448
Math + Code = Blockchain 😁
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++
sr. member
Activity: 294
Merit: 267
Baba God Noni
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/

legendary
Activity: 3444
Merit: 10537
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.
sr. member
Activity: 308
Merit: 448
Math + Code = Blockchain 😁
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.
full member
Activity: 154
Merit: 101
Jump to: