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

2.4k

u/captainAwesomePants Apr 28 '22

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

YES!

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

YES!

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

Good question. It's because it's really cheap to build a trillion tiny things that can reliably be either on or off, and it's much more expensive to build a bunch of things that can be in 10 different states. For example, if you wanted to store any number between 1 and 1,000,000, you could either do it with 6 counters that could store 10 values each, or you could do it with 20 counters that could store 2 values each, and it turns out that 20 counters storing 2 values each are much cheaper to make.

Is that how compression works?

No. It's the same amount of information either way. It takes less space to write it on paper in decimal, but it's still the same total amount of information.

These may be crazy questions

These are crazy IMPORTANT questions. "Oh my god information is just a number" is perhaps the foundational thought of computer science. It leads to Hilbert's "oh crap mathematical proofs can be a number" discovery, which led to Godel's incompleteness theorem, which is one of the most astounding, depressing, and important mathematical discoveries of the 20th century. It's a GREAT question to be thinking about.

760

u/Smooth_Measurement_1 Apr 28 '22

Thank you for the detailed answer and for making me feel like I'm not so stupid for asking that question.

1.0k

u/captainAwesomePants Apr 28 '22 edited Apr 28 '22

No worries, this is really fun stuff. The whole "oh my god programs are data" revelation leads to a lot of amazing thoughts.

For example, pi is an infinite, nonrepeating decimal - meaning that every possible number combination exists somewhere in pi. Any program you write can be expressed as a decimal number. That means that your program exists somewhere in pi. Instead of storing the program itself, I could just tell you which digit of pi it starts on!

There was a controversy many years ago when someone published a small program that could decode DVDs. There were arguments and lawsuits basically claiming that the program was illegal. In response, some programmers found a prime number with 1401 digits that, in binary, was a gzip file containing the source code to the program. They argued that declaring a prime number illegal was ridiculous.

That stuff is fun and mind-blowing, but there are practical thoughts too. Once you realize that your program is a number, and you realize that programs are good at manipulating numbers, you'll probably realize that your program can do operations on programs, including on itself!

241

u/l_am_wildthing Apr 28 '22

every possible number combination exists somewhere in pi

Not to be pedantic but this is a misconception about the infinite-ness of pi... just because it is infinite and non-repeating doesnt mean it has every possible number. 1.101001000100001000001... is infinite and non-repeatable but doesnt contain every number. Pi is obviously different but the same applies

33

u/Sufficient_Drop5013 Apr 29 '22

It may very well be a misconception, but you can't prove it's not true.

39

u/schoolmonky Apr 29 '22

Depending on what exactly you mean by "it," you totally can, and /u/l_am_wildthing did.

If by "it" you meant the statement "Pi doesn't contain every possible number," then yes, that's currently believed to be false, and therefore unprovable.

But if you read carefully, that's not the statement that /u/l_am_wildthing is arguing against. What they actually say is that the facts that a number (in this case, pi) is infinite and non-repeating do not imply that it contains every possible number. He's not making a claim about whether pi has all numbers in it, but instead about the logical relationship between whether pi is infinite and non-repeating and whether pi contains all numbers.

→ More replies (8)

40

u/jcb088 Apr 29 '22

Until he can! If he can! Maybe that's his life's work!

This conversation might be the start of something incredible!

30

u/nimbledaemon Apr 29 '22

If you start believing everything you can't prove to be false, you're going to end up believing a lot of bullshit.

→ More replies (3)

24

u/Putnam3145 Apr 29 '22

Sure, but you can't claim it like it's a known fact either. Lots of people suspect P != NP but I'm not gonna go around proclaiming it.

→ More replies (3)

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

→ More replies (6)
→ More replies (4)

83

u/captainAwesomePants Apr 29 '22

Totally fair. We also have to show that pi is normal, and although I'd bet it is, that is certainly not a given.

1

u/Smooth_Measurement_1 Apr 30 '22

That's an interesting concept. Do you think there will be a long line of single digits in Pi at some point in its life?

For example 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

I think that's quite a rare possibility and the odds are extremely slim....

→ More replies (24)

23

u/green_meklar Apr 29 '22

Instead of storing the program itself, I could just tell you which digit of pi it starts on!

But on average the index number would be about as long as the program itself. So you still can't get an informational free lunch that way.

10

u/gaspronomib Apr 29 '22

Yes, but the index number itself would be in Pi, so you could just give the index to the index number. And if that index number was too long, well then it exists in Pi as well.

It's index numbers all the way down.

→ More replies (1)

8

u/oakteaphone Apr 29 '22

Instead of storing the program itself, I could just tell you which digit of pi it starts on!

Please do! joke

9

u/captainAwesomePants Apr 29 '22

It starts at bit 186282. For security, I've also encrypted the program with a one time pad.

8

u/EmpyrealSorrow Apr 29 '22

There was a controversy many years ago when someone published a small program that could decode DVDs. There were arguments and lawsuits basically claiming that the program was illegal. In response, some programmers found a prime number with 1401 digits that, in binary, was a gzip file containing the source code to the program. They argued that declaring a prime number illegal was ridiculous.

Can I just clarify something that's confusing me with this? Is it important for the program that it is a prime number? Or is it just a series of values that happens to contain the number equivalent of the programme and, by virtue of being one of the largest prime numbers known, is automatically archived and therefore protected?

11

u/rcxdude Apr 29 '22

Is it important for the program that it is a prime number?

Only to make it a bit of a stunt to represent it as such, making the argument appear to have a bit more weight, because prime numbers are 'mathsy'. (it would more naturally be a slightly different number which wasn't prime: what they did was basically have a part of the file which could take any value they wanted without affecting the functionality, then try random values in there until the result became a prime. Because primes are still fairly dense at these very large numbers, this doesn't really take too long for a computer)

→ More replies (1)

4

u/Roxolan Apr 29 '22

They argued that declaring a prime number illegal was ridiculous.

Relevant blog post: What Colour are your bits?

The problem is that there are two conflicting sets of rules there. Under the lawyer's rules, Colour is not a mathematical function of the bits that you can determine by examining the bits. It matters where the bits came from. The scrambled file still has the copyright Colour because it came from the copyrighted input file. It doesn't matter that it looks like, or maybe even is bit-for-bit identical with, some other file that you could get from a random number generator. [...] To a computer scientist, on the other hand, bits are bits are bits and it is absolutely fundamental that two identical chunks of bits cannot be distinguished. [...]

This idea of Colour is a problem for communication between those of us who work in the world of computers, where Colour does not exist, and those of us who work in the law, where Colour exists and is important. Lawyers will ask computer scientists questions about how to determine the Colour of bits [...], and computer scientists will find it difficult to say anything in response that the lawyers can comprehend - because a big part of computer science is about understanding that Colour does not exist.

3

u/twbluenaxela Apr 29 '22

What? How is that possible? How did the source code for a program be in a prime number

61

u/captainAwesomePants Apr 29 '22 edited Apr 29 '22

Here is a prime number with 1401 digits:

48565078965 7397829309 8418946942 8613770744 2087351357 9240196520 7366869851 3401047237 4469687974 3992611751 0973777701 0274475280 4905883138 4037549709 9879096539 5522701171 2157025974 6669932402 2683459661 9606034851 7424977358 4685188556 7457025712 5474999648 2194184655 7100841190 8625971694 7970799152 0048667099 7592359606 1320725973 7979936188 6063169144 7358830024 5336972781 8139147979 5551339994 9394882899 8469178361 0018259789 0103160196 1835034344 8956870538 4520853804 5842415654 8248893338 0474758711 2833959896 8522325446 0840897111 9771276941 2079586244 0547161321 0050064598 2017696177 1809478113 6220027234 4827224932 3259547234 6880029277 7649790614 8129840428 3457201463 4896854716 9082354737 8356619721 8622496943 1622716663 9390554302 4156473292 4855248991 2257394665 4862714048 2117138124 3882177176 0298412552 4464744505 5834628144 8833563190 2725319590 4392838737 6407391689 1257924055 0156208897 8716337599 9107887084 9081590975 4801928576 8451988596 3053238234 9055809203 2999603234 4711407760 1984716353 1161713078 5760848622 3637028357 0104961259 5681846785 9653331007 7017991614 6744725492 7283348691 6000647585 9174627812 1269007351 8309241530 1063028932 9566584366 2000800476 7789679843 8209079761 9859493646 3093805863 3672146969 5975027968 7712057249 9666698056 1453382074 1203159337 7030994915 2746918356 5937621022 2006812679 8273445760 9380203044 7912277498 0917955938 3871210005 8876668925 8448700470 7725524970 6044465212 7130404321 1826101035 9118647666 2963858495 0874484973 7347686142 0880529443

Consider this as a number. This is its decimal representation, but you could also write it in binary as a number with 4500ish bits. You could save those bits in order as a file. If you were to do that, you would in this case find that it is a gzip file, and if you opened that gzip, you would find the source code to a program that breaks the encryption on DVDs.

22

u/twbluenaxela Apr 29 '22

So you're telling me, if I take this number, throw it into an online binary converter, then take this number, throw it into notepad, save it, then it will convert to a gzip file automatically? And when I open that zip file, it will have the source code to break the encryption on DVDs?

51

u/captainAwesomePants Apr 29 '22

Yes.

I'll take it that you completely understand that files are just bits and bytes, and bits and bytes can represent anything, including one giant number. So you understand that a large number can just be a representation of a file, and it follows naturally that one could make a gzip file containing the source code and convert that into a number like the one above.

Your confusion then is how the hell somebody could specifically aim to make that number be prime. That's a great thing to wonder about, and the answer is very clever. You see, gzip is special because if you add a few bytes to the end of it, nothing changes. It still decodes to the same thing. The bytes at the end are completely ignored. So, let's say you start with the gzip file you want, and then you add 2 bytes of zeroes at the end. Now turn that into a number. Now do this:

  1. Check if the number is prime. If so, we did it! Stop.

  2. Increase number by 1.

  3. Goto 1

Pretty good chance that one of the next 65536 or so numbers is gonna be prime.

Here's the creator's explanation of how he worked it out: http://fatphil.org/maths/illegal1.html

→ More replies (24)
→ More replies (2)
→ More replies (5)

10

u/Triple96 Apr 29 '22 edited Apr 29 '22

Same as what the OP of this post is talking about. Take a program, compile it into binary and convert that binary to decimal. In this case apparently that decimal value is 1401 some number 1401 digits long.

Edit: 1401 digits long, not 1401

10

u/acamann Apr 29 '22

not equal to 1401, equal to a number that is 1401 digits long. Way mind blowinger

→ More replies (2)
→ More replies (2)
→ More replies (1)

3

u/gaspronomib Apr 29 '22

If every number that exists appears somewhere in Pi, and all digital media is simply very long numbers, then video and audio of every event that ever has occurred or ever will occur, from the Big Bang to the heat death of the Universe is embedded in its digits.

Assuming that is true, then Pi also has a crapload of- no, ALL- child pornography in it. Therefore, knowing how to calculate the digits of Pi makes one guilty of possessing child porn. I say we arrest anyone who understands the ratio of- one sec, there's someone at my door-

STOP! I'm unarmed. No, don't taze- jjfjaiolzzbl o!hj $&@! seriously, I'm just a math professo- I'm not resisting! Help! Those cuffs are hurting me! Call my lawyer! And my grad students! Tell them to burn all the text books!

3

u/BigBootyBear Apr 29 '22

You know someone killed it when you feel the need to sit down and contemplate your life after reading their answer to the thread...

3

u/[deleted] Apr 29 '22

From now on i will call all my sailor copies of software and media: cool numbers i found on the internet

3

u/cleethby Apr 29 '22

That means that your program exists somewhere in pi.

Does that also mean every/any block of text also exists in pi? That's crazy

→ More replies (1)
→ More replies (18)

18

u/barryhakker Apr 29 '22

My person, asking questions is about as far from stupid as you can possibly get.

4

u/santafe4115 Apr 29 '22

this is the "Ill never learn it all because look at the forefathers I stand on. But damn lets have some fun learning this rabbit hole along the way" that a lot of people in tech reach. It helps to not create imposter syndrome and helps with the constant feeling of "never knowing". You never will! we are explorers trying to orient an ever changing map and that is okay

3

u/Tom0204 Apr 29 '22

Btw reprenting decimal numbers in computer memory (which is binary) actually takes up more memory than just storing it in binary.

For example, two BCD digits (binary coded decimal) take up 8 bits and can only count up to 99 while an 8-bit binary number can count up to 255.

This answers your question about why don't we just store programs as decimal numbers and convert it to binary at run time (it would take up more memory, not less).

→ More replies (2)

16

u/[deleted] Apr 29 '22

Just wrapped up my CS degree. I wholeheartedly support this comment. You're asking some really cool questions OP! Really fundamental to CS. Either you're really insightful, you've got a great teacher who helped you discover that for yourself, or both!! Probably both if I'm being honest.

1

u/Smooth_Measurement_1 Apr 29 '22

I just thought about it myself after reading up on binary again. it was floating around in my head for a few hours to decided to post it here and find out if I'm mental or not.

23

u/Yum-Yumby Apr 29 '22

I just wanted to say that your enthusiasm and insight makes me want to learn more about the subject (I just started CS50 so I know nothing). Thank you for this rabbit hole

22

u/Avimox Apr 29 '22

And, not just Linux - everything on your computer is "just a number." Pictures, songs, movies, text... Those are just (agreed-upon) interpretations of a number. A JPG is a meaningless, gigantic number without a JPG decoder to "read" the number and follow its instructions to change pixel colors on the screen.

Gets into important philosophical debate about how a number can be illegal: https://en.wikipedia.org/wiki/Illegal_number

→ More replies (1)

31

u/[deleted] Apr 29 '22

Also the other big thing regarding binary vs decimal is that decimal is far less reliable with our current computing setups (electricity). If you use voltage to represent off (0) or on (1), your threshold can be close to 0 volts for 0 and close to, say, 45volts for on. If you took the same 45 volts for the decimal system, it would be (0-5v, 0, 5-10v, 1, 10-15, 2, etc.) Any change in the power grid or just electrons being electrons could result in that 9 stored in memory becoming an 8, which would lead to some problemos.

7

u/KalebRasgoul Apr 29 '22

In most transistors, 1 is 5 volts.

9

u/Alexlun Apr 29 '22

Your reply is amazing. You're amazing. People that interact with you on a daily basis are really lucky.

9

u/Lighted_Fool Apr 29 '22

Not to be pedantic or anything just to call out an interesting evolution of storage technology. Modern SSD nand cells actually indeed are essentially made up of “counters” that can store up to 16 values, its basically Multiple Bit Per Cell nand solid state technology. If you ever see SSDs advertised as MLC (2bit per cell), TLC (3bit), QLC (4bit) thats what those are.

