Shall I move from C to Java?

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi everyone,

I am planning to learn Java.

Can I access HW registers in Java? Or can I call C function from Java
program?

Thanks.


Re: Shall I move from C to Java?

Quoted text here. Click to load it

Even though I don't know much about Java, I know these tidbits:  

No, you cannot directly access hardware from Java.  I would be surprised
to find a serious Java for embedded use that did not include library
functions to do so, however.

Java itself doesn't provide a means to call C functions, but most Java run
time environments provide a means to call external code.  Of course, if
you're calling external code then you have to maintain code bases in C
_and_ Java...

--
Tim Wescott
Control systems and communications consulting
We've slightly trimmed the long signature. Click to see the full one.
Re: Shall I move from C to Java?

Quoted text here. Click to load it






If I design a HW platform, how can I run Java in this bare machine.


Re: Shall I move from C to Java?
[...]
Quoted text here. Click to load it

Your first step should be to find a newsgroup with "java" in its name.

--
Keith Thompson (The_Other_Keith) snipped-for-privacy@mib.org  <http://www.ghoti.net/~kst
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst
We've slightly trimmed the long signature. Click to see the full one.
Re: Shall I move from C to Java?
Quoted text here. Click to load it
quoted text -
As per my basic understanding, for your hardware platform you need to
Develop or Port Java Run Time Environment <JVM , regret i am not java
guru and This is not Java-news group, regret if you think replying to
OT>

-Raxit
Quoted text here. Click to load it



Re: Shall I move from C to Java?

Quoted text here. Click to load it

You need a Java run-time environment to run Java, at which point the
machine would no longer (by my definition) be "bare".

--
Tim Wescott
Control systems and communications consulting
We've slightly trimmed the long signature. Click to see the full one.
Re: Shall I move from C to Java?
Quoted text here. Click to load it

A typical embedded system will not have the CPU
power or memory to interpret the bytecode at
runtime, so that leaves two options:

1.  Use a compiler that generates native machine
    code.  See http://gcc.gnu.org/java /

2.  Use a uC that includes hardware support for
    Java bytecodes.  There are several inexpensive
    (less than $10) microcontrollers based on the
    ARM926EJ-S core, including Atmel's AT91SAM9260
    and NXP's LPC3180.

My opinion is that Java is a poor language
choice for most embedded system projects.  But
you can come to you own conclusion about that.

[comp.lang.c removed from newsgroups]


Re: Shall I move from C to Java?
[X-post lacked F'up2, reduced to one group]


Quoted text here. Click to load it

I'll be blunt.  If you must ask, you can't.

Re: Shall I move from C to Java?
Quoted text here. Click to load it
[Please don't quote signature blocks.  I've correct this here.]

This is, of course, getting way off-topic for comp.lang.c.  I'm sure
there is an "embedded Java" newsgroup out there, and Google returns a
sick amount of hits for that phrase.

However, it may be instructive to consider that implementing embedded
systems does not have to be all bare-metal bit-banging.  There is a
relatively long tradition of interpreted byte-code slinging in the
embedded world.

It really depends on your application and deployment.
--

Direct replies will be blacklisted.  Replace "spamtrap" with my name to
We've slightly trimmed the long signature. Click to see the full one.
Re: Shall I move from C to Java?

Quoted text here. Click to load it

    So you can compile programs once in one platform, and run them
nowhere?

Quoted text here. Click to load it

    I bet you can't.

Quoted text here. Click to load it

    Yes - using JNI. The catch is that the overhead introduce by this
is such that in most cases the resulting code is almost as slow as an all
Java code.



Re: Shall I move from C to Java?

Quoted text here. Click to load it

Don't be (a) silly (b) atopical.
 
Quoted text here. Click to load it

You can't in C, either.

Quoted text here. Click to load it

That is, of course, going to depend on how much work the C code does;
"most cases" is sheer handwaving.

--
Chris "(render unto \X that which is X's)(C | Java)" Dollin

Hewlett-Packard Limited registered office:                Cain Road, Bracknell,
We've slightly trimmed the long signature. Click to see the full one.
Re: Shall I move from C to Java?
[X-post lacked a F'up2; reduced to one group]


Quoted text here. Click to load it

Why, given you clearly don't know if it's going to do you any good?

Quoted text here. Click to load it

If you must ask, that strongly implies it's a bad idea for you to learn
Java at this point.  You have to analyze what it means to use Java
instead of C first.

Re: Shall I move from C to Java?

Quoted text here. Click to load it

Is there any C syntax extension that support multi-thread like Java
syntax?
or how can I use  C Macro to hide the OS routine call in C program?

I don't like the style:
fun(...)
{
p();
.
.
.
v();
}

I want to use
syn fun(...)
{
.
.
.
}


another question is how to disable "goto", can I write #define goto
error("no goto")


Re: Shall I move from C to Java?
Quoted text here. Click to load it



No.


What makes you think you need to do that, or that OS routine calls would
even exist in an embedded systems?

Re: Shall I move from C to Java?

Quoted text here. Click to load it

So, you're saying you want to redefine C such that experienced C
programmers won't be able to read your code?

Just who are you planning on hiring to work on this?

Quoted text here. Click to load it

Well, why not just refrain from using "goto"?  I've been coding in C for
nearly 20 years and have yet to use it myself (yes, I know it's good for
exception handling).  Were I to see one in a code review I'd be
scrutinizing it closely, and probably trying to suggest realistic
alternatives.

If you're trying to control developers by putting it in some universal
header file they'll get around you one way or another; if you're trying to
avoid using it yourself -- just avoid it.

--
Tim Wescott
Control systems and communications consulting
We've slightly trimmed the long signature. Click to see the full one.
Re: Shall I move from C to Java?

Quoted text here. Click to load it

how do you think

p();
if(xxx=yyy)
goto L1;
else
{
do_something();
v();
}

if the language support multi-thread, the debug time will be less.

a save language should not let user see the OS.


Quoted text here. Click to load it


Re: Shall I move from C to Java?

Quoted text here. Click to load it

If you want a "safe" language that was designed to operate in a
multithreaded environment and do systems/embedded programming, then there
are approximately two answers, that I know of: Ada and Modula-3.  There
are certainly groups of people with extended versions of Java and C# doing
approximately that too, though.  Eiffel might fit the bill, and
generally compiles through C, which might help.

Most practitioners just use C or assembly, and leave the safety and
threading to higher-level tools (such as static checkers or code review
processes) and operating systems.

If you want state of the art type safety, you might want to investigate
erlang, ocaml, sml and hascall, but I don't know that anyone is using them
for embedded work, unless you count telephone exchanges (quite a few of
which run erlang) as embedded systems, which they probably are...

--
Andrew


Re: Shall I move from C to Java?

Quoted text here. Click to load it

Is there any Macro can hide the OS routine?

I believe that C syntax extension is a cheaper solution than a new
language.

Actually in Embedded world, C has a lot syntax extension such as
"interrupt fun()"...

So can we have "exclusive fun()" or "exclusive "?




Quoted text here. Click to load it


Re: Shall I move from C to Java?
says...
Quoted text here. Click to load it

What OS routine are you referring to?

Quoted text here. Click to load it

Are you planning on writing a compiler for only your use?
 
Quoted text here. Click to load it

Which a don't use (or trust come to that).  Although others certainly
do.  The syntax varies considerably as well.

Quoted text here. Click to load it

And these would do what exactly?

Robert

--

Re: Shall I move from C to Java?
timestamped Tue, 14 Aug 2007 10:00:47 -0700,
|-------------------------------------------------------------------------|
|"[..]                                                                    |
|                                                                         |
|another question is how to disable "goto", can I write #define goto      |
|error("no goto")"                                                        |
|-------------------------------------------------------------------------|

Yes, but someone else can simply type
#undef goto

Site Timeline