Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Subject: C to JVM compiler (AMPC)

Reply
Thread Tools

Subject: C to JVM compiler (AMPC)

 
 
Mohd Hanafiah Abdullah
Guest
Posts: n/a
 
      05-14-2005
Axiomatic Solutions Sdn Bhd announces the availability of AMPC version 1.2.
You can purchase AMPC online now at:
http://www.axiomsol.com/hedesu/shopping/index.php

Major Changes
-------------
Version 1.2 supports the MS Windows XP platform, beside Linux x86 and
Mac OSX. It also supports the DOUBLE floating point type. Please see the
README file for details on DOUBLE floating point type.

AMPC (Axiomatic Multi-Platform C) is a C compiler/IDE targeting the JVM
(generates Java Bytecode). The resulting .class executables will be
able to run on any Java Virtual Machine (tm). AMPC enables programmers
to write/port applications using C targeting the JVM, thus, opening up a
whole new market dimension vis-a-vis JVM-enabled devices such as desktop
systems, PDAs, cell-phones, game consoles, set-top boxes, automotive systems
(GPS based displays, OnStar, Satellite radio systems, etc), and so forth.
AMPC can also be used to turn legacy applications written in C into JVM
applications, with a single source base to manage. Use existing C skill sets
instead of learning new Java skill sets.

AMPC includes a Graphical User Interface (GUI) as part of the Integrated
Development Environment (IDE) for fast and organized software
development.

AMPC is based upon the American National Standards Institute C (ANSI C),
X3.159-1989. There are however a few differences between AMPC and a
fully compliant ANSI C compiler. The differences of AMPC with a fully
compliant ANSI C compiler are described in AMPC's product description.

JNI (JVM Native Interface) support is available for the purpose of
calling native C or C++ functions from AMPC.

AMPC can also generate assembly code for the Jasmin assembler using the
asm() directive.

It also can call most Java classes using the functions INT_java(),
FLOAT_java(), DOUBLE_java(), and so forth.

Hardware Requirements:
- Any x86 compatible computer running MS Windows XP
- Any Macintosh computer running Mac OSX
- Any x86 compatible computer running Linux
- 128MB RAM minimum

Software Requirements:
- Java SDK 1.4.2 or newer (JDK 1.5 recommended).

More info on AMPC can be found at http://www.axiomsol.com

Thank you and best regards.

--
Axiomatic Solutions Sdn Bhd
http://www.axiomsol.com

--
http://www.axiomsol.com
http://www.cs.indiana.edu/hyplan/napi.html
 
Reply With Quote
 
 
 
 
Ioannis Vranos
Guest
Posts: n/a
 
      05-14-2005
Mohd Hanafiah Abdullah wrote:

> AMPC (Axiomatic Multi-Platform C) is a C compiler/IDE targeting the JVM
> (generates Java Bytecode).


C is a procedural language and as far as I know JVM is an OO framework. How can C code
create class definitions, inheritance, use objects etc? May you provide a hello world
example in C by using the JVM facilities?



--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
 
 
 
Rapscallion
Guest
Posts: n/a
 
      05-14-2005
Ioannis Vranos wrote:
> C is a procedural language and as far as I know JVM is an OO

framework. How can C code
> create class definitions, inheritance, use objects etc? May you

provide a hello world
> example in C by using the JVM facilities?


This is easy. Use only static functions in Java. The hard thing (which
cannot be reached directly) is to map the low level functions (memmove,
....) to Java.

R.C.

 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      05-14-2005
Rapscallion wrote:

> This is easy. Use only static functions in Java. The hard thing (which
> cannot be reached directly) is to map the low level functions (memmove,
> ...) to Java.


I have no JVM experience, but I have .NET experience, which is a CLI VM platform.

In .NET, in most (perhaps all) cases, static methods are more run-time expensive than
usual methods which do the same operations, and are used either for-do-something-only-once
(having the same cost as the initial call of the equivalent method of an object of the
class) since it doesn't make sense to create an object of the class for doing something
only once - an example is a file operation -, or thread safety (the same resource being
shared by more than one threads, and thus additional checks and locks) or other reasons.

Also many static methods return objects by themselves.

I suppose these are also the case for the JVM. So how does C code can handle returned
objects of a static/non-static method?


memmove etc are more applicable to native code and not VM code.



--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
Brandon J. Van Every
Guest
Posts: n/a
 
      05-14-2005
Ioannis Vranos wrote:

> Mohd Hanafiah Abdullah wrote:
>
>> AMPC (Axiomatic Multi-Platform C) is a C compiler/IDE targeting the JVM
>> (generates Java Bytecode).

>
>
> C is a procedural language and as far as I know JVM is an OO
> framework. How can C code create class definitions, inheritance, use
> objects etc? May you provide a hello world example in C by using the
> JVM facilities?
>

Your question makes no sense to me. The product is a C --> Java
compiler, not a Java --> C compiler. The point of the product is to use
C skillsets and not learn Java. C programmers don't do class
definitions, inheritance, etc. If they wanted to do all of that in
Java, they'd do Java. Presumably their "hello world" is going to be
written in C, although I do think it's an interesting question if the C
standard libraries are available and output JVM bytecode.

--
Cheers, www.indiegamedesign.com
Brandon Van Every Seattle, WA

"We live in a world of very bright people building
crappy software with total **** for tools and process."
- Ed McKenzie
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      05-14-2005
Brandon J. Van Every wrote:

> Your question makes no sense to me. The product is a C --> Java
> compiler, not a Java --> C compiler. The point of the product is to use
> C skillsets and not learn Java. C programmers don't do class
> definitions, inheritance, etc. If they wanted to do all of that in
> Java, they'd do Java. Presumably their "hello world" is going to be
> written in C, although I do think it's an interesting question if the C
> standard libraries are available and output JVM bytecode.



From my .NET experience, I do not think it is easy (and in some cases even possible) to
provide managed versions of C standard library.

Again from this experience of mine, the main difference between a native machine and a VM
is that the assembly language of a VM is more high level than the assembly of a native
machine. Having C++ in mind here, for example the assembly language of CLI standard (.NET
is a CLI compliant VM) has also the concepts of class, enumeration, etc which have some
(perhaps minor but existent) differences compared with C++ native ones. That's why in C++
case (and perhaps in other platform neutral languages), CLI features are provided
*separately* from the native features (currently in "managed extensions" and in the
upcoming C++/CLI).

Regarding C things should be even more difficult since it lacks the built-in concept of
OO, I can't understand how C programs can interact with the JVM APIs. Unless you can't do
anything else under JVM apart from ISO C code, which doesn't make much sense and which is
not possible under its entirety (GC is moving objects around and thus you can't rely on
pointer arithmetic, or compare two pointers to see if they point to the same object
(memory area), memmove etc. You could pin them (I do not know if JVM permits object
pinning), but this implies additional run-time cost, forgetting pinned objects which will
not be garbage collected possibly resulting in memory leaks, etc).



--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      05-14-2005
Ioannis Vranos wrote:

> From my .NET experience, I do not think it is easy (and in some cases
> even possible) to provide managed versions of C standard library.
>
> Again from this experience of mine, the main difference between a native
> machine and a VM is that the assembly language of a VM is more high
> level than the assembly of a native machine. Having C++ in mind here,
> for example the assembly language of CLI standard (.NET is a CLI
> compliant VM) has also the concepts of class, enumeration, etc which
> have some (perhaps minor but existent) differences compared with C++
> native ones. That's why in C++ case (and perhaps in other platform
> neutral languages), CLI features are provided *separately* from the
> native features (currently in "managed extensions" and in the upcoming
> C++/CLI).
>
> Regarding C things should be even more difficult since it lacks the
> built-in concept of OO, I can't understand how C programs can interact
> with the JVM APIs. Unless you can't do anything else under JVM apart
> from ISO C code, which doesn't make much sense and which is not possible
> under its entirety (GC is moving objects around and thus you can't rely
> on pointer arithmetic, or compare two pointers to see if they point to
> the same object (memory area), memmove etc. You could pin them (I do not
> know if JVM permits object pinning), but this implies additional
> run-time cost, forgetting pinned objects which will not be garbage
> collected possibly resulting in memory leaks, etc).



I checked their web site (I guess I should have done this since the beginning), and saw
that they provide their own APIs (probably have encapsulated JVMs APIs to functions). In
this way I guess it is possible to do JVM programming (this must have been a real pain for
them though).



--
Ioannis Vranos

http://www23.brinkster.com/noicys
 
Reply With Quote
 
Christian Bau
Guest
Posts: n/a
 
      05-14-2005
In article <1116096955.568188@athnrd02>,
Ioannis Vranos <(E-Mail Removed)> wrote:

