Whenever we write code, after compilation the code will be converted to machine language and then stored in the hard disk. But before compiling the code, it is still in the high-level language. How and where the memory is allocated for the code before compiling the code while it is in a high-level language.

I assume, before compiling the code is stored in RAM, but how? because we can only store in machine language in RAM.

If there is any wrong with my question or it is a wrong way of asking, please comment below. It will be helpful

  • $\begingroup$ Welcome to the site. Of course I have no way of knowing where you got the notion that one can only store machine language in RAM. We can store anything, in any format, in RAM. It's just bits as far as the computer is concerned. $\endgroup$ – Rick Decker Sep 6 '20 at 17:27
  • $\begingroup$ isn't the machine language is nothing but bits? $\endgroup$ – SHASHIKANTH GAJJELLI Sep 6 '20 at 17:38
  • $\begingroup$ @RickDecker when we write something in notepad, how it is converted into bits(machine language)? $\endgroup$ – SHASHIKANTH GAJJELLI Sep 6 '20 at 17:40
  • $\begingroup$ I can store machine words in RAM. I can have them interpreted by the RAM containing that memory - during compilation rather than before. $\endgroup$ – greybeard Sep 7 '20 at 14:26
  • $\begingroup$ @SHASHIKANTHGAJJELLI it's not converted into bits. it's always bits. there is nothing else. $\endgroup$ – user253751 Sep 8 '20 at 18:45

Typically source code is stored in a file on your hard drive or SSD drive. Usually you have backup copies in all kinds of places, and you use source code control to store more copies in more places, together with the ability to get older versions or newer versions to your files at any time.

When compiling, the source code files are read like any other files. Maybe they are read completely, or only in parts. Whatever the author of the compiler thinks is most efficient. The source code will be moved to the address space of the compiler, and then to RAM. Depending on your operating system, if you compile the same program multiple times, file contents may be automatically cached in RAM.

  • $\begingroup$ Thanks for your response, but my question is, how the source code is stored in RAM or drive, in which format. Does it automatically gets stored in bits( or machine language)? $\endgroup$ – SHASHIKANTH GAJJELLI Sep 7 '20 at 2:32
  • $\begingroup$ If I open a notepad and write some content, how it is converted to bits and before saving, where does it gets stored? $\endgroup$ – SHASHIKANTH GAJJELLI Sep 7 '20 at 2:33
  • $\begingroup$ So your question has nothing to do with compilers? $\endgroup$ – gnasher729 Sep 7 '20 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.