Live data from Hacker News

C to Java Translation. Automatic, Complete, Correct. Free for Open-Source.

mtsystems.ch

11–20 of 55 posts

Re: C to Java Translation. Automatic, Complete, Correct. Free for Open-Source.

#11
post #8

It says the translation is correct, is there any proof of that ?

Only in the form of translating and running dozens of C applications (programs and libraries) and running their testsuites. E.g. libcurl comes with a great extensive testsuite (a perl script running against the binary).

Translated applications still need to be thoroughly tested and usually some bugs are still found.

So we didn't formalize and verify our translation. Interestingly enough, we run into bugs in javac and ecj (Eclipse Java Compiler) surprisingly often. So verifying our translation would still lead to translations with bugs ;-)

Another fun fact: Since our translation knows the limits of allocated memory (and many other things), we found many illegal memory accesses in C programs that were unknown before (libgmp, micro httpd, vim, ...) since they didn't (or only very seldomly) lead to segfaults.

Re: C to Java Translation. Automatic, Complete, Correct. Free for Open-Source.

#14
post #9

Interesting how gotos are translated to switches 90% of C should be pretty easy to translate, but of course, the devil (and a lot of functionality in existing libraries) is in the details. There would be probably money in translating COBOL to Java, but maybe there are solutions already?

The main problem being undefined behaviour that is actually undefined and varies from compiler to compiler!

Yeah, you might need a config switch to configure what would you want to do with the most common undefined behaviours (or "just change" your C code)

(Because "just change" usually ends up creating other problems. Been there, done that, "code is wrong but works" and when you try to fix stuff breaks)

Re: C to Java Translation. Automatic, Complete, Correct. Free for Open-Source.

#15

I wonder what the performance impact is. Why do young students no longer learn C? Don't you want to be closer to the underlying OS?

>Why do young students no longer learn C?

Who said they don't? This project is about porting existing stuff, for interoperability, etc. Not as a way to "avoid learning C".

>Don't you want to be closer to the underlying OS?

No, why would I want to do that unless I have a specific need for that?

Re: C to Java Translation. Automatic, Complete, Correct. Free for Open-Source.

#16

Earlier quoted context omitted.

I've seen many research papers on Java -> C translation during my PhD. Some of them came with a prototype tool. But as with previous work on C -> Java translation, none of the tools actually really worked completely. I actually wrote a Java -> Eiffel translator: http://se.inf.ethz.ch/research/j2eif Based on that experience I can say it would be quite a big effort to write a Java -> C translator. But not impossible.

Thanks for the post. What was the big sticking point with the Java -> C translators?

It's easy to do a minimal prototype when doing research. But writing real translators means to get all the details right. In research we usually don't have the time for that.

Translating Java - in my experience - is very hard because of the extensive runtime system (reflection, base classes, synchronization, ...). E.g. if your application does System.out.println("Hello"); you already need the System and PrintWriter classes. They in return depend (among many other things) AWT which needs the security classes. And so on. A HelloWorld pulls in 1208 classes of the base library. They in return depend on java.dll which you have to re-implement from scratch. Or you rewrite all base library classes which is even harder.

I hope this gives you a basic idea of the problem.

Re: C to Java Translation. Automatic, Complete, Correct. Free for Open-Source.

#18

C++ to Java would be more interesting.

True. But also adds a lot of complexity on top of an already very complex translation. But it's certainly something we'll look at in the future (together with supporting Cobol and Fortran).

But I heard there are C++ to C translators. I don't know how good they are and how the resulting code looks like. But if they're decent, you could do C++ -> C -> Java :)

Post reply on HN