I have 2 programs that must communicate with each other. They should share state (variables, files - i don't know how to achieve this). One program should read it and react on changes - the other should write to this global state.
Using files for this purpose is not even slow, it is difficult to read a file that someone writes at the same time.
What is the best way to achieve this shared state between programs? (looking for a cross-platform solution)
One idea to achieve this is to export your data (variables, state, etc) in a json file and store it in a temporary file. Once you have done this, with your second program you can read that json file that has been generated by the first program and parse it so you can assign those variables to your second program.
If you are working with those programs in a network, then I would suggest to use REST.
XML and Json are formats to exchange information across platforms. You will have to make sure you have a Json parser in both programs.
I hope that helps.