10 Apr

The Joys of Running External Programs

As part of adding Julia, we’ve been looking at making an interactive console, i.e. capturing the output produced by a program, and letting us send commands to it. Making this work has a surprising number of traps.

Firstly, our current approach to running an external process was slightly flawed; the site CSharpTest.Net has sample code that shows how it should be done (which is not the way Microsoft do it in their sample!). Our code suffered from several of the common mistakes they list. The next release will do this better (which allows Julia 0.3.3 to work, for example, which it did not before).

As part of this exploring, we have also worked out how to run Julia and Python in a C# console so that we can send them commands interactively. This did not work “out of the box” in the way we’d expected. We now know why. When run from C#, these programs no longer think they are connected to a TTY (i.e. an interactive) terminal, and so they change their behaviour to act as if a file was passed to them (which means they just seem to hang, with no output being produced).

This is good description of why re-directing input (stdin) and output (stdout) fails for these programs. One solution is to use an intermediate program that really is a TTY terminal. Another trick is to force Python and Julia to run in interactive mode even though they are no longer connected to the “right sort” of input/output. The “-i” (interactive) flag makes them do this.

Hopefully this will all result, one day soon, in (1) faster running Julia code as a result of re-using a single Julia instance for each run, and (2) a truly interactive console in SolverStudio.

2 thoughts on “The Joys of Running External Programs

  1. I am following the development of SolverStudio very closely. I find the application to be an outstanding and incredibly useful addition to Excel. The key feature I use most is Python integration. Once Julia is added, I will be in heaven. Thanks for the great work on this outstanding software solution!

    • Pleased you like SolverStudio and find it useful. The next release will include a (beta) Julia console. All feedback is welcome on this and any other SolverStudio features/glitches/bugs! Andrew

Leave a Reply

Your email address will not be published. Required fields are marked *