r/learnprogramming • • Apr 28 '22

If everything is ultimately binary, does't that just make programs a specific number?

I did the CS50 course a while ago and they covered binary in there. I did binary back in 2006 when I was at college too so understood the logic behind it already. It's either on or off!

When a C program compiles, it goes through it's phases and compiles to assembly and then ultimately machine code i.e binary.

Let's say our program is 5,000,000 pages of 1's and 0's. All of those 1's and 0's make up a single number....albeit a super long number.

Does that mean that the entire Linux operating system, for example, can be represented by an actual number?

If so, why are we not storing programs as a number because that would take up less space than the 5,000 pages of 1's and 0's.

110101000101011111011011111110111100 = 57000443836 in decimal. So why don't we store programs in decimal and convert that to 1's and 0's in real time?

Storage would be much less. Is that how compression works?

These may be crazy questions but it just entered my head earlier when thinking about what the binary of a program can represent.

Even shorter than decimal is HEX.... So why don't we store programs in Hex?

Any help appreciated on this one so I can wrap my head around it.

1.7k Upvotes

346 comments sorted by

View all comments

Show parent comments

81

u/matthewapplle Apr 29 '22

Something something monkey typewriter Shakespeare??

69

u/InnerBanana Apr 29 '22

This comment is one of the failed attempts from that very experiment

0

u/[deleted] Apr 29 '22

[deleted]

10

u/goahnary Apr 29 '22

All of them actually. Including this one. These monkeys are hilariously self-aware while… also not self aware??

Does the monkey learn and grow as it types? If it does I think it would take it significantly less time to learn/type Shakespeare.

28

u/p43- Apr 29 '22

Let me neatly summarise this whole comment thread:

7463662637483720304057371719

6

u/Mollyarty Apr 29 '22

Or more time, if the monkey learns and grows it'll likely develop its own style that might not align with Shakespeare

2

u/Vonkampf Apr 30 '22

Maybe not, maybe they got the complete works of Shakespeare on like the 3rd attempt and just stopped…

1

u/goahnary May 10 '22

True. That is an option.

3

u/james_connor Apr 29 '22

But have they read Shakespeare?

2

u/bladedspokes Apr 29 '22

All the world's a stage, and all the monkeys merely players. They have their entrances and their exits; and one monkey in his time plays many parts.

0

u/SnowWholeDayHere Apr 29 '22

This is the exact logic that NHS (UK) used to overhaul their system and make it an even bigger mess than before. It is now a case study available to everyone.

https://www.henricodolfing.com/2019/01/case-study-10-billion-it-disaster.html

1

u/13Zero Apr 29 '22

The monkeys have to be typing randomly for that to work.

No one has found a pattern in the digits of pi, but it’s possible that one exists.