jcfaria
2022-Jun-04 03:43 UTC
[Rd] Writing Extensions for R under Windows: is it better for GUIs to communicate with R via Rgui.exe, Rterm.exe or R.dll?
Writing Extensions for R under Windows: is it better for GUIs to communicate with R via Rgui.exe, Rterm.exe or R.dll? In the construction of extensions (GUIs) for R, in the establishment of communication, according to the options below: 1- Rgui.exe (via Windows API) vs. R.dll (embedded R) 2- Rterm.exe (via IPC) vs. R.dll (embedded R) What are the advantages and disadvantages in each case? I would like to take advantage of the email to thank Tomas Kalibera for his efforts in solving the problems of R 4.2.0 communication and the Tinn-R project. Once fixed the issues in R that surfaced due to using GraphApp (cross-platform GUI Library in C for Windows) it was possible to fix the communication issues in Tinn-R with Rterm.exe and Rgui.exe. Version 9.01.XX.XX with the corrections will be released soon. At the moment we are in extensive testing phase. Thanks in advance, ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria UESC/DCET/Brasil joseclaudio.faria at gmail.com Telefones: 55(73)3680.5545 - UESC 55(73)99966.9100 - VIVO ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ If you have software to deal with statistics, you have arms, if you have good software, you have arms and legs, if you have software like R, you have arms, legs and wings... the height of your flight depends only on you. [[alternative HTML version deleted]]
Ivan Krylov
2022-Jun-08 14:57 UTC
[Rd] Writing Extensions for R under Windows: is it better for GUIs to communicate with R via Rgui.exe, Rterm.exe or R.dll?
On Sat, 04 Jun 2022 03:43:39 +0000 jcfaria <joseclaudio.faria at gmail.com> wrote:> Writing Extensions for R under Windows: is it better for GUIs to > communicate with R via Rgui.exe, Rterm.exe or R.dll?Well, WRE section 8 is all about linking the GUI to R as a DLL. It does mention the alternative approaches like Rserve or DCOM, but such interfaces are limited to some extents.> In the construction of extensions (GUIs) for R, in the establishment > of communication, according to the options below: > > 1- Rgui.exe (via Windows API) vs. R.dll (embedded R)Setting aside the fact that Windows API is not cross platform (which may be not the point if you're writing a Windows-only GUI), the messages that the application accepts and interprets are not a part of a documented interface, so while they tend to be stable (because Windows is mostly stable in handing the same kinds of messages to the applications running there), they may be broken (like in R 4.2.0). Linking to R.dll has a higher initial cost of setting up (you have to write those callbacks, you have to set up R_HOME...), but the interface won't be broken without a good reason and a migration plan.> 2- Rterm.exe (via IPC) vs. R.dll (embedded R)The console interface might be better understood and more stable than passing messages to windows. If you're writing some kind of universal interface suitable for different applications, all of which run a Run-Eval-Print Loop in the command line, this may be a better approach to take instead of linking to them individually. Although not without problems [*], this is probably more stable than talking to Rgui.exe by means of SendInput().> What are the advantages and disadvantages in each case?The advantages of linking to R.dll include being able to set up all kinds of callbacks (EditFile, Busy, dataentry/dataviewer/selectlist) to make their behaviour fit the theme of your application. The disadvantages include a higher initial cost of setting it up and maybe having to recompile it for different versions of R. -- Best regards, Ivan [*] Check out ConEmu <https://conemu.github.io/> source code for workarounds they probably amassed for all kinds of applications that would otherwise prefer to be running in the standard console window.