A CFront-like compiler available?

B

Bunny.Joy

Hi,
I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.

Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?

Thanks.
 
I

Ian Collins

Hi,
I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.
How can a tool that converts C++ to C help a C programmer to learn Java
more effectively?
 
S

santosh

Hi,
I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.

Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?

Thanks.

Why do you want to do this, particularly for learning Java.

PS. I don't think any extant tool does what you want.
 
B

Bunny.Joy

How can a tool that converts C++ to C help a C programmer to learn Java
more effectively?
Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.
 
B

Bunny.Joy

Why do you want to do this, particularly for learning Java.

PS. I don't think any extant tool does what you want.
Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.
 
S

santosh

Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.

Hmm, I think you're off on a wild goose chase. If you want to
understand how C++ and Java programs are compiled and how their
runtime support is implemented, you'll have to understand their
standards, the source code of a conforming implementation and it's
accompanying libraries, not to mention the characteristics of the
target machine architecture.

Simply reading a source translation will get you nowhere, even if you
can find a tool to do that.
 
B

Bunny.Joy

Hmm, I think you're off on a wild goose chase. If you want to
understand how C++ and Java programs are compiled and how their
runtime support is implemented, you'll have to understand their
standards, the source code of a conforming implementation and it's
accompanying libraries, not to mention the characteristics of the
target machine architecture.

Simply reading a source translation will get you nowhere, even if you
can find a tool to do that.
Yes, it is really a great job to understand every aspect of a big
language like C++ or Java, however, what I care the most is its
runtime characteristics instead of their compilers or even the whole
language systems. I use Assembly language to study C and thus have
achieved a very good undestanding of the C runtime mechanism. So, I
wonder if there is also a similar way to analyze C++ or Java. In my
opinion, that is really a short-cut.
 
I

Ian Collins

Yes, it is really a great job to understand every aspect of a big
language like C++ or Java, however, what I care the most is its
runtime characteristics instead of their compilers or even the whole
language systems. I use Assembly language to study C and thus have
achieved a very good undestanding of the C runtime mechanism. So, I
wonder if there is also a similar way to analyze C++ or Java. In my
opinion, that is really a short-cut.

No, it isn't. If you understand an assembler, there is a fairly clear
relationship with unoptimised C.

The same is not true with C and C++.
 
S

santosh

Yes, it is really a great job to understand every aspect of a big
language like C++ or Java, however, what I care the most is its
runtime characteristics instead of their compilers or even the whole
language systems. I use Assembly language to study C and thus have
achieved a very good undestanding of the C runtime mechanism. So, I
wonder if there is also a similar way to analyze C++ or Java. In my
opinion, that is really a short-cut.

It depends on what exactly you mean by runtime system. You can try to
understand what's happening at a machine level for compiled languages
by examining the assembly output of the language's compiler, but this
is far more difficult for interpreted languages like Java. Java in
particular, is compiled to "bytecode", which runs under a complex
virtual machine, which does interpretation and runtime compilation in
combination. The runtime support for Java programs is also
significantly larger and more complex than for C. For C++, features
like RTTI, exception handling and name mangling will also complicate
matters.

C is closer to assembler than C++ and particularly Java. You'll have
to know the innards of the compiler/VM and associated libraries, in
conjunction with the language's specification to really understand
what's happening at the machine level.

All this assuming that you can get a tool to translate arbitrary C++
and Java source into C.
 
B

Bunny.Joy

It depends on what exactly you mean by runtime system. You can try to
understand what's happening at a machine level for compiled languages
by examining the assembly output of the language's compiler, but this
is far more difficult for interpreted languages like Java. Java in
particular, is compiled to "bytecode", which runs under a complex
virtual machine, which does interpretation and runtime compilation in
combination. The runtime support for Java programs is also
significantly larger and more complex than for C. For C++, features
like RTTI, exception handling and name mangling will also complicate
matters.

C is closer to assembler than C++ and particularly Java. You'll have
to know the innards of the compiler/VM and associated libraries, in
conjunction with the language's specification to really understand
what's happening at the machine level.

All this assuming that you can get a tool to translate arbitrary C++
and Java source into C.
What you said is very helpful to me and I am preparing to study more
about C++ compiler and Java VM, that seems to be a real need. Thank
you.
 
K

Keith Thompson

Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.

<OT>
C++ and Java are two very different languages.
</OT>
 
S

santosh

What you said is very helpful to me and I am preparing to study more
about C++ compiler and Java VM, that seems to be a real need. Thank
you.

Unless you're fairly proficient in Java and C++, you'll have a very
difficult time understanding their implementations, even if they
happen to be in C. Ditto, for their runtime behaviour.

I wouldn't go about this way if I were you, but YMMV.
 
G

Greg Comeau

I know that some granddaddy-level C++ compiler can compile C++ code
into a C intermediate. Apart from that, however, I can not find any
modern compiler to do that. And in fact, I think, this factor is very
pragmatical for a C programmer to learn Java more effectively.

(Hmm, coulda sworn I just responded to this in another NG?)

Be careful with pragmatics. Also, be careful what you wish for :)
Any one can give me some information on that ? Tools, compilers or
other methods applicable are all attractive to me. But where to get
them?

Comeau C++ (http://www.comeaucomputing.com ) does, at least as
an internal phase of translation does, so I'm not sure to what
extent that can be helpful.

You mention something about Java above, but it's unclear what
your intention are, so feel free to elaborate, as there may be
better approach to what you're trying to do that we can offer.
 
G

Greg Comeau

Oh, what I wrote is not clear indeed. Well, what I mean is that I hope
to get a tool that can translate or compile Java/C++ code into C code,
just like the old CFront did. I think this would be meaningful and
helpful for me to dig into the deep implementation mechanism of C++ or
Java through reading C code.

Comeau C++ can do what you seek but probably won't help you in this
case as our translation to C is normally an internal phase of
translation.

Also, unlike some of the others who posted here, I can see merit
in donning a hazmat suite and jumping right in, however,
I agree with them this as a first tier approach to understanding,
this is barking up the wrong tree.

Not mentioned in this is to pick up a copy of Lippman's Inside
The C++ Object Model (see http://www.comeaucomputing.com/booklist
for more info on it) which pretty much covers a cfront perspecive
to the model. Very insightful, but again, not necessarily necessary
for understanding C++ or Java, if I'm understanding you correctly.
You should be considering high level concept for that.

You also seem to be seeking some sort of C++ <--> Java relationship,
and it may or may not be there.
 
G

Greg Comeau

Yes, it is really a great job to understand every aspect of a big
language like C++ or Java,

If that is true, and I'll buy it to some extents, one problem with your
approach is that you will be limiting yourself to one perspective,
in the meantime, implementations have fairly good liberty to do as they
choose on many things. So looking at what you're seeking will not be
the complete picture, though certainly part of it.
however, what I care the most is its
runtime characteristics instead of their compilers or even the whole
language systems.

What do you mean by "runtime charactertics"? And which "facts" in
particular are you trying to seek?
I use Assembly language to study C and thus have
achieved a very good undestanding of the C runtime mechanism. So, I
wonder if there is also a similar way to analyze C++ or Java. In my
opinion, that is really a short-cut.

It's one appaoach, but it's painfully low level and can be a distorted
focus. I'm not saying people shouldn't some of this, or that it can't
be handy in some cases to know, but I'm still unclear on the problem
you're trying to solve? IMO, HLLs are for allowing us to more easily
model and express the problems we're trying to solve, and for that,
I'd rather very much first trying to understand that features and their
semantics and uses.
 
G

Greg Comeau

It depends on what exactly you mean by runtime system. You can try to
understand what's happening at a machine level for compiled languages
by examining the assembly output of the language's compiler, but this
is far more difficult for interpreted languages like Java. Java in

I'll even up sanosh one. :) That is to say, it's still even hard
with the compiled languages. Because IMO when you say *a* machine level,
although there can be commonalities, you're really looking at one
machine at a time, and even worse, one version of one compiler for
one machine at a time. That's a lot of work. :) And probably
misleading (at least narrow) often.
 
C

CBFalconer

santosh said:
Why do you want to do this, particularly for learning Java.

PS. I don't think any extant tool does what you want.

I think Comeau does it for C++.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs)
<http://clc-wiki.net> (C-info)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top