Pages:
Author

Topic: why was Bitcoin written in C++? (Read 372 times)

newbie
Activity: 17
Merit: 0
June 07, 2023, 10:54:32 PM
#23
Modern CPUs have many cores. Some parts of blockchain applications parallelize perfectly (like checking digital signatures) while some parts don't parallelize at all (like executing transactions in order). Modern C++ has a very good mix of effective inter-thread communication and optimization of single-thread performance.

C++ doesn't have a run time that stops the world or manages memory, giving your application consistent control over this behavior. Move semantics allow you to get objects that behave like values (i=j; a+=1; does not change j) but perform like references (deep copies are avoided except where needed).

hero member
Activity: 2114
Merit: 603
June 05, 2023, 12:52:23 PM
#22
I am not sure if this has any relevancy but I know one company named as 63 moons. It’s a multinational conglomerate and operates in various financial domains as well. Most recently they have started their own crypto currency exchange and they also have pre existing stock market exchanger.

The programming and full stack development has been done in C++ language itself. Most of the developers they are choosing has extensive knowledge of C programming. When asked to friend working at their firm named “Ticker Enterprise” they said it is both simple and hard language but it is most common in the field of information technology. This could mean that it’s just that it is most basic language, it is the language where everything starts really. That could be the reason for the same.
sr. member
Activity: 616
Merit: 271
June 04, 2023, 10:52:35 AM
#21
But, and this is a huge BUT everybody in the office knows PHP everybody in the office can deal with any issues if they come up.
As I mentioned above, this is a bit of issue when you are working as a team. In my team, we have few new guys who are coming from the Vue library background but majority of us have been working with Angular. But then, we have to readjust to Vue because the framework is easy to learn.
The consequence was delay in task management as we depended on documentation for few days.
Choice of language is sometimes a problem when you are not a solo programmer. I read somewhere that people were helping Satoshi to write codes as he didn't do it all alone.
legendary
Activity: 2114
Merit: 1403
Disobey.
June 02, 2023, 06:57:04 PM
#20
I am going to have to go with the theory of what most things are written in a particular language. It's white the person knows.

Many times, we have done things for web-based apps in PHP that we know can be done more efficiently using a different language. But, and this is a huge BUT everybody in the office knows PHP everybody in the office can deal with any issues if they come up. So PHP it is. Satoshi could have done it differently, but if C++ was what was known then that is what was used.

-Dave
Agreed, anyone that's not a mulit-language genius will stick to what they know best.
However the question should also be, why did Satoshi and future Bitcoin devs know c++ so well? One reason is probably the time-period they learned computer-science related stuff - until the early 2000s c++ was still very popular, before the uprising of Javascript and other web-focused languages.
Another very important aspect as to why c++ is probably one of the best fits for Bitcoin Core is it's closeness to Assembly. C and C++ allow low-level memory management and offer one of best performances compared to a ton of newer languages.
These are just my amateur guesses though. Smiley
legendary
Activity: 3500
Merit: 6320
Crypto Swap Exchange
June 02, 2023, 05:35:23 AM
#19
I am going to have to go with the theory of what most things are written in a particular language. It's white the person knows.

Many times, we have done things for web-based apps in PHP that we know can be done more efficiently using a different language. But, and this is a huge BUT everybody in the office knows PHP everybody in the office can deal with any issues if they come up. So PHP it is. Satoshi could have done it differently, but if C++ was what was known then that is what was used.

-Dave
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
June 02, 2023, 04:15:17 AM
#18
C is pretty much the father of programming languages; just think that the entire linux kernel is written in C.

Not entire linux kernel though, very small amount of linux kernel are also written with Assembly, C++ and Rust.

Everyone knows that C++ was and is one of the most famous programming languages out there and many of the top software creators have mastered the language and have built applications specifically in that language.  Some of those well known applications that have been built using C++ code are Adobe Photoshop, Google chrome, Git, Dropbox, and many others. The most of the AAA titles use that language for creating those high graphics games. Even the operating systems are mainly codded with C++ programming language.

In 2008 the best language for programmers was C++ and there were many guides, and tutorials available for that language. Other languages weren't as efficient and as useful for creating high quality software piece in those times, the best programmers of the era chose C++ for their projects and most of those applications are still based on the same code with fixed bugs and added features.

While C++ indeed is great programming language, i can't help but think your statement is just very biased towards C++.
1. C++ is far from most famous programming language based on https://survey.stackoverflow.co/2022/.
2. Linux is almost entirely written with C, while Windows and Mac also use C. See https://stackoverflow.com/a/580300.
3. There's no such thing such as best programming language.
hero member
Activity: 784
Merit: 672
Top Crypto Casino
June 02, 2023, 12:56:34 AM
#17
I have tried to figure out why Satoshi decided to go with C++ in writing bitcoin codes. I have some of these assumptions below, I decided to share to learn more;

  • Could it be that C++ is the most popular language then?
  • Could it be that it is the language Satoshi was more conversant with. As a developer,  I try to use the language I know too well, even if it might be inefficient
  • Is there any security advantages of using C++? I mean python also supports open source and Js enhances scalability.  Why the special interest in C++
  • Right now C++ is largely regarded as the best language for crypto coding. Is this accolade given C++ because Satoshi used it and developed the king of cryptocurrency.  Assuming Satoshi used another language,  is there any possibility that the language would be more adopted for crypto coding
  • Finally,  is there any possibility that since 1985 C++ is developed, there will be a time it will become an obsolete language and bitcoin codes will require that it should be re-written in another language?

I agree with the answers of the reputed members of the forum but in my mind the answer is a little different. I think Satoshi chose to write Bitcoin in C++ programming language because he was good at that language and his main programming language at that time might be C++ because of the wide acceptability. He might have also tried the thing using other codes and failed to get it into the state that C++ helped him to get. I might be wrong but that's what I think of right now.

Everyone knows that C++ was and is one of the most famous programming languages out there and many of the top software creators have mastered the language and have built applications specifically in that language.  Some of those well known applications that have been built using C++ code are Adobe Photoshop, Google chrome, Git, Dropbox, and many others. The most of the AAA titles use that language for creating those high graphics games. Even the operating systems are mainly codded with C++ programming language.

In 2008 the best language for programmers was C++ and there were many guides, and tutorials available for that language. Other languages weren't as efficient and as useful for creating high quality software piece in those times, the best programmers of the era chose C++ for their projects and most of those applications are still based on the same code with fixed bugs and added features.

So, if we keep all those things in our mind than it was a good decision to chose C++ over other programming languages to create a safe and useful digital currency for the world. Even if we leave the coding language behind, it's still a inspiring thing to notice that someone like Satoshi gave us a gift in the form of Bitcoin and he was so sincere that he left it in the hands of the community. If fame was his intention then he would never disappear from the scene, and trust me he would be among the richest and most famous people of the world if he didn't chose to disappear.
sr. member
Activity: 616
Merit: 271
June 01, 2023, 06:27:37 PM
#16
Right now C++ is largely regarded as the best language for crypto coding. Is this accolade given C++ because Satoshi used it and developed the king of cryptocurrency.  Assuming Satoshi used another language,  is there any possibility that the language would be more adopted for crypto coding

The only reason why it is believed that C++ is the most popular language for developing crypto projects is that thousands of projects are just forks of Bitcoin and Monero which all use C++.
This makes alot of sense to me. Since the codes system is open source, it was accessible to many who cloned it and mare make lily changes to create their own coin. This should be the genesis of C++ as the most popular language for crypto projects development.

  • Finally,  is there any possibility that since 1985 C++ is developed, there will be a time it will become an obsolete language and bitcoin codes will require that it should be re-written in another language?

As long as C++ remain popular and actively receive new update/standard, it won't become obselete. For reference, C++20 standard already released while C++23 standard still in progress.

Great to remind me of this. I think I wasn't thinking then....
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
June 01, 2023, 03:13:53 PM
#15
I tend to believe it's because C/C++ has probably the best readability : efficiency tradeoffs, at least comparably to the high level languages of that time. C is pretty much the father of programming languages; just think that the entire linux kernel is written in C. And, while efficiency isn't prioritized in many software, I think Bitcoin needs to run efficiently. Otherwise, someone else will write a more efficient alternative.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
June 01, 2023, 01:48:12 AM
#14
Right now C++ is largely regarded as the best language for crypto coding. Is this accolade given C++ because Satoshi used it and developed the king of cryptocurrency.  Assuming Satoshi used another language,  is there any possibility that the language would be more adopted for crypto coding

The only reason why it is believed that C++ is the most popular language for developing crypto projects is that thousands of projects are just forks of Bitcoin and Monero which all use C++.

These don't have smart contracts so they can't just write a token for it like Ethereum (which is written in Golang) and derivatives, they have to clone the entire physical codebase.

Also many of the more "modern" languages did not exist back in 2008 when Satoshi started coding this thing. There was really only C/C++, Java, Python, ... you get the idea. Be thankful that he didn't write it in Delphi or Pascal Smiley
legendary
Activity: 2114
Merit: 1403
Disobey.
May 31, 2023, 05:35:31 PM
#13

Quote
and Satoshi was not an exceptionally experienced software developer, and this is evidenced by the presence of a lot of bugs in the versions that he developed .
Sorry but that is also a fairly clear falsehood, one spread by inept and inexperienced developers to make themselves sound smarter.  Bitcoin was written in a modern style, almost entirely free of manual memory management.  Normally in industrial software you expect a defect rate of worse than 1 bug per thousand lines of code and bitcoin had a much higher proportion of tricky parts so I would expect a higher defect rate than typical.  Yet the original bitcoin software had an extremely low defect rate [...]

Thanks for these very informative and intersting lines on Satoshis coding skills. I vaguely remember reading a similar comment years ago, but with less substance and also less infotainment factor.
You mentioned the low error-to-codel-ratio could be an indication for a team working behind the pseudonym of Satoshi - how likely do you personally rate this hypothesis to be true and are there other indicators pointing in that direction?
staff
Activity: 4284
Merit: 8808
May 31, 2023, 09:45:06 AM
#12
All the ideas related to Bitcoin were already present, and even the idea of ​​Bitcoin has a historical basis before 2008
Sorry, but in the interest of slowing the spread of misinformation this is just plainly false.  The idea of using a distributed anonymous cryptographic lottery to form a consensus is the revolutinary idea in Bitcoin and it had no historical precedent.  People were working on the problem since at least 2001 (search spent-twice) and not finding the answer-- even though they were well aware of the predecessor technologies:  The linked discussion included Hal Finney (eventual creator of RPOW), Adam Back (inventor of hashcash), and Peter Todd (eventual Bitcoin developer).

For this reason he probably was not so fluent in more modern coding languages and also bitcoin works perfectly in C++, so why bother to write it in another langue.
What more modern language would he have used?  The likely candidates that existed at the time have extremely poor performance (particularly memory usage overheads but also runtime), given that Bitcoin has many times been at the breaking point keeping up with the traffic and there are no alternative implementations with acceptable performance written in those more modern languages even today, I think that would have been unwise indeed.


hero member
Activity: 1274
Merit: 681
I rather die on my feet than to live on my knees
May 31, 2023, 09:30:44 AM
#11
I also think that C++ was chosen mostly because of 2 reasons. Who wrote either the protocol and the software Bitcoin core where comfortable with the programming language and also because C++ allows a very more "user-friendly" memory management than for instance, languages of lower level such as pure C. Also, trying to build applications which requires graphics like windows and boxes, buttons and so on, in pure C, requires the usage of external libraries such has SDL, and despite the fact tha tI don't know much about it, I know it is very easy to get quite complex and probably less efficient and slower than using C++ or other OOP languages.
hero member
Activity: 406
Merit: 443
May 31, 2023, 07:43:36 AM
#10

It is also believed that satoshi was already of a high age when he created bitcoin, maybe he was already retired or close to his retirement. For this reason he probably was not so fluent in more modern coding languages and also bitcoin works perfectly in C++, so why bother to write it in another langue. You have to remember that at first bitcoin was slimly a project that was managed of a handful of people and nobody would have thought that the adoption would be this huge.

All the ideas related to Bitcoin were already present, and even the idea of ​​Bitcoin has a historical basis before 2008, but Satoshi was the only one who developed it for a valuable model, and Satoshi was not an exceptionally experienced software developer, and this is evidenced by the presence of a lot of bugs in the versions that he developed .

Age is not a measure. For example, a 15-year-old teenager was able to hack a *wallet* claiming to be an unhackable crypto wallet.
https://techcrunch.com/2018/08/14/unhackable-bitfi-crypto-wallet-has-been-hacked/

Source researchgate/Elise Alfieri
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
May 31, 2023, 05:50:19 AM
#9
    • Finally,  is there any possibility that since 1985 C++ is developed, there will be a time it will become an obsolete language and bitcoin codes will require that it should be re-written in another language?

    As long as C++ remain popular and actively receive new update/standard, it won't become obselete. For reference, C++20 standard already released while C++23 standard still in progress.



    Could it be that C++ is the most popular language then?
    According to the data from https://www.tiobe.com/tiobe-index/, Java, C, and C++ were one of the most popular programming languages in 2008.

    TIOBE use very poor data source though, since it seems they rely on total search result with specific keyword on few different search engine.

    The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. Popular search engines such as Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.
    hero member
    Activity: 882
    Merit: 792
    Watch Bitcoin Documentary - https://t.ly/v0Nim
    May 31, 2023, 05:17:37 AM
    #8
    I would describe bitcoin idea in four words: A currency, blockchain, node and miner.
    Satoshi needed to create something that was super secure, resource efficient and fast. You have to keep in mind the equipment that was available back then, there weren't so powerful PCs 15 years ago. Bitcoin's block size was limited to 1MB, mining uses Proof Of Work consensus, blocks should be validated quickly. I don't have a background in programming, I just started learning of javascript recently, so, there may be other reasons why he chose C++ but from all of these, I would say that he chose C++ over others because of its excellent performance, efficiency and support back then.
    hero member
    Activity: 1022
    Merit: 642
    Magic
    May 31, 2023, 04:06:04 AM
    #7


    You will find more reasons on the internet, but Satoshi had to choose a programming language and this language was C++ because it is the best and he (she or they) may have other reasons, God only knows.

    It is also believed that satoshi was already of a high age when he created bitcoin, maybe he was already retired or close to his retirement. For this reason he probably was not so fluent in more modern coding languages and also bitcoin works perfectly in C++, so why bother to write it in another langue. You have to remember that at first bitcoin was slimly a project that was managed of a handful of people and nobody would have thought that the adoption would be this huge.

    What speaks for this thesis is also that satoshi left bitcoin not long after it was published, since he probably simply retired. That is something a young person would probably not do, but who knows. Satoshi could still be here under another name and nobody would know.
    legendary
    Activity: 2450
    Merit: 4415
    🔐BitcoinMessage.Tools🔑
    May 31, 2023, 02:55:26 AM
    #6
    Could it be that C++ is the most popular language then?
    According to the data from https://www.tiobe.com/tiobe-index/, Java, C, and C++ were one of the most popular programming languages in 2008.

    Quote
    Could it be that it is the language Satoshi was more conversant with. As a developer,  I try to use the language I know too well, even if it might be inefficient
    Developers usually write in the languages they are most proficient in, but you can solve the problem with any programming language you like and later reimplement it in another to make the solution more efficient and suitable for particular use cases.

    Quote
    Is there any security advantages of using C++? I mean python also supports open source and Js enhances scalability.  Why the special interest in C++
    As far as I know, C++ has no serious vulnerabilities, and it is supported by a large community of developers and regular contributors. If you want to build a secure system, then C++ is quite suitable for achieving your goal.

    Quote
    Finally,  is there any possibility that since 1985 C++ is developed, there will be a time it will become an obsolete language and bitcoin codes will require that it should be re-written in another language?
    Bitcoin already has dozen of implementations in different languages, so it is not necessary to rely on C++ as a popular choice among developers.
    legendary
    Activity: 3766
    Merit: 1364
    Armory Developer
    May 31, 2023, 02:36:51 AM
    #5
    AFAIK he was in touch with Wei Dai via various cypherpunk forums. Bitcoin used CryptoPP, Wei Dai' C++ crypto library. I assume that had some weight in the balance.
    hero member
    Activity: 406
    Merit: 443
    May 31, 2023, 02:16:01 AM
    #4
    I have tried to figure out why Satoshi decided to go with C++ in writing bitcoin codes. I have some of these assumptions below, I decided to share to learn more;
    You have to distinguish between Bitcoin, which is a protocol, and the software that runs full nodes, which is Bitcoin Core in our case.
    Your question is What made satoshi written Bitcoin core using C++ as the main programming language.

    One of the most important advantages of C++ language is that it gives great control over memory usage, the program can be written will be very consistently without the need to rewrite the code from scratch in case you want to write for a different programming language.

    You will find more reasons on the internet, but Satoshi had to choose a programming language and this language was C++ because it is the best and he (she or they) may have other reasons, God only knows.
    Pages:
    Jump to: