M
Mark A. Gibbs
it's almost a lost cause to try and educate an dogmatist. when one is
determined enough in one's faith, trivialities like rationalization and
blatant, incontrovertable facts are merely annoyances, and can be
readily assumed to be nonsense. still... the idealist in me has to try...
ports and special machine instructions are rare, eh? dude, if you're
willing to sacrifice ports and special machine instructions, your
programs are no longer capable of:
- reading keyboard input (via interrupts).
- reading mouse input (via port-access instructions).
- multithreading (via context-switching instructions).
- video display (via device drivers, which require ports and interrupts).
- accessing storage devices (more of the same).
etc.
in short, you're now the proud new owner of a javaâ„¢ powered paperweight.
that would depend on the os, now wouldn't it?
as for that being 'c' code, how about:
int* screen = static_cast<int*>(0xA0000000); // ^_^
jerry coffin's code is perfectly valid, and may be the expected way to
access some hardware resource.
uh huh. i don't program the enterprise, i just make sure she has enough
power, sir. boudary checks sound nice on paper, but if you can't turn
them off, they are a problem. anything that gets between you and the
hardware and refuses to move when you need it to is a problem. this is
not opinion, this is common sense.
being able to actually access console hardware and make it do stuff is
more preferred over the other consiferations you mentioned in my little
multi-billion dollar corner of SW enterprise.
good for pascal. can java do it?
no sir, not every memory access is direct memory access. in fact, few of
them are these days. when you do an allocation in windows and it returns
memory address 0x12345678, do you seriously think that any variable you
put in there will actually be at physical address 0x12345678 on your ram
chip? if you allocate a variable at 0x10000004 in one process, then
another at 0x10000008 in another, do you seriously think that you could
add 4 to 0x10000004 in the first process and access the variable in the
second? honestly, people pay so much damn lip service to memory and
security, but few actually consider what they're talking about.
first of all, you don't implement platforms for "c/c++", you implement c
and c++ compilers for platforms. or you implement platforms, then later
port a c++ compiler over.
second of all, you just write it. for the record, you could even
generate a c++ compiler and c++ programs for a system that uses java
bytecode-based hardware, ie, the "java platform".
but the problem isn't that either c++ or java is incapable of creating a
compiler, because they both are. the problem is that c++ compiles to
native code - even is that native code is cross-compiled - whereas java
only generates code for the java operating system.
consider this example. imagine you have two operating systems x and y. x
has both a c++ compiler and a java vm. y has neither. you have been
asked to write a text editor for y. you cannot accomplish this using java.
(aside1 - of course, if you had a java-to-native-code compiler you could
do it. but that would not be generating a java program, now would it?
not unless you also generated the entire vm and all required libraries.
and even if you argued that compiling native code from java was a
legitimate solution, last time i checked, native-ized java programs were
abysmal in size and performance.)
(aside2 - there *is* a way that you could even if you didn't allow for
the existence of a java-to-native-code compiler, but seriously, you
would never find anyone idiotic enough to suggest it. not for a text
editor at least.)
mark
determined enough in one's faith, trivialities like rationalization and
blatant, incontrovertable facts are merely annoyances, and can be
readily assumed to be nonsense. still... the idealist in me has to try...
valentin said:You don't make sense here. C++/Java are not the best candidates for
real-time programming indeed. But real-time system and OS are different
notions. Any program can be accomplished using memory-access only (ports and
special machine instructions are rate). What is the definition of "complete
program"?
ports and special machine instructions are rare, eh? dude, if you're
willing to sacrifice ports and special machine instructions, your
programs are no longer capable of:
- reading keyboard input (via interrupts).
- reading mouse input (via port-access instructions).
- multithreading (via context-switching instructions).
- video display (via device drivers, which require ports and interrupts).
- accessing storage devices (more of the same).
etc.
in short, you're now the proud new owner of a javaâ„¢ powered paperweight.
I was asked not to call you C programmers but this is C code. It will fail
executing on a modern OS.
that would depend on the os, now wouldn't it?
as for that being 'c' code, how about:
int* screen = static_cast<int*>(0xA0000000); // ^_^
jerry coffin's code is perfectly valid, and may be the expected way to
access some hardware resource.
Any byte-array acces in java is a subject of boundry check indeed. However,
a cgi dll attached to a WEB sever is located in its address space. The
option for unlimited memory access, enabes your to fail the server
(unintentionally). As a designer, I will choose a tool that allows me to
accomplish faster (C/C++ compilers are slow, stupid and produce code often
slower than say Delphi compiler). Java sandbox targets reliable modules
which cannot distroy the rest of the system. Furthermore, Java allows for
exceptions which when not handeled show you a sensible error message with
the line of source code caused the error. Which is not possible in the case
of unlimited memory access (you get mem access violation dialog, don't
you?). These consiferations are often more preferred over direct memory
access in the modern SW design, espesially enterprise programming.
uh huh. i don't program the enterprise, i just make sure she has enough
power, sir. boudary checks sound nice on paper, but if you can't turn
them off, they are a problem. anything that gets between you and the
hardware and refuses to move when you need it to is a problem. this is
not opinion, this is common sense.
being able to actually access console hardware and make it do stuff is
more preferred over the other consiferations you mentioned in my little
multi-billion dollar corner of SW enterprise.
So, my point is that C/C++ programmers are convinced they are best operating
on pointers. What is a problem to write that line of code in, say Pascal?
TurboPascal even defines a special word for accessing abolute mem locations:
var screen: array[0..N] of byte absolute $A000:$C000;
good for pascal. can java do it?
Finally, ANY memory access (say assigning a variable) is direct memory
access. Furthermore, don't you know about java HW processors? How will you
access HW in a Java-bytecodes-only system?
Real-time Low-power Java Processor aJ-100
http://www.systronix.com/jstamp/reality.htm
no sir, not every memory access is direct memory access. in fact, few of
them are these days. when you do an allocation in windows and it returns
memory address 0x12345678, do you seriously think that any variable you
put in there will actually be at physical address 0x12345678 on your ram
chip? if you allocate a variable at 0x10000004 in one process, then
another at 0x10000008 in another, do you seriously think that you could
add 4 to 0x10000004 in the first process and access the variable in the
second? honestly, people pay so much damn lip service to memory and
security, but few actually consider what they're talking about.
So, what is your point? Yes, Java is not only just a lang, it is a platform.
How do you implement a platform for C/C++ in these langs? I whould implement
HW in VHDL. Anyway, I can generate HW netlists in Java (manufacturing still
should be done on a factory).
first of all, you don't implement platforms for "c/c++", you implement c
and c++ compilers for platforms. or you implement platforms, then later
port a c++ compiler over.
second of all, you just write it. for the record, you could even
generate a c++ compiler and c++ programs for a system that uses java
bytecode-based hardware, ie, the "java platform".
but the problem isn't that either c++ or java is incapable of creating a
compiler, because they both are. the problem is that c++ compiles to
native code - even is that native code is cross-compiled - whereas java
only generates code for the java operating system.
consider this example. imagine you have two operating systems x and y. x
has both a c++ compiler and a java vm. y has neither. you have been
asked to write a text editor for y. you cannot accomplish this using java.
(aside1 - of course, if you had a java-to-native-code compiler you could
do it. but that would not be generating a java program, now would it?
not unless you also generated the entire vm and all required libraries.
and even if you argued that compiling native code from java was a
legitimate solution, last time i checked, native-ized java programs were
abysmal in size and performance.)
(aside2 - there *is* a way that you could even if you didn't allow for
the existence of a java-to-native-code compiler, but seriously, you
would never find anyone idiotic enough to suggest it. not for a text
editor at least.)
mark