For example a two bit per cell MLC nand can store 4 different values based on differing energy states to represent two bits (00,01,10,11). We have extended this technology up to 4 bits so far (16 total different values in a single cell).

17

u/[deleted] Apr 29 '22

Compression can still contain the same total amount of information. Lossless compression works without destroying information, so there’s always the same total amount of information. A quick example would be to represent a string like “10101010101010101010” like 10*”10”. It’s the same information but one way it’s shorter.

10

u/mrbaggins Apr 29 '22

Worth an asterisk on compression: No single compression algorithm can compress anything smaller losslessly. There is, by definition, an infinite number of things that any single algorithm cannot compress. Pigeonhole principle is a simple enough "proof" of this.

6

u/linseed-reggae Apr 29 '22

anything smaller losslessly

Keyword here is smaller, not lossless.

A lossless compression algorithm will always be lossless, but when "compressing" data with a sufficiently high entropy, the resultant compressed stream will be larger than the input.

5

u/mrbaggins Apr 29 '22

Entropy isn't necessarily the issue. You can quite simply define patterns that break many common algorithms. The point is that it compresses nicely in a different algorithm though.

→ More replies (16)

7

u/Python-Token-Sol Apr 29 '22

lmao this was epic reply

7

u/AskAndYoullBeTested Apr 29 '22

What an awesome answer man

7

u/old_man_steptoe Apr 29 '22

Good question. It's because it's really cheap to build a trillion tiny things that can reliably be either on or off, and it's much more expensive to build a bunch of things that can be in 10 different states.

Exactly that, really. If you have a transistor and you say, 0-2v is a 0 and 4-6v is a 1, it's easy to discern which one it is. There's a big gap in the middle too. Trying to have 10 discrete states with an early transistor, and particularly vacuum tube would be impossible.

5

u/[deleted] Apr 29 '22

Oh my god your answer makes me cry. There’s so much to learn that I am in awe at the depth of it.

2

u/Honor_Bound Apr 29 '22

Yeah I read this comment as a new student and realize how bad I am at math yet how important math really is to this field. I may be screwed D:

5

u/LittleWompRat Apr 29 '22

So, if I type decimal number randomly (like 753753531....147416427427 up until billions of billions of digits), there's a chance (albeit very small) for me to accidentally invent a software that leads to the cure of cancer?

6

u/captainAwesomePants Apr 29 '22

Sure, but that's also true with source code. If you open up a text editor and start typing, you could maybe type the source code to a program that cures cancer.

3

u/SufficientUndo Apr 29 '22

Yes this is the Shakespeare typewriter problem.

4

u/fakeuserisreal Apr 29 '22

NGL I love seeing people who are super passionate about things that I'm just beginning to wade into. It's super motivating.

3

u/IamMichaelSalim Apr 29 '22

Great explanation! To expand a little bit on the decimal section for those interested:

You can store data however you like. What matters is how you interpret it. For example, quantum computers doesn't use 0 and 1s but can still behave like a normal computer.

We store "something" and it can mean different things depending on how we view it.

We choose binary because the physics behind it is easy and reliable to implement.

Here's a good article if these kinda things are interesting to you: https://kunststube.net/encoding/

2

u/jManYoHee Apr 29 '22

What's the number for Windows?.... Haha

4

u/Honor_Bound Apr 29 '22

at least 7

2

u/jManYoHee Apr 30 '22

At least 3.1.... but definitely not 8 or 9.

2

u/michaelrulaz Apr 29 '22

So could I convert the entire Linux operating system from binary to Hex then write that number down on a piece of paper. Then anytime I needed a Linux operating system just convert it to binary and then somehow recompile it?

→ More replies (2)

2

u/AplombPlummer Apr 29 '22

It is really cool to see all the machinery for computability theory built up. Like, seeing programs mapped to natural numbers via an encoding, then if you have a partial function f, whose domain is the cartesian product of programs numbers and inputs that have a non-empty result, then you start asking questions about whether that program halts or not. I.e., the domain for f, gives us a handle on the unsolvability of the halting problem.

Just expounding on the above from what I remember from auditing computability theory. heh

2

u/[deleted] May 16 '22

What a great written answer. Makes me want to go down that rabbit hole of this vast area of interlocking subjects.

1

u/n00bst4 Apr 29 '22

Maybe I talk shit but doesnt it also have to do with maintenance ?

It's way easier to update one small well understood function in a controlled environnement than pushing and recompilling the entire program everytime

1

u/top_of_the_scrote Apr 29 '22

Claude Shanon too

1

u/CMPSMayeaux Apr 29 '22

I really like your explanation. Great job! 👏🏻👍🏻

1

u/[deleted] Apr 29 '22

Less space to write a number on paper…? Questionable.

1

u/maxpossimpible Apr 29 '22

Then you could consider biological life as just a number as well, albeit with base 4.

→ More replies (5)

1

u/Yeuph Apr 29 '22

I'd like to check that discovery of you cited of Hilbert. Do you have some keywords or a link so as I may indulge myself?

4

u/captainAwesomePants Apr 29 '22

Hilbert came up with a system for formalizing proofs into and very terse, simple mathematical language with the idea that it would make verifying whether proofs were true a matter of simply checking arithmetic: https://en.m.wikipedia.org/wiki/Hilbert%27s_program. His dream was using this system to create a version of math that was guaranteed to be perfect.

Godel figured out that Hilbert's proofs could be expressed as a number, and once it was a number it could be used to construct proofs about itself. Godel then used this fact to basically destroy all of Hilbert's dreams by showing that there were true laws of math that Hilbert's system could never prove without also being able to prove contradictions, and for an encore Godel showed that the same thing was true for every other proof system, which was deeply upsetting to mathematicians. Godel's proof is covered in detail in a bunch of pop science books and videos and I highly encourage watching one.

1

u/DweEbLez0 Apr 29 '22

Oh wise one!

On a similar but side note. For a base64 image string, is that essentially the binary number for that image? Like, is that the actual uncompiled code for that image?

Im a self taught + bootcamp grad but have taken some CS college courses.

→ More replies (1)

1

u/[deleted] Apr 29 '22

...this is roughly related to checksums right?

1

u/[deleted] Apr 29 '22

This is such an awesome response to a really interesting question. Thank you.

1

u/BigBootyBear Apr 29 '22

which led to Godel's incompleteness theorem, which is one of the most astounding, depressing, and important mathematical discoveries of the 20th century

Could you please explain to someone trash in math like myself, how a mathematical discovery could be depressing?

2

u/captainAwesomePants Apr 29 '22

Godel's Incompleteness Theorem states that any consistent mathematical system will have facts that are true but can never be proven.

That means that there are almost certainly some big math questions that are true or false (like P=NP or others) but that nobody will ever be able to conclusively answer. This is very unfortunate if you have made a career out of searching for a proof for a big math question.

→ More replies (3)

1

u/FunGuyCode Apr 29 '22

Your in-depth knowledge scares me...

2

u/captainAwesomePants Apr 29 '22 edited Apr 29 '22

Thanks, but don't worry. Everything sounds impressive when it's new. This is all undergrad Computer Science degree concepts mixed with enthusiasm (the stuff pop science videos are made of!). People tend to focus more on the programming part of CS degrees (because that's the bit you'll actually use in life), but the mathematical part is a whole lot of fun.

→ More replies (1)

1

u/Pythun Apr 29 '22

Username checks out.

1

u/kinghardlyanything Apr 29 '22

This guy computes

1

u/noneedtoprogram Apr 29 '22

Modern SSD NAND flash actually does store multiple values per cell, qlc is quad-level-nand, it can store 4 bits per cell, effectively writing in base 16 (as opposed to base 10 like the author suggests).

You are correct of course that what's important is the information density, and the representation you use for that doesn't matter, everything can be reduced to a binary representation anyway.

1

u/5Beans6 Apr 29 '22

Interestingly too, we actually do make memory that stores more than 1 bit of information in a single cell. MLC, TLC AND QLC all exist for NAND flash and each one has a higher memory density. But as you alluded to, the most reliable method is still single level cells.

1

u/[deleted] Apr 29 '22

So now I’m thinking, if everything can be reduced to data and all possible permutations of data could exist in pi… reality really is a hologram and pi is the encryption key.

Just a thought experiment.

100

u/HonzaS97 Apr 28 '22

Binary is convenient for computers because of how it is all implemented on hardware level. Very simplified, electricity being present is 1, it being absent is 0. Anything else is prone to errors because of fluctuations.

There is no point in adding extra overhead by another layer converting it to decimal / hex / anything else and vice versa.

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

Yes.

And for example, an infinite sequence of random 1s and 0s will contain everything that has ever happend and will happen, every program possible, every picture and movie and so on.

23

u/Smooth_Measurement_1 Apr 28 '22

How many 1's and 0's make a movie?

I might just spend my time putting 1's and 0's on paper now and write the next Hollywood masterpiece!

62

u/HonzaS97 Apr 28 '22 edited Apr 28 '22

Well, download a movie, see how big it is and there is your answer (eg 3GB = 3 000 000 000 bytes = 24 000 000 000 bits).

Now of course, you'd have to manage them in an order that'd make it possible to decode into something sensible. Soo, good luck with 224000000000 options I guess?

10

u/jcb088 Apr 29 '22

Here's what you do:

First, look at the population growth of humans. Assuming that we a.) leave earth and populate other planets and b.) maintain an interest in this question, how many people would it take to solve this problem within the next 100 years (or maybe longer, since population growth takes time).

Also, assume that 1 in 1 million people are working on this problem. Over time, imagine an industry forms of people creating films in which the data is randomly generated 1s and 0s.

My point is: maybe some problems can only be solved by a google of people working with a google of computers. More interesting than creating a good film, what film would be born of this analysis that no human could ever intentionally think to create? Sure, 99.99999999999999999999999999999999999999999999999999%+ of the films generated would essentially be static visually and audibly, but there is an extremely tiny golden nugget in there of material that could be so inconceivably fascinating it'd all be worth it!

9

u/captainAwesomePants Apr 29 '22

There's a famous short story about this idea called "The Library of Babel." It's about a universe full of rooms. Every room is full of books. Each book is a random ordering of characters filling a 410 page book. Every possible combination is somewhere in the library. Nearly every book is nonsense, but the inhabitants realize that, if every possible combination of letters is there, somewhere in there are the true books: https://en.wikipedia.org/wiki/The_Library_of_Babel

→ More replies (1)

12

u/Pantzzzzless Apr 29 '22

Sure, 99.99999999999999999999999999999999999999999999999999%+ of the films generated would essentially be static visually and audibly, but there is an extremely tiny golden nugget in there of material that could be so inconceivably fascinating it'd all be worth it!

This is basically the Many-Worlds Multiverse theory scaled down to movies.

→ More replies (3)

2

u/[deleted] Apr 29 '22

This is why digital property rights get kind of bizarre: in a real sense, piracy is the illegal downloading of numbers. When you write a program, or make a digital image, or a video, or a song, or literally anything digital to which copyright attaches, you're effectively copyrighting a number.

→ More replies (1)

0

u/LilQuasar Apr 29 '22 edited Apr 29 '22

And for example, an infinite sequence of random 1s and 0s will contain everything that has ever happend and will happen, every program possible, every picture and movie and so on.

thats not true. it might contain every possible finite sequence but it might also not do it

edit: for the people downvoting, you might want to check this out

→ More replies (2)
→ More replies (8)

59

u/Bacon_Techie Apr 28 '22

The reason we store things in binary in the first place is because it is the most accessible format for computers to read, unless it’s an analogue computer. In order to store that decimal number in the first place it would just be converted to a binary number. They both take the same amount of space because they contain the same amount of information. It would take the same amount of information to store 23 as it does 10111.

106

u/Immanonner Apr 29 '22

Hold on....I think I understand...

hits blunt

If everything is ultimately binary...

Coughs

Does that mean our life can be represented by a specific number?

And if we knew the whole number sequence beginning to end we could potentially examine the end of the sequence to tell the future before it happened?

Isnt that basically DNA?

Some say that Calculus is the language god speaks...but now I'm beginning to wonder if he only speaks in binary.


Great questions, loved reading the answers--this is why I follow this subreddit.

36

u/xxxxx420xxxxx Apr 29 '22

We can represent everything as numbers, but shit changes all the time and we can't know what's going to happen in the future at certain scales <hits vape>

5

u/caboosetp Apr 29 '22

we can't know what's going to happen in the future at certain scales

If you call dispatch, they can probably give you a rough idea of which trucks are headed to those scales now though.

2

u/Tino_The_DM Apr 29 '22

And while we can represent anything as numbers, we interpret it all as language, and language is just arbitrary. There is no sign without a signified, and what is signified is arbitrarily determined <sucks last little bit out of the roach>

29

u/POGtastic Apr 29 '22

11

u/protienbudspromax Apr 29 '22

Damn there really is one for everything.

14

u/Cquintessential Apr 29 '22

No, DNA has context. Codons are 3 nucleotides, which translate to various proteins. While you could abstract the literal DNA sequence to a number, it would have very little meaning without the part that reads it.

A better statement would be that everything is binary in state. It’s either there or it isn’t. Now you can extrapolate and say that you can have “nothing” or “everything”. “Something” is every value in between that nothing and something.

So between 0 and 1, there are infinite rational and irrational integers in the interval. If you look at mathematics and topology, you can see that manifolds can have their “something” and “nothing” translated across dimensions (holes and such.)

Anyway, I’m neither a mathematician or a theoretical physicist, so this is probably all wrong and terribly communicated.

7

u/BeauteousMaximus Apr 29 '22

I am a Strange Loop by Douglas Hofstaeder goes into this and a lot of related questions.

3

u/captainAwesomePants Apr 29 '22

I'm super excited you cited this one. Everybody talks about Godel, Escher, Bach, but Strange Loop is great!

2

u/not_some_username Apr 29 '22

I'm watching an anime like that

2

u/JBatjj Apr 29 '22

Real life is rendered in quaternary

2

u/[deleted] Apr 29 '22

Hello everyone, this is your daily dose of existential crisis

1

u/protienbudspromax Apr 29 '22

There are a subset of numbers that cannot be represented in a turing machine tho. Any set which is uncountable are thus by nature not something that can be resolved inside a turing machine.

Things which are discrete and enumerable are things that turing machines can compute or atleast understand.

Countable things are anything where you can say a "next".

Like the natural numbers. You can say that 2 is 100% coming "next" to 1 and there is nothing in between.

But if I ask you what comes after 0.01??

You cannot give me a number, because any number you give I can give back a number between your number and this 0.01 so my number should have been next?

These kind of sets is where turing machine cannot compute.

1

u/sephirothbahamut Apr 29 '22

Wait until you find out about the Planck length

32

u/tekkub Apr 28 '22

Yup! That also means some numbers are illegal somehow.

8

u/indigoHatter Apr 29 '22

That was way more interesting than I expected.

31

u/Sticky-IPadKid Apr 29 '22

i literally thought about posting something like this yesterday.

my entire hard drive just stores a number.

the cure to cancer is a number.

if you can find a way to store it, your consciousness is just a number.

if you can have a file format that stores atoms, the entire universe is just a number.

7

u/top_of_the_scrote Apr 29 '22

makes me wonder if you can brute force new ideas by randomly flipping bits

like you generate a PNG with random pixels and you squint at it like "yeah that looks like a 9 cylinder engine" lol

6

u/umhiwthishappeninh Apr 29 '22

project idea: randomly generate images with random pixels until a new idea is created

2

u/top_of_the_scrote Apr 29 '22

yeah was thinking you just bombard your brain until you solve the 3 body problem or succumb to the radiation /s

→ More replies (1)

2

u/TiagoTiagoT Apr 29 '22

That's sorta how neural networks work at the most basic level...

0

u/[deleted] Apr 29 '22

[deleted]

31

u/obp5599 Apr 28 '22

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?

No because what you read as 1 and 0 is not the computers representation. When you read '5' on a computer screen, that is an ASCII value, represented by 1 (8 bits) in memory. To the computer EVERYTHING is binary. Its not a matter of choice. It has to be, based on how the hardware works. So the number 570 would be 24 bits, while 570 in binary would be 10 bits

29

u/[deleted] Apr 29 '22

Basically you have independently discovered that turing machines are countable! Let's parse that theorem down:

  1. Turing machines are the formal model of computation.

  2. Turing machines have a finite representation on a linear tape using a finite alphabet.

  3. Because their length is finite, and the alphabet is finite, we can order them in lexicographic (or dictionary) order.

  4. If something can be ordered, it can be numbered.

  5. As an extension: The set of all mathematical problems is uncountably infinite, whereas the set of all computer programs are countably infinite. That proves that some problems cannot be solved by a computer.

This is undergrad theory of computations stuff. Good job figuring the essence out on your own.

11

u/Zjarr- Apr 29 '22

I really like these posts with avid debates about technical stuff

10

u/Long_Investment7667 Apr 29 '22

If you want your mind to explode, search for Gödel encoding . It starts with the idea that every program in a specific language can be represented as a number and every interpreter of that language that evaluates a program is “just” doing arithmetic

8

u/48911150 Apr 28 '22 edited Apr 29 '22

How do you suggest we store 57000443836 in order to save storage space?

4

u/SKR47CH Apr 29 '22

Obviously on paper and pen.

5

u/arbobendik Apr 28 '22

Your computer can only store and calculate with binary values so any other system is not an option

5

u/ValentineBlacker Apr 28 '22

The order that the 1's and 0's are in, is also important.

9

u/[deleted] Apr 28 '22

It doesn't quite work like that.

Computers are state machines - they move from one state to another. The ultimate simplicity in state management is a system that has two states - on and off. This on and off situation can be represented by 0s and 1s, and it can also be usefully represented by electrical voltages. That's all a computer is.

What you're talking about is actually the state machine viewed in reverse. You can take these states - on and off - and use them to represent numbers by configuring them in specific ways. It's more the flow of 0s and 1s that's important though.

It's like, 1 here changes the 7th item there into a 1. If the 7th item is a 1, the 12th item becomes a 0. If the 12 item is a 0, the 15th item becomes a 1 etc. What's the value of the 15th item if this first is a 0?

That's sort of the value of computers - they build in these state transitions, but allow for changes to the way the transitions happen. It's actually the variance in transition that's useful.

3

u/Putnam3145 Apr 29 '22

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?

You're storing the same amount of information, just in about 30.1% the symbols, which doesn't matter that much.

Despite all the people saying that we don't do this... we kinda do? A quad-level cell solid state drive holds 4 bits in each of its units, which is the same as a single hexadigit. This does save on space, but it's less reliable, which is why we we're on binary in the first place.

3

u/yiliu Apr 29 '22

As others have pointed out: yep, a program is just a number.

This reminded me of an old thought experiment, from the early days of file sharing. All files, and in particular all media files, are also just numbers. A video of the latest Marvel movie is just a number.

So you could take that number and perform some math on it: divide it by some other number (call it a), and get the result, b. Take that number and use it to divide a file containing a fresh rip of the latest, I dunno, Kanye West album, getting c.

You're left with a bunch of numbers, meaningless on their own. But a * b equals the latest Marvel film. b * c equals the most recent Kanye album. And so on.

Are the numbers therefore illegal? The numbers don't mean anything on their own. No number can be said to be 'part' of a specific piece of media, any more than it can be part of any other. Is it the formula (i.e. a * b) that's illegal? Or just the calculation of that formula?

Anyway...interesting to think about.

3

u/martinborgen Apr 29 '22 edited Apr 29 '22

Apart from compression, yes to all.

It goes even further though! The binary number is itself actually just a representation of an on/off configuration in a bunch of wires that causes switches to be on or off in a certain way, that makes a certain operation happen inside a computer.

Or as someone once said: digital electronics is actually just lots of very small and fast analogue electronics.

This is why it's stored as binary, because it's not the value of, say, fourteen (decimal 14, binary 1110) that's what we're after, but that these four wires are ON, ON, ON, OFF that causes the next clock cycle in our CPU to do what we want.

2

u/gbhall Apr 29 '22

Mind blown bro

2

u/rayjensen Apr 29 '22

Great question. I’m gonna ask my prof this sometime myself haha

2

u/mushpotatoes Apr 29 '22

For what it's worth. Any program is just a number, but different processors will interpret that number in different ways.

Any thing that can be measured can be represented as a number, but the context of the number is also important. In the case of computers, that context would be the machine language/instruction set.

2

u/ruat_caelum Apr 29 '22

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.

This is like saying which is heavier 10,000 pounds of feathers or 10,000 pounds on concreate.

They are both the same weight.

Likewise the "number" and the "program" have the same amount of information you can't "Shrink it" by converting from one to the other because they are the same.

A rocket transporting our feathers or concrete to space would need the same fuel because the weight is the same. A memory card holding the number or program would need the same storage because the information is the same.

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

We don't have the means to do that. We have the means to hold an electrical charge (1) or not charge (0) how would we have a "base ten" with that? either something has charge or not. two states, so binary.

And again even if we did have a base ten circuit the DATA is the same. Just like the wight of feathers or concrete is the same no matter if we convert one to the other the fundamental measurement is the same.

Is that how compression works?

It is not as you aren't "compressing" anything you are "Converting"

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

Well let's think about this logically. What makes it "shorter" the "bandwidth" of the symbols right? So if we have base 8 OCT we only have symbols 0-7 (8 different symbols) base 10 had 10 of course, base 16 HEX has 16 symbols by extending into the letters A-F, what we made up a base 36, it runs from zero to nine, then A, B, C, like Hex but all the way to Z. We could hold 36 values in a single position, and the value of 37 would be represented at "10"

Now let's extend this logically even further. Say we just draw random symbols without duplication until we have 300,000 of them. Now we can hold a unique value in 1 symbol from 0-299,999 (base ten)

Does this gain us anything? Are we making the NUMBER smaller, or just how it is represented? isn't this just another type of CONVERSION like conversion feathers to concrete but still having the same weight?

