UniSharping: converting C # code to Java and Python
Since the 70s, has been developing. Simplified English , whose goal is to define a subset of a language that is understandable to a wide range of non-native speakers. It is recommended, for example, for technical documentation. Automatic translators on such a subset will work deliberately more correctly, ideally generating text that does not require manual proofreading.
If you apply this approach to C # for the task of automatically converting code to other programming languages, you can select a subset of language constructs, system libraries and technologies that can potentially be translated into a wide range of other languages. And the conversion is not a one-time (migration), but a permanent one for expanding the integration capabilities of the project in C # - so that at any time it's possible to get the working code in another language without the need for any editing.
Let me introduce: UniSharping
The restriction of C # .NET to solve this problem, we called
(Universal Sharp), and the conversion process and its tool - UniSharping . Executable modules, settings and documentation are laid out on GitHub , the system is free for non-commercial use (Non-Commercial Freeware).
list supported classes C # and their members with analogues in Java and Python in the current version on the site, there is also online demo .
As for the technologies, now the list is limited to the console application and unit-tests (UnitTest). Well, individual Lib projects, as a special case, are translated into the appropriate constructions of the desired language.
For a successful translation, the original C # (solution) project must have some startup part that checks the functionality of the original C #. Well, if it's an extensive system of auto-tests (standard UnitTest in different implementations or self-written ones), but at least there must be at least a console application that runs correctly when launched without any user intervention. The need for this is obvious - after generation into the final language, you can immediately check the performance. Ideally, all tests should work similarly to C #.
History of the project
The idea of such a converter has existed for a long time. My main project is SDK Pullenti natural language processing - the ideal candidate for conversion: a large amount of complex and constantly improved code. To integrate with Java, you had to wrap in web services, tcp servers, etc.
In the summer of last year, there was time and energy to create the first option. He translated the Pullenti project into Java, as well as himself in Java.
The next six months, the converter developed on several internal projects that were in the company, mainly through the expansion of system classes.
In the spring of 201? there was an idea to support and Python, which was implemented by the summer. But the inclusion of a second language was not provided in the initial version and it turned out clumsily. It was necessary in the summer to completely rewrite the engine for the potential of several final languages. Also, the settings for the system classes from the hardcode were put into external text files. I hope this set will expand not without your help.
The further plans while are those:
pull Python to the Java level. Now Python is supported at the level of Pullenti, however Java in comparison with it has gone far ahead on other projects.
support PHP at least at the level of the Pullenti project.
support C ++. Yes, I realize that this is very difficult, because it is unclear when releasing the memory - which pointer is a link, and for what it is necessary to do delete. But there are ideas
Whom it can come in handy
Basically, those who develop a potentially cross-platform SDK on C #. Thanks to the UniSharping converter, their SDK can become also "cross-program", which will expand the circle of potential users.
Recently, the STRs have become stronger in Russia, which became mandatory in most state structures and some large companies. Explain that. NET Core is also not very easy to get, because "Microsoft". Let some company develop its information system in C #. To implement the product in the "SPO-company", you can select the logical part of the project (back-end), it is automatically converted into releases as needed, and the visual part (front-end) is done on the SPO. That is, continue to develop in C #, and in Java only the front-end.
I do not exclude that, in principle, it is possible to convert and web-projects (with restrictions, of course), but I do not have the necessary skills and information for this. If anyone sees this possibility, then it is quite possible to implement it in UniSharping.
I note, for a real complex project C # support for Java or another language will require some effort to modify the code, allocating the project in the projected part, "overlapping" it with unit tests. Also, the configuration of yet unsupported system classes and methods and the correction of errors of UniSharping itself (with my help) is another work. But the process is convergent, at the end of which the project expects a bonus of "cross-program".
It may be interesting