Subject:
|
Why Java for Robots (was NXT and bluetooth enabled phones)
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Tue, 17 Jan 2006 14:58:20 GMT
|
Original-From:
|
PeterBalch <peterbalch@compuserve.comIHATESPAM>
|
Viewed:
|
1634 times
|
| |
| |
> > In lugnet.robotics, PeterBalch <PeterBalch@compuserve.com> wrote:
> > for robots, Java requires a ludicrously huge virtual
> > machine.
>
> Peter Gammie <peteg42@gmail.com> wrote:
> Lejos is not a full JVM - it has no garbage collector, e.g., and the
> standard library is mostly absent.
I was looking into Java as a small-robot programming language and examined
a few implementations. I came to the conclusion that it simply wasn't
suitable. Sure you can shoehorn a cut-down version into a small processor
but you've had to remove so much that what's left hardly counts as Java.
IMHO Java is just another run-of-the-mill language. It's C++ with the nasty
parts taken out. (Which to me means that it's object-oriented Pascal with
curly brackets.)
I want to be convinced otherwise because maybe I'm missing out on something
wonderful. I'm no Java expert so maybe I'm talking complete drivel.
> <scratches head> OO is not the only way to do this. It is not clear
> to me that the overheads of Java (relative to say a brickOS / C
> combination) are worth it on the RCX, especially as you have to
> manage memory manually in both cases anyway.
Spot on!
What makes Java special are the class libraries and the garbage collection.
It absolutely requires an enormous heap and a garbage collector - neither
of which make it suitable for a small robot.
And most of the standard Java class libraries are concerned with graphics,
windowing and string handling so aren't relavent.
And what use are Objects anyway? (Heresy!?)
I use them all the time in Delphi and they're great because 99% of the
objects I use are associated with something that appears in the user
interface. I drag a button into the window and an object appears in my
program that I can talk to. How useful is that in a robot? Sure, I could
have an object that corresponds to a pushbutton or Sonar but does that make
programming easier? Easier than just a library of subroutines? I haven't
found it so.
Objects are wonderful in their place. I just don't think their place is in
small robots. If I'm writing a Windows business application (yuk) where,
say, clients arrive, have transactions and depart then Objects would be the
way to do it. But robots aren't like that.
Especially not if Objects require the huge overhead of a heap and garbage
collection.
Lets compare Java-plus-objects with old-time Fortran-plus-subroutines.
Java treats all objects as dynamic. Java treats the stack as dynamic. That
is a mistake in a small processor with limited memory.
Old-time Fortran treated all data allocation as static. A good Fortran
compiler will analyse the subroutine calls and work out which local
variables cannot be used concurrently. That's exactly what's wanted for a
small processor with limited memory.
It seems to me that it would be perfectly possible to write something that
looked superficially like Java-plus-objects but where everything was
statically allocated. (Am I right? I know lots about writing compilers but
very little about Java. Because Java is a better designed language than
C++, it should compile to smaller code. Pascal is even better in that
respect.)
In 1980 I had a DOS Fortan compiler that would generate code to run on a
ZX81 (a Z80 machine with 1k RAM for data and program). Java and C++ live in
the world of Windows Software Bloat. Hobby roboteers live back in the
1980s.
Peter
|
|
Message has 1 Reply:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|