To convert the source code into machine code, translators are needed.It translates the entire program and also reports the errors in source program encountered during the translation.
![]() Where he writes how-to guides around Computer fundamental, computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us. Credits This code conversion tool is based on source code from the develop editor, a free open source alternative to Visual Studio.NET. The thought of manually converting 10k lines of code was scary so I decided to give automatic translation a try. That was a fail. What I expected was a command-line tool that I can run on.java files that will produce.cs files. What I got was an eclipse plugin. Java To C Language Converter Install It ProperlyI can barely create a working project in eclipse so I failed to install it properly (even after trying to follow supposedly step-by-step instructions). Then I tried Microsofts JLCA (Java Language Conversion Assistant). Sadly, its been discontinued (apparently Microsoft no longer considers Java to be threatening enough to continue investing in automatic java-to-c conversion). Here are the exact commands I used to convert perst sources: mkdir c:kjksrcnuperst-csharp. C:Program FilesMicrosoft Visual Studio 8JavaLanguageConversionAssistantjconvert c:kjksrcnuperstjavasrc JDK J2EE Out c:kjksrcnuperst-csharp. C:Program FilesMicrosoft Visual Studio 8JavaLanguageConversionAssistantjconvert c:kjksrcnuperstjavasrc15 JDK J2EE Out c:kjksrcnuperst15-csharp ProjectType Library ProjectName Nuperst Verbose. C:Program FilesMicrosoft Visual Studio 8JavaLanguageConversionAssistantjconvert c:kjksrcnuperstjavasrc15 JDK J2EE Out c:kjksrcnuperst15-csharp The results are far from perfect but Im certainly happy I tried it first. Ive had to fix parts that were converted incorrectly, parts that were not converted at all, fix style issues (make the code more idiomatic C) etc. It doesnt change the fact that I probably saved lots of time compared to an alternative i.e. Java and C are remarkably similar but have enough dissimilarities to trip automatic conversion. There are many big and small, obvious and subtle differences. Parts where JLCA had problems: perst uses reflection heavily. JLCA couldnt translate class loading by name Java idioms (that use ClassLoader) to.NET equivalent (which must fish out things from assemblies) Iterator in Java has remove(), IEnumerator in.NET doesnt. JLCA doesnt quite know what to do about it classes implementing IO.Stream interfaces were not fully converted due to differences in interfaces some final values were translated as readonly, instead of const, and initialized at runtime (vs. It is harder than it looks like at first but if an implementation abandoned several years ago can do a decent job, a better implementation should be possible. GWT translates Java to JavaScript so it seems like it should be possible to do even better job converting to a language that is much similar. ![]() While I understand why its done this way (eclipse has built-in Java parser that sharpen uses), its a shame that mechanics of using a tool are prohibitively complex (at least for those who dont know ins-and-outs of eclipse).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |