[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A 21st Century Apple II?
Jason <jasonb19xx@yahoo.com> writes:
> On 2009-03-10 23:51:15 +0700, Raymond Wiker <raw@RawMBP.local> said:
>
>> Jason <jasonb19xx@yahoo.com> writes:
>>
>>> Languages do have domains of applicability. For example, C++ is a
>>> systems programming language. Among other things, you can implement
>>> an operating system in it (for example Windows). Java is not a
>>> systems programming language and is unsuitable for this type of use
>>> because it must run on a JRE. In Java's defence, C++ is not really
>>> suitable for writting web applets.
>> This is not a well-chosen example. The run-time requirements
>> of C++ are not that much different from Java - both need substantial
>> run-time support just to carry their own weight :-)
>
> I think this statement is based at least partly on a misunderstanding
> of the difference between a programming language and a programming
> platform.
Not quite - I know the difference, and I'd say that both C++
and Java are closer to being programming platforms than programming
languages. Both of them have extensive standard libraries, and both of
them are pretty close to useless without those libraries (i.e, much of
the reason for using Java and C++ disappears if you cannot use the
standar libraries.)
> C++ is a programming language, Java is a programming platform.
>
> C++ needs no run-time support to run. You can write C++ code which
> will live in an ROM without linking to any start up code or libraries
> (-nostartfiles, -nodefaultlibs g++ options). Furthermore, the code
> can be linked statically (-static g++ option) so that there is no
> dependence on any dynamically loaded libraries.
You still need run-time suport if you want to do stuff like
reading from files, or do anything that has any sort of effect on the
world.
> Java, by definition, runs on a Java Runtime Environment (JRE). Java
> programs are compiled into a bytecode which is interpreted by a
> virtual machine implemented on the host system. Some of these virtual
> machines support just-in-time (JIT) compilation which compiles the
> bytecode into native code when it is first loaded but they still
> require the presence of the JRE to function.
There are native Java compilers, some of which may even eschew
garbage collection. There are also interpreted versions of C++. In
summary, the world is not just black and white.
> Several things should be apparent from the above:
>
> First, because C++ does not require any external libraries or other
> support in order to execute code written in it, C++ programs can be
> many times smaller than their Java counterparts. This advantage
> becomes less significant with large programs that make heavy use of
> external libraries.
If a C++ program does not use any libraries, it cannot do
anything interesting.
> Second, Java is not a suitable systems programming language not only
> because it must run on top of a JRE, but also because the language
> deliberately avoids constructs which allow its users to access memory
> directly. The latter can certainly be addressed with native methods
> for direct access to memory/hardware although this would be considered
> poor design by most OS engineers and it still leaves the larger
> problem of the JRE remaining.
>
>> On one hand, I cannot think of any OS implemented in
>> either of these. That doesn't mean that they don't exist, but it's
>> hardly widespread. On the other hand, you have a language like Lisp,
>> which is "known" to be inefficient and a resource hog. This is
>> factually incorrect; Lisp has been used to implement the OSs of AI
>> workstations and there is even a story about a machine running an
>> interrupt handler in interpreted mode.
>
> Were you aware that Microsoft Windows is implemented in C++? I can't
> think of an OS more widespread than it.
Windows is not something that springs to mind as implemented
in C++... as far as I know, the old stuff uses a language that is
closer to C than C++. All the new stuff is implemented on top of
the .NET runtime, where C# is the preferred language. What was your
point about virtual machines and large runtimes, again :-?
> Being inefficient or a resource hog does not preclude a language from
> being used to implement an operating system.
Which means that Java should be as suitable as C++ :-)