Live data from Hacker News

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

mtsystems.ch

41–50 of 55 posts

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

#41
post #38

Earlier quoted context omitted.

Can you elaborate on that? What's the C code, the translated Java code and your expected Java code? Thanks!

http://lmgtfy.com/?q=duff%27s+device&l=1#

I saw that ;-) The translation is:

  do {

    to.set((from = from.shift(1)).get(-1));

  } while(--count > 0);

which looks correct to me. Hence my question what orodley thinks is wrong.

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

#42

Earlier quoted context omitted.

This sounds like a great spin off - bug finding in C code. Have you put much thought into pursuing this?

Didn't think too much about it since there are many C specific analyzers and tools that do the same. Well, they do it way better. E.g. Valgrind.

I would guess the value would be if you find bugs that other tools don't. If you just find the same bugs as Valgrind then I agree that there would not be too much value, but if you find unique bugs then it would be useful.

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

#44

Main author here. Let me know if you have any questions. I’d be happy to answer.

I tried so hard to break main arguments (char argv), on my last try I sent char argv to a function and It wrapped main, and inserted program name to beginning and called the wrapped main with new arguments. I give up.

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

#45
post #34

Earlier quoted context omitted.

No, why would I want to do that unless I have a specific need for that? At least if you're using a Unix-like system, then understanding POSIX is essential for knowing how things work starting on an intermediate level.

And why would I want to understand how things work down in the OS? Anyway, C is a horrible language. Between Fortran and Ada it's unclear to me why C should be chosen for anything, inertia and herdthink aside.

Have you used Fortran or Ada?

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

#47
post #38

Earlier quoted context omitted.

http://lmgtfy.com/?q=duff%27s+device&l=1#

I saw that ;-) The translation is: do { to.set((from = from.shift(1)).get(-1)); } while(--count > 0); which looks correct to me. Hence my question what orodley thinks is wrong.

I think you might be looking at the wrong thing on the Wikipedia page. The core feature of Duff's Device is interleaved switch and do statements:

  n = (count + 7) / 8;
  switch (count % 8) {
  case 0: do { *to = *from++;
  case 7:      *to = *from++;
  case 6:      *to = *from++;
  case 5:      *to = *from++;
  case 4:      *to = *from++;
  case 3:      *to = *from++;
  case 2:      *to = *from++;
  case 1:      *to = *from++;
          } while (--n > 0);
  }
(extraneous register statements removed for conciseness)

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

#48
post #34

Earlier quoted context omitted.

And why would I want to understand how things work down in the OS? Anyway, C is a horrible language. Between Fortran and Ada it's unclear to me why C should be chosen for anything, inertia and herdthink aside.

Have you used Fortran or Ada?

Have used Fortran. It's pretty nice, actually. I mean, it does have unstructured programming, but its structured alternatives feel pretty natural. Fortran code, like C code, feels a bit fragile but unlike C, Fortran doesn't seem to be actively malevolent. I only know Ada by its (excellent) reputation.

EDIT: Only true if you use the implicit-none flag when compiling Fortran.

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

#49

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 :)

On the C++ to C translators: The first actual C++ compiler was actually a trans-compiler to C (actually the language was still called cFront back then, but basically it's the first version of C++[0]).

So in that case, the C++ to C compiler was there before the first real C++ compiler which appeared some time later.

[0] http://www.cplusplus.com/info/history/

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

#50
NestedVM was able to do this over a decade ago.

http://git.megacz.com/?p=nestedvm.git;a=summary

And is actually open source, not "free for open source".

Kudos to the developers though, I'm not trying to bash your skills or diminish the quality of your work... I'm sure many enterprises can/will benefit from this. Just wanted to let the free/open source community know that you don't have chomp on the "free for open source" carrot.

Post reply on HN