How to make a variable public (any language)

Hi everyone

I have come up with such a question, thought it over for a long time, it seems to have been formulated. How to issue a variable in any language to any other language, i.e. so that any other application can process it?

Roughly, I imagine the following:

  1. Get the address of a variable
  2. Get the length in bytes
  3. Pass them to the process
  4. Waiting for changes
  5. Continue work

The tags indicate the languages ​​that I will be able to check myself in the near future, but otherwise – any. Axis – Windows (if you’re interested in tench, please create a separate topic, because I can’t check it)

The condition is not to use pipes, sockets, etc. (except for passing the address and length). Why – well, for example, because transferring a 200-meter array over a local socket can take longer than processing it in assembler. Here, most likely, it will be adequate to write two long ints to a file, because this is the most simple and stable for any language – write and get from a file. Accordingly, take into account that the application may not have access to this memory area and provide it.

Preparation for delfey (don’t know if the variable will be available):

var myVar: String;
    varLink: Cardinal;
    varLength: Cardinal;
...
myVar := '0lol';
// myVar[1] - 
varLink := Cardinal(Addr(myVar));
varLength := Cardinal(Length(myVar));
makeCommonVar(varLink, varLength); // , 
while myVar[1] = '0' do //    , 
  begin
  Sleep(50);
  Application.ProcessMessages;
  end;
ShowMessage(myVar); //  

Possibly chaotic… Something like “let’s write bridges between all languages”. You can recall the well-known to most ArtMoney – the principle of work is somewhere nearby.

Yes, php is there in labels alone – I don’t even know if (and how) it is possible to get the address (int) of a variable.

If the code doesn’t threaten to be huge, examples are welcome. Why is this all? Well, for example, different languages ​​have different tasks, and somewhere processing a variable can be faster / more convenient / easier, after all.


Answer 1, authority 100%

There are tons of options, why reinvent the wheel?

  1. mapped files to memory (mappedFiles)
  2. dll
  3. WM_DATA (that’s what the message is called)
  4. Data Base ! (:)
  5. memcache(d)

And most importantly, WHAT IS IT FOR?


Answer 2, authority 38%

In short, from all this stream of consciousness, I understand that you need to figure out how to transfer data from one process to another. Moreover, in both processes, programs written in different languages ​​are executed. Let me remind you that each process runs in its own virtual memory address space, and it cannot just get access to the space of another process. Several solutions have been devised for data exchange. All of them have long been known and implemented on most modern operating systems. Pipes, sockets, signals, message queues. For your purposes, I think shared memory will do. This is when a certain area of ​​memory becomes available to both processes. And it doesn’t matter what language the programs are written in, since all these IPCs are implemented at the OS kernel level. The main thing is that this language supports this type of IPC, or at least makes it possible to call the system’s API functions. And one more thing: data is not transferred from language to language, from program to program.


Answer 3, authority 12%

I would advise you to dig towards COM objects, or DLL


Answer 4, authority 12%

Yes, it looks like just a DLL, or writing a variable to a file, although this is not kosher.