EmbeddedRelated.com
Forums

Shall I move from C to Java?

Started by dick August 14, 2007
On Aug 14, 1:07 am, dick <dick_12345...@hotmail.com> wrote:

> Can I access HW registers in Java? Or can I call C function from Java > program?
Not directly, and yes, respectively. There is an implementation of a JVM for AVR; I've seen it mentioned briefly in c.a.e in response to a thread I posted asking something related. There is ALSO an implementation of a JVM for the Commodore 64 (a 1MHz 6502-family device, for those who don't know this). The real question is, do you understand what Java will provide for you, and what it will cost you (in terms of resources, performance etc). I had very specific reasons for wanting to use Java in my project (it was the PC UI side of an embedded system).
On Tue, 14 Aug 2007 10:00:47 -0700, dick wrote:

> Hans-Bernhard Brker wrote: >> [X-post lacked a F'up2; reduced to one group] >> >> dick wrote: >> >> > I am planning to learn Java. >> >> Why, given you clearly don't know if it's going to do you any good? >> >> > Can I access HW registers in Java? Or can I call C function from Java >> > program? >> >> 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. > > 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(...) > { > . > . > . > } >
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?
> > another question is how to disable "goto", can I write #define goto > error("no goto")
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 http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Tim Wescott wrote:
> On Tue, 14 Aug 2007 10:00:47 -0700, dick wrote: > > > Hans-Bernhard Brker wrote: > >> [X-post lacked a F'up2; reduced to one group] > >> > >> dick wrote: > >> > >> > I am planning to learn Java. > >> > >> Why, given you clearly don't know if it's going to do you any good? > >> > >> > Can I access HW registers in Java? Or can I call C function from Java > >> > program? > >> > >> 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. > > > > 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(...) > > { > > . > > . > > . > > } > > > > 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?
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.
> > > > > another question is how to disable "goto", can I write #define goto > > error("no goto") > > 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 > http://www.wescottdesign.com > > Need to learn how to apply control theory in your embedded system? > "Applied Control Theory for Embedded Systems" by Tim Wescott > Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On Tue, 14 Aug 2007 19:49:12 -0700, dick wrote:

> if the language support multi-thread, the debug time will be less. > > a save language should not let user see the OS.
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
In news:1187110847.342921.248580@k79g2000hse.googlegroups.com
timestamped Tue, 14 Aug 2007 10:00:47 -0700,
dick <dick_12345678@hotmail.com> posted:
|-------------------------------------------------------------------------|
|"[..]                                                                    |
|                                                                         |
|another question is how to disable "goto", can I write #define goto      |
|error("no goto")"                                                        |
|-------------------------------------------------------------------------|

Yes, but someone else can simply type
#undef goto

larwe wrote:

> On Aug 14, 4:15 pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com> > wrote: > >>dick wrote: >> >>>Hi everyone, >> >>>I am planning to learn Java. >> >>http://www.microsoft.com/mspress/books/10457.aspx > > > What has Microsoft's proprietary closed nonsense got to do with Java? > Or, for that matter, embedded programming? >
Stupid questions deserve equaly stupid answers. VLV
On Aug 15, 10:23 am, Vladimir Vassilevsky <antispam_bo...@hotmail.com>
wrote:
> larwe wrote: > > On Aug 14, 4:15 pm, Vladimir Vassilevsky <antispam_bo...@hotmail.com> > > wrote: > > >>dick wrote: > > >>>Hi everyone, > > >>>I am planning to learn Java. > > >>http://www.microsoft.com/mspress/books/10457.aspx > > > What has Microsoft's proprietary closed nonsense got to do with Java? > > Or, for that matter, embedded programming? > > Stupid questions deserve equaly stupid answers. > > VLV
And you are always there to oblige, right? ;^) Sorry, I couldn't resist...
On Aug 15, 10:23 am, Vladimir Vassilevsky

> Stupid questions deserve equaly stupid answers.
The question may have been ill-formed but I do not have enough information to judge that its intent was stupid.
Andrew Reilly wrote:
> On Tue, 14 Aug 2007 19:49:12 -0700, dick wrote: > > > if the language support multi-thread, the debug time will be less. > > > > a save language should not let user see the OS. > > 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... >
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 {...}"?
> -- > Andrew
In article <1187200063.146222.145190@d55g2000hsg.googlegroups.com>, dick 
says...
> > Andrew Reilly wrote: > > On Tue, 14 Aug 2007 19:49:12 -0700, dick wrote: > > > > > if the language support multi-thread, the debug time will be less. > > > > > > a save language should not let user see the OS. > > > > 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... > > > > Is there any Macro can hide the OS routine?
What OS routine are you referring to?
> I believe that C syntax extension is a cheaper solution than a new > language.
Are you planning on writing a compiler for only your use?
> Actually in Embedded world, C has a lot syntax extension such as > "interrupt fun()"...
Which a don't use (or trust come to that). Although others certainly do. The syntax varies considerably as well.
> So can we have "exclusive fun()" or "exclusive {...}"?
And these would do what exactly? Robert -- Posted via a free Usenet account from http://www.teranews.com