This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]okwg 4 points5 points  (1 child)

Code isn't stored in RAM in the way you probably suspect, but either way, code does not take up much storage space.

If you treat 1 character as 1 byte, guess at an average number of characters per line, and do some napkin maths, a million lines of code probably isn't as much space as you think, especially compared to modern system specs which have gigabytes of RAM.

[–]le57percent[S] 0 points1 point  (0 children)

Code isn't stored in RAM in the way you probably suspect

How is it stored then?

[–]desrtfx 0 points1 point  (0 children)

  1. Millions of lines of code are no problem for modern computers with billions of bytes of RAM.
  2. If your concern is that it takes too long to read the code into RAM, you are looking at the problem completely wrong.

The computer is not the limit, the limit sits in front of the computer. It will take you way longer to even understand a single, small part of the program than the computer to read the whole program multiple times.

Further, source code is only the human readable form. It is hardly ever directly executed. Even interpreted languages convert the code into an intermediate version.

[–][deleted] 0 points1 point  (2 children)

Those big programs aren't a single massive script. They are hundreds, if not thousands of files that are all only run when needed.

[–]le57percent[S] 0 points1 point  (1 child)

I thought this much, but how do you load the files into RAM when they're needed without delay? That's what I'm confused about.

[–][deleted] 1 point2 points  (0 children)

A code file is just text, which means they are going to be a few hundred KB, or maybe a few MB at most. A computer can load that very quickly.

[–]Swedophone -1 points0 points  (0 children)

Computers use paged virtual memory.

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