Does any programming language use memory?

Asked

Viewed 440 times

11

When I write a program in any programming language, compiled or interpreted, is it necessary to run a RAM? Please explain.

Being more specific, I made a text editor using Javascript. When this text editor runs in Javascript, what happens? This goes straight to memory or straight to processor?

Because if we have the source code of some program, it is to imagine that this source code is somehow free, it does not depend on the operating system but on the language that was written.

Because of this, a source code + programming language would not need, or would not necessarily have some kind of storage, for such a feat. That is, either compile or interpret, it is the same. If you compile, somehow you make an interpretation the same happens with interpreters. And you wouldn’t need RAM either.

  • 2

    Nor do we exist without memory... :(

  • Related: https://answall.com/q/209542/64969

  • If I remember correctly, in order for any program to run it must be loaded into the computer’s memory. RAM memory is used by the processor to store the files and programs being processed. https://pt.wikipedia.org/wiki/RAM

  • Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.

2 answers

13

When I write a program in any programming language, compiled or interpreted, a RAM is required to run?

Theory

All programming language must be Turing Complete, otherwise it cannot receive this denomination. This means that every programming language, among other features, needs to have a means of storing data and this is done in memory.

What kind of memory? This is not specified. So in theory it does not need to be RAM.

In general a program needs to be in memory to run. Again it does not need to be RAM.

Practising

The memory used to contain the program or store data from its execution is RAM. It would be difficult to do different, at least in von Neumann architecture. Of course I could use a secondary memory, mass, as a disk, but the performance would suffer a lot.

In fact when there is more data than available RAM it is common that part of them are placed in mass memory, but at the time of use always need to be in RAM, and the operating system must manage this, probably through virtual memory.

Being more specific, I made a text editor using Javascript. When this text editor runs in Javascript, what happens?

About the loading and execution of programming has already been answered. Also how the computer understands the code.

But in Javascript it’s a little different. It gets the source code and needs interpret him or compile it. In fact almost every Javascript engine is Jittado. So there’s a process of transforming the source into binary code. All this is done by a software, so only this process already uses a lot of memory, to store the source, the intermediate steps and the binary end result that will run. Of course all this memory will be released as the use, if all goes well and the Jitter code is well done, as it usually is.

This goes straight to memory or straight to processor?

The processor has only limited registers, even the most powerful are in the tens or hundreds, each one can occupy a word. So it’s virtually impossible to work with just the processor. It doesn’t matter what kind of language. Of course, at the exact moment of execution of an operation the data in question will be in the register, it cannot operate directly in the RAM.

Imagine you have a very complex problem to solve at hand, how do you do? You run every step and every result is written on paper so you can use it later, right? On the computer this is RAM. When you’re making an account, manipulating something, it’s common to make a totally disposable intermediate calculation, this is done in RAM, but then it’s thrown away. Something is so simple that you do it in your head, this is the processor using registers.

So, yeah, any kind of language needs RAM to keep your data.

Because if we have the source code of some program, it is to imagine that this source code is somehow free, it does not depend on the operating system but on the language that was written.

Yes, but I see no relevance in this context. At least this seems to make little sense of what was asked. No code has relevance to the operating system.

Because of this, a source code + programming language would not need, or would not necessarily have some kind of storage, for such a task.

No, as already demonstrated.

That is, either compile or interpret, it is the same. If you compile, somehow you make an interpretation the same happens with interpreters.

Yeah, but I don’t see what that has to do with the context presented in the question. The final sentence doesn’t even make much sense.

And I wouldn’t need RAM either.

I can’t imagine why I wouldn’t need to. I think reading this answer and all links Understand that you do. It needs for the source, for the binary, for the data, and I’m just talking about the direct use of the program, or the environment it needs as well.

Should also be of interest:

  • I usually watch out for strong words like all. Not every programming language is Turing-complete. It is true that there is no complete non-Turing language of broad commercial employment, but there are functional languages like Charity that are not Turing-complete.

  • @Renan All programming language is Turing complete by definition. If a language calls itself, or popularly people call it out of the definition it needs to justify it, it still doesn’t mean it is. Since I don’t know the language and where you’re getting your definition from, I can’t say anything.

1

Every program needs memory to run. Without exception, follow a link with an example execution of a program in Portuguese here. And if you want to understand a little more about how it works, search for stack execution, a link that explains a little here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.