The answer is yes, it's a conversion, not compression. Even though you are displaying the "number" in fewer and few digits, the VALUE of the number will always be the same.

  • How does compression work then?

The easiest answer is that it throws away data you can't use. The VLUE of the number is less or fewer, the weight of the feathers is less, etc. For an MP3 a computer program looks at all the data and determines for instance that because a big bass beat is playing at the 3 second mark, your human ears cannot hear the flute or tringle anyway. So instead of keeping that data that you won't be able to use. It removes it completely. This is LOSSY compression. LOSELESS compression is a bit more difficult to explain and I'll skip that for now

2

u/Rythoka Apr 29 '22

Congratulations on re-discovering the reasoning behind Gödel's Incompleteness Theorem! It's math-heavy, but there's some good content out there if you want to learn more about it. I recommend the YouTube video by Veritasium: https://www.youtube.com/watch?v=HeQX2HjkcNo

From a programming perspective, the arguments in that video about the existence of true statements without proofs is about undecidability, a concept which defines the limits about what can and cannot be solved by a computer.

1

u/crossedline0x01 Apr 29 '22

Dude! I just posted a comment about the re emergence of analog computers hahaha. It's by Vertasium too, they have really good stuff.

2

u/axl00000 Apr 29 '22

The question is... Do I really exist in PI? Am I just a number?

2

u/vi_sucks Apr 29 '22

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.

Because the ultimate data storage is a bit. Which stands for "binary digit". At the basis of everything what you have is basically an electronic switch that is either on or off.

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?

We do. Well not in decimal but more likely in hex or whatever. It's just easier to store numbers in powers of 2 because, again, the final base level storage is in bits.

2

u/pushedright Apr 29 '22

It's all in how you interpret the binary.

2

u/[deleted] Apr 29 '22

Oh, it's worse, any movie or song you download is also just a number. That means that copyright is literally making certain numbers illegal to use or look at.

1

u/Locomule Apr 28 '22

You are prioritizing storage space over speed.

1

u/[deleted] Apr 29 '22

Lots of great answers so I'll just comment on one point others have missed.

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

Not compression, but that's how multi-level cell flash memory works. The original technology is binary, but if you use four charge levels you get two bits per cell. 5 bits as the current limit of practical technology, which requires 32 distinct levels.

The cells stay the same size, so you can increase the storage density by a factor of four or five.

But the disadvantage is that it's harder to precisely set or read the charges. So MLC memory doesn't last as long as single-level and it's typically slower, especially the write speed.

So the memory manufacturers are another step ahead and actually use SLC to buffer newly written data. This is one of the reasons why burst write speed is better than sustained.

1

u/Prize_Bass_5061 Apr 29 '22

Tangentially, your questions are also related to hashing.

Every file on a computer is a very large, specific number. We can generate a shorter number (hash) that represents the larger number. That’s what the md5sum terminal command does. It’s how we compare files instead of comparing them byte for byte.

In general that’s what hashing is. Generating a smaller number to represent a larger one. Hashing is not compression because data is lost. So we cannot compute the large number given its hash.

1

u/Graphenist Apr 29 '22

Yes, but its an extremely long and precise number, and you wont save space converting it to Base-10. Informational entropy will forbid you from compressing arbitrary data an arbitrary amount...

At least, all math and logic seems to indicate that arbitrary data can not be compressed arbitrarily. If you could break that assumption, it would easily be the greatest discovery of all time. But dont get your hopes up because its pretty obviously impossible, and can be proven to be impossible

1

u/nomoreplsthx Apr 29 '22

Every program is a number Now go read about Godel's incompleteness theorem and be prepared to have your mind blown: it also turns out every possible sentence in any language can be represented by a number, and you can prove insane things about any possible system of logic from that fact.

1

u/Autarch_Kade Apr 29 '22

Related to your questions is this video I watched just an hour ago:

That unbelievable function that can compute EVERYTHING! It discusses boolean logic and how a few simple operators can be used with any input to make every single possible program.

1

u/[deleted] Apr 29 '22

Representing a single state of an operating system/app is one thing but both are constantly changing states over time with input so it’s never just a single number forever.

The other reason has to do with how data is stored on solid state drives. They are stored in charge flash trap devices which I believe can only exist in 8 states at the moment.

000 001 010 100 011 110 101 100

You have to change the way things are stored as well as how they are compiled too accomplish

1

u/arkie87 Apr 29 '22

I mean, if a program is 1 kilobyte, that is 2^(8*1024) which is a number with 2467 digits, which would take of up nearly a kilobyte of memory, so I'm not sure you would really save that much space

1

u/arkie87 Apr 29 '22

perhaps 30 years ago, this would have been a convenient way to compress programs, but now adays, space is not really an issue. the time it would take to decompress wouldnt pay compared to the space saving.

1

u/[deleted] Apr 29 '22

Yes, Google the illegal prime, which is actually a program that breaks encryption but in number form

1

u/MurderousTurd Apr 29 '22

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?

We know that computers "think" in binary. So when memory is stored, it is in binary.

Even though the decimal(or hexadecimal) representation of a number looks smaller, it still gets stored on the memory as binary, and then gets converted to decimal or hexadecimal for readability purposes.

It is possible in theory to have a memory based on 10_decimal position switches, but the information would have to be converted to binary for the computer to use, a process that would take time to do. In fact, there is a device that can kind of do this already - an analog to digital converter, but they tend to use very specific readings and and in small (comparatively) quantities.

For information to be stored an used in other formats would require computers built on that format. How that would work is well outside my wheelhouse and would be better for a computer scientist/engineer to explain.

1

u/Rapsideal Apr 29 '22

This post got me thinkin'...

1

u/morphotomy Apr 29 '22

Yes. When you're specific enough, everything is its own name.

1

u/at_zero Apr 29 '22

All languages produce machine code which uses binary.

1

u/WildkurtOfGood Apr 29 '22

At the hardware level you would be limited by the number of bits the computer can process at once. So you would still be restricted to lines of code. It would be possible to line up everything in 1s and 0s, but that number would larger and beyond comprehension. Keeping in mind that every position represents 2 to the power of some exponent, it can get way out of hand exponentially.

1

u/BeauteousMaximus Apr 29 '22

We do store programs in binary, because everything stored on a computer is stored in binary. Both the source code and the compiled executable program are stored in binary.

The reason we write with programming languages instead of just going in to poke at zeroes and ones is that programming languages provide useful abstractions that allow us to not worry about lower-level issues like which memory registers hold the relevant bits for some value, and instead we can have things like classes and objects and functions and database connections and web requests and file input/output and a million other things where you don’t want to worry about how they are implemented on a specific machine, you want to make them work consistently and handle common errors and complications without thinking about them.

Of course…below the level at which all data is binary, all signal is analog :) for example:

https://en.m.wikipedia.org/wiki/Single-ended_signaling

The widely used RS-232 system is an example of single-ended signaling, which uses ±12 V to represent a signal, and anything less than ±3 V to represent the lack of a signal.

1

u/madhousechild Apr 29 '22

Imagine writing a program that works out to 6.057991032254544522218884 x1046 and the bug is that it must be 6.057991032254544522218883 x1046. Wow.

IDK but I like how OP thinks. I once wrote a program to reduce yelp data to a bitstring and then each business had a number, but they weren't unique.

1

u/AppropriateSeesaw1 Apr 29 '22

Duh, how else do you think your hard drives store your programs?

1

u/green_meklar Apr 29 '22

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

Yes. This is more of a theoretical CS question than a programming question, though.

Also, if everything is ultimately binary, that raises the question of how you tell where a given number ends and the next one starts. You could interpret the contents of your hard drive as different programs depending on where you decide to stop.

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.

Because the storage is binary, too.

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?

Because the decimal storage would be more expensive per digit. Indeed it would be about as much more expensive as the number would be shorter (and would be less convenient for programmers). You can't get information 'for free' converting either way.

Is that how compression works?

Not really. Data compression just converts binary to binary, the trick is that you use it on binary numbers that have nonrandom patterns in them and you take advantage of those patterns to map larger numbers onto smaller numbers.

1

u/humaneWaste Apr 29 '22

Because to store any number requires the binary representation for digital storage.

Everything is stored as bytes(a collection of 8 bits), which is also base 256. Hex is only base 16. Storing a program as hex (one hex character per byte) would actually double the size of it.

Storing decimals as bytes could triple the size:

32 bits is 4 bytes, or four characters. Which can represent a value upto 4.3 billion, which is 10 characters(decimals).

Ultimately bits are only sub-addressable. Bytes are the minimally addressable limit, which is what memory and storage both utilize as far as software developers are concerned. The hardware deals with bits transparently, for the most part.

Like, if you open a file to read or write you'll be using bytes. Same with allocating and addressing memory. If you want to deal with bits there's bit-wise operators....

So that's where we're at. Storage (and memory) is essentially base 256, far better than hex or decimal! But regardless, computers compute and store everything at the bit level.

1

u/krackout21 Apr 29 '22

It may sound mind blowing these days, but in the past there were programmers who wrote binary directly. Not assembly, binary! More usual, for convenience, they wrote in hex and converted to binary.

The most known example of such a programmer is Steve Wozniak. If I recall well he wrote the firmware and BASIC of Apple I in binary, because he couldn't afford assemblers and compilers - or time sharing computers; all of them expensive in the past.

1

u/andrisb1 Apr 29 '22

Somewhat related, that's actually how RSA encryption works. Take a file in the form of a number, do math on it (really just multiplication), result is the encrypted file. To decrypt it you would need to do the math in reverse, but without knowing other part of the equation (the private key) you would need to brute force it. Which, due to size of the numbers is nearly impossible.

2

u/[deleted] Apr 29 '22

Just an addendum to this, it's super cool how RSA uses prime numbers. It multiples two large primes together, making an even larger semiprime. That semiprime has the two original primes as its factors, but the math required to find all the factors for the semiprime is very time consuming. That's why it's still possible to securely encrypt things with this system using large enough keys, but cryptographers also know that certain quantum algorithms are going to be able to do the factorization much quicker and so RSA encryption will be rendered useless once quantum computers become more of a reality. That's because--going back to binary--quantum computing isn't limited to just 0 or 1, off or on, but can be off and on at the same time. Which is a concept I personally still cannot get wrap my head around, but it all wraps back around to quantum physics and Schroedinger's cat.

1

u/kagrom Apr 29 '22

Yes, and its all contained in PI number!

1

u/diorcula Apr 29 '22

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.

I don't think this is true, as this would only account for 1 of the states of the program?
When you press a button or give some input there will be a change in bits somewhere in the program ultimately changing the outcome of the number

Therefore I think it would probably be a range of numbers?

1

u/Grtz78 Apr 29 '22

A program is a state that in its state encodes the means to alter its state.

That's all a Turing Machine really is.

1

u/sullyj3 Apr 29 '22

To add on to the other excellent answers, there's a very approachable book called The Information by James Gleick that goes into this stuff and the implications in detail.

1

u/igglepigglesblanky Apr 29 '22

If you think it is possible to have a sentient computer (AI) then some very large numbers are sentient .

1

u/[deleted] Apr 29 '22

And if numbers are just patterns? Isn’t programmes just a pattern? It’s everything one pattern!

1

u/[deleted] Apr 29 '22

aaah i love this question !!!

here's short python program that will show you the actual 0s and 1s that represent any file or program on your computer:

import sys 
 
# Read the file and load it into a string 
filepath = sys.argv[1] 
f = open(filepath, 'r') 
st = f.read() 
 
# Convert the string to binary 
bin_data = ' '.join(format(ord(x), 'b') for x in st) 
 
# Display the string 
print bin_data  

if you save this program into a file called hex.py, you can run it like this:

python hex.py /link/to/file/you/want/to/see/in/binary/code

source: https://www.quora.com/How-do-I-get-the-binary-code-of-any-file

one thing that confuses me about this though is that these are separated by spaces and not all of these blocks are the same length. i guess it would be more accurate to prepend an appropriate amount of 0s to those blocks which are less than 8 bit (=1 byte) long?

1

u/chervilious Apr 29 '22

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

Yes, Ted ed make a good video about it

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.

Because binary is easier to work with for computers, physically it's just whether something has a current or not, if you could make something that has 10 states and is efficient enough you can make a new computer architecture. Current computer architecture relies on binary.

From StackExchange:

Because binary lends itself naturally to an ON-OFF system where ON means a current and OFF means no current. Using 10 different voltage levels would be very error-prone.

... Overall, the binary system wins because it is the easiest to design circuits with and the easiest to analyze and implement.

Other than that, remember that everything is recorded in binary, even decimal. There will be no space-saving whatsoever, in fact, it will make the program slower because you need to convert it.

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

We human look at this and said the right one is shorter, computer store both as the same.

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

As stated before, both are the same length for computers. Unrelatedly when you're reverse engineering you're usually looking at the hex instead of the binary, it's easier for humans to reverse engineer a hex compared to a binary.

1

u/donotlearntocode Apr 29 '22

I see a lot of comments in here about why we store data as binary instead of decimal, but not about how "programs are numbers". That took me some time to wrap my head around.

So when you write a program, it gets compiled from the language you wrote, which is what converts it to "a number", but it can also be seen as a list of numbers. These numbers represent instructions to the CPU. Instructions might be add this, load that, jump there, store this, etc. Each instruction maps to a number. So add might be 1, jump might be 2, etc. So when you turn the computer on/load a program/boot the OS/etc, you tell the CPU to start reading numbers from the big number that is your program. Computers' instructions are a specific bit-length, so it reads that many bits out of your program. That number lights up a series of bits on the cpu, which causes the CPU to do whatever instruction is associated with that instructions, then the next chunk of N bytes are read.

2

u/tidewater41009 Apr 29 '22

Any ordered sequence of numbers can be represented by a single number. Two way Video number function.

1

u/AlexAegis Apr 29 '22

"Can a program be represented as a number"

yes

"can linux be represented as a number?"

No*.

* But it can be represented as a set of numbers because you can compile linux in many ways and they would all produce a different result.

But it also depends on what we mean when we say linux. Is it the combination of all possible things you can build from it? or the sourcecode itself?

1

u/cuddleslapine Apr 29 '22

by linux, I think he meant a Linux installation at a given time (or rather, I guess the OS as whole, that runs on a machine)

1

u/[deleted] Apr 29 '22

never thought of this before, the whole thread is enlightening🤯

1

u/hali_mehdi Apr 29 '22 edited Apr 29 '22

I tkink, and i might be wrong, that there is actually no such thing as decimal either, in machine world decimal it self is but a graphical representation of a binary number that actually stored in memory, that is why we can not sace space by converting a binary to decimal, cuz actually in memory it does not get converted.

1

u/wgunther Apr 29 '22

This is a very good observation, and a very important one in mathematical logic: https://en.wikipedia.org/wiki/G%C3%B6del_numbering

1

u/LucidTA Apr 29 '22

We're all just monkeys on a type writer bro.

1

u/pocketmypocket Apr 29 '22

The only other thing to mention here, your compiler makes the number specific for your hardware and/or operating system.

I couldn't take an arduino program and put it on my CPU.

1

u/DryPenguin0w0 Apr 29 '22

bro if you wanna engineer a wacky base 3 computer prototype and write assembly for it, i'm all for it

1

u/dota2nub Apr 29 '22

I think it's been done and deemed impractical.

1

u/the-B-in-Brick Apr 29 '22

It is true that everything in a modern system is binary, until quantum computing becomes reality.

That’s because data is stored one bit at a time in a transistor, and that transistor has two (bi) states loosely viewed as on v off. (Hence BInary-Transistor = bit).

Current systems cannot store in decimal, because transistors don’t have 10 possible states, only two. We write it on paper as decimal because that’s a convenience for humans. Current computing architecture doesn’t understand decimal. Or even alpha-numeric. Only binary.

The different coding languages are all created for human convenience. The C language, considered one of the closest languages to that understood by a binary computing system, isn’t read by a computer.

When completed by the human it gets compiled. It is converted to a series of binary “pieces” in a way that’s specified by the Instruction Set Architecture (ISA) of which you may have heard of x86 commonly used by Intel & AMD, or RISC used by ARM.

From here, it’s fed into the processor comprising two main parts — the code & the data.

For example, “add the data stored at location (register) A to the data stored at location B, and save the output to location C.” It is thus the compiler’s job to convert human-written code into machine readable code (fun fact: different compilers churn out slightly different results, and some coders are very loyal to their chosen compiler)

The exact “rules” for this process is specified by the ISA. (The above is a simplification). Because of the differences in architectures, code compiled (into binary) for x86 can’t be run on RISC. But the human written code (aka source code) hasn’t yet been broken down into machine code, so it can (generally) be swapped between systems.

This means that your broader question is right, all code and data is binary, and that in theory could be represented as a decimal number.

The entire movie The Matrix could be represented as one really really long decimal number.

But if you were to change just one single frame of it, that long decimal number would look entirely different. In binary (or decimal), a screenshot of a pic would be a number entirely different from the original.

If we simplify the concept and instead of a movie represented as an absolutely unique number we took, I dunno, a pixelated cartoon of an ape what might you get? Yup. An NFT. But that’s a story for another time.

1

u/lordtnt Apr 29 '22

Yes and copyrighted music, videos, and everything digital is like copyright a number.

https://en.wikipedia.org/wiki/Illegal_number

Numberphile has a 9 year old video about this: https://www.youtube.com/watch?v=wo19Y4tw0l8

1

u/HandMadePaperForLess Apr 29 '22

You are correct, and it is an interesting idea. The reasons we don't translate the number are:

It takes a ton of work to translate between systems. Going binary to hex is a little easier than to decimal, but it is a lot of work.

We don't have a good way to store decimal or hex that a computer can read. Computers read binary, and we can store that in a way that goes straight into computer brain. For this we would need to store the number somewhere else and translate it in binary signals.

1

u/jacobyllamar Apr 29 '22

The most basic computer component is the switch. And, of course, it's innately binary (on/off.) So that's why we store things in binary. If you had a transistor switch that has 10 different emission levels, then you could store one decimal numeral there, but building that is WAY more complicated than a binary one, so we just build tons of 2 level switches.

I've skipped many details, but, more or less, that's why we can't just compress something to decimal.

1

u/[deleted] Apr 29 '22

Hey, one implication of this, is that every program already is its own hash code.

1

u/dota2nub Apr 29 '22

Best hash function, no collision, much wow.

1

u/some_clickhead Apr 29 '22

If you store programs in decimal, there will still need to be a bunch of 0's and 1's to represent those decimals, because as you said, 0's and 1's is all that the computer can store at the end.

It's similar in principle to compression, yes, it's just that in this case you aren't compressing anything because you haven't reduced the amount of information necessary to represent your code (the decimal would have to be long enough to uniquely identify your program, so it would take up a lot of space regardless).

An easy way to understand how compression works is this:

[0, 0, 0, 1, 1, 1]

could also be represented by:

[ (0, 3), (1, 3) ]

If I decide that in the second array, for each pair of numbers (x, y), x represents the value, and y represents the number of consecutive instance of that value. This type of representation would achieve a very high compression rate for arrays which feature a lot of consecutive, similar numbers.

Then I could call the first array a PNG and the second one a JPG, and I would just need to make sure that other computers know how to read and interpret them according to their specifications.

1

u/dota2nub Apr 29 '22

What do you save that number in? Oh yes, binary! Whoopsies!

You don't actually, have access to anyting else at the memory level.

1

u/[deleted] Apr 29 '22

S

1

u/crossedline0x01 Apr 29 '22 edited Apr 29 '22

Some really smart people are trying to make analog computers a thing again. I guess its inevitable once we reach the climax of Moore's law , which I think is closer than most think. We already have a transistor that's pretty much the size of an atom. Once we breach that barrier I think the number will be more of a continuous unknowable number rather than a discrete absolute one. The best well be able to do is approximate its value.

I'm not sure, but I think right now an approximated program is an impossibility. A problem that could only be solved with an analog device itself. Cool and interesting question.

Link: https://m.youtube.com/watch?v=GVsUOuSjvcg

1

u/Greedy-Turnover5659 Apr 29 '22

Dayummm ...🤯🤯 Literally blew my mind after reading your first question ... Never occurred to me 😂😂

discord : Blockchain Learning Community DApp World https://discord.gg/jUQwyKQt2V

1

u/ImprovisedGoat Apr 29 '22

This is all absolutely mind blowing. Is there a book I can read more about this?

1

u/Pickled_Wizard Apr 29 '22

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

Yes. Also, there's a solid chance it exists as a sequence within pi.

1

u/andy9775 Apr 29 '22 edited Apr 29 '22

Using Godel numbering one can assign a number to each program (or function or TM).

Proofs which use the halting set usually define the set as the index of a function which halts making the halting set, a set of numbers

1

u/Gantzz25 Apr 29 '22

Wow very interesting post and answers!

1

u/NaifAlqahtani Apr 29 '22

Really great question! Thanks for asking.

1

u/fbidu Apr 29 '22

Here is a small python script for you to toy around with that idea

https://gist.github.com/fbidu/28dfb1949756dd81a788cd58345aecfd

run it, study it, break it. You'll find some amazing things following that train of thought!

0

u/shawntco May 02 '22

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

This is one of those unintentionally brilliant observations that usually only newbies ever have, I love it

1

u/Smooth_Measurement_1 May 02 '22

How was it unintentionally brilliant? How do you know it wasn't intentional? That's completely discrediting my intelligence by saying that I accidentally asked an intelligent question.....

-4

u/gruntmeister Apr 28 '22

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

Yes!

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.

We do store them as a number. What did you think we're storing them as? I don't remember ever having to type in "5000 pages of 1s and 0s" in my computer to run a computer program.

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?

Because computers, hard drives, cd's, dvd's, store data digitally. You might've heard the term.

Storage would be much less.

No. Please explain: unless you're still thinking about printing data out on paper, how would 57000443836 take less storage than 110101000101011111011011111110111100? It's the same number, the same amount of information. What storage are you talking about in the first place? Digital storage? Like hard drives?

→ More replies (1)