> Regarding C things should be even more difficult since it lacks the built-in
> concept of
> OO, I can't understand how C programs can interact with the JVM APIs. Unless
> you can't do
> anything else under JVM apart from ISO C code, which doesn't make much sense
> and which is
> not possible under its entirety (GC is moving objects around and thus you
> can't rely on
> pointer arithmetic, or compare two pointers to see if they point to the same
> object
> (memory area), memmove etc. You could pin them (I do not know if JVM permits
> object
> pinning), but this implies additional run-time cost, forgetting pinned
> objects which will
> not be garbage collected possibly resulting in memory leaks, etc).


You are confusing "pointers" and "memory addresses". They are the same
in many C implementations (depending on what you mean exactly with
"memory address"), but in a JVM based C compiler they would most
definitely not be the same. Most likely a C pointer would be implemented
as a pair (object, offset); possibly (array of byte, index into array).
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      05-14-2005
"Brandon J. Van Every" <(E-Mail Removed)> writes:
> Ioannis Vranos wrote:
>> Mohd Hanafiah Abdullah wrote:
>>> AMPC (Axiomatic Multi-Platform C) is a C compiler/IDE targeting the JVM
>>> (generates Java Bytecode).

>>
>> C is a procedural language and as far as I know JVM is an OO
>> framework. How can C code create class definitions, inheritance, use
>> objects etc? May you provide a hello world example in C by using the
>> JVM facilities?
>>

> Your question makes no sense to me. The product is a C --> Java
> compiler, not a Java --> C compiler. The point of the product is to
> use C skillsets and not learn Java. C programmers don't do class
> definitions, inheritance, etc. If they wanted to do all of that in
> Java, they'd do Java. Presumably their "hello world" is going to be
> written in C, although I do think it's an interesting question if the
> C standard libraries are available and output JVM bytecode.


According to the initial description, it's not a C --> Java compiler,
it's a C --> Java Bytecode compiler. Java is a high-level language; a
C --> Java compiler would generate Java source code from C source
code.

There's an unfortunate tendency to fail to distinguish between Java
(the high-level language) and Java bytecode (a low-level intermediate
or interpreted form). They were designed together, but they aren't
necessarily logically linked -- and many of the concepts in Java
bytecode predate Java the language. It's entirely possible to compile
languages other than Java to Java bytecode (for example, there's at
least one Ada compiler that generates Java bytecode). It's also
entirely possible to compile Java to machine language.

C presents some interesting challenges, because its freewheeling use
of pointers is difficult to express in Java bytecode. I suspect that
a lot of constructs that invoke undefined behavior but happen to work
perfectly well with a traditional C compiler will actually fail with a
C --> JVM compiler. That's probably a good thing; it provides a way
to weed out non-portable constructs in C code that's intended to be
portable. Perhaps the C --> JVM compiler can serve the purpose of the
DS9000 (a mythical machine with a C implementation that behaves as
perversely as possible without actually violating the standard).

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      05-15-2005

"Ioannis Vranos" <(E-Mail Removed)> wrote
> C is a procedural language and as far as I know JVM is an OO framework.
> How can C code create class definitions, inheritance, use objects etc? May
> you > provide a hello world example in C by using the JVM facilities?
>

The program takes as input the text

#include <stdio.h>

int main(void)
{
printf("Hello world\n);
return 0;
}

The C to JVM compiler then creates a class called something (probably based
on the name of the C source file)

class hello_c
{
static void main()
{
system.out.println("Hello world");
}
}

It has the intelligence to know that the call to printf() can be relaced by
a call to System.out.println() if you remove the trailing newline.

This file then gets fed to a Java complier, which produces a Java .class
file.

In practise it wouldn't bother creating an intermediate human-readable Java
file and the Java compiler would be integrated into the C to JVM compiler.
But that's just a detail. Also it would have to generate lots of fancy Java
code to handle more complicated printf() calls.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subject: C to JVM compiler (AMPC) Mohd Hanafiah Abdullah C++ 25 05-17-2005 07:47 AM
MS JVM and Sun JVM problem Young-Jin Lee Java 3 01-21-2004 04:25 AM
Different behavior for newStringUTF() for Sun JVM and IBM Jvm Lasse Java 1 01-05-2004 07:49 PM
Re: Handling both MS JVM and Sun JVM Kevin Hooke Java 2 09-02-2003 05:31 AM
java compiler in JVM Wats Java 7 07-17-2003 02:23 AM



Advertisments