Do we really need virtual machines? - Compilers

This is a discussion on Do we really need virtual machines? - Compilers ; Hallo, According to their proponents virtual machines such as JVM and CLR are the solution to all our (programming) problems, of which portability is but one. Maybe it's just because when I learnt programming the p-machine was considered an interesting ...

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23

Do we really need virtual machines?

  1. Default Do we really need virtual machines?

    Hallo,
    According to their proponents virtual machines such as JVM and CLR are
    the solution to all our (programming) problems, of which portability
    is but one.

    Maybe it's just because when I learnt programming the p-machine was
    considered an interesting oddity, but with the exception of code that
    really must run unchanged on unknown platforms, I fail to see what do
    I gain from a virtual machine that I don't already get from a good old
    compiler/runtime support/standard library chain.

    After all, isn't gcc the most ported virtual machine of all?

    Now, this being the compiler forum, I'm interested in learning about
    the advantages of virtual machines from the compiler writer
    perspective.

    Thank you,
    Nicola Musatti

  2. Default Re: Do we really need virtual machines?

    Nicola Musatti wrote:

    > Maybe it's just because when I learnt programming the p-machine was
    > considered an interesting oddity, but with the exception of code that
    > really must run unchanged on unknown platforms, I fail to see what do
    > I gain from a virtual machine that I don't already get from a good old
    > compiler/runtime support/standard library chain.


    There is no requirement to virtualize code in order to gain
    portability. Quite the contrary, what the JVM and other
    implementations do is perform reference checking, and JVM even tries
    to do that before running the code (virtually or not) in order to
    enhance performance. Further, a good virtual memory implementation can
    perform complete reference checking as well.

    To be fair, I don't think anyone from the JVM or .net crowd is
    claiming that virtualization is required for portability, otherwise
    the just in time compiler ideas make no sense (I don't believe .net is
    even has a virtual machine implementation).

    100% portability with standard compilers is a worthwhile study (I
    define 100% portability as recompile only). I would divide the
    portability problem into sematics and enforcement. Semantics is having
    the same code perform the same action on different implementations,
    enforcement is making sure the program does not violate the rules
    under which the sematics are garanteed to be correct. There seems to
    be lots of agreement on sematics, but not much on enforcement.

    --
    Samiam is Scott A. Moore

  3. Default Re: Do we really need virtual machines?

    On 2 Oct 2004 01:17:26 -0400, Nicola Musatti <Nicola.Musatti@ObjectWay.it>
    wrote:

    > Hallo,
    > According to their proponents virtual machines such as JVM and CLR are
    > the solution to all our (programming) problems, of which portability
    > is but one.


    Well I hope they aren't saying it will solve my performance problems -
    because I'd have a hard time believing that!

    > Maybe it's just because when I learnt programming the p-machine was
    > considered an interesting oddity, but with the exception of code
    > that really must run unchanged on unknown platforms, I fail to see
    > what do I gain from a virtual machine that I don't already get from
    > a good old compiler/runtime support/standard library chain.


    If you view a virtual machine as just a well-defined platform
    targetted by compilers, then it seems there is nothing you can do for
    a virtual machine that cannot be done for some other platform. A VM
    is practically synonymous with an emulator except that VM code is
    designed to be emulated.

    > After all, isn't gcc the most ported virtual machine of all?


    I think it's not a virtual machine; when the program is running, gcc
    is no longer running.

    > Now, this being the compiler forum, I'm interested in learning about
    > the advantages of virtual machines from the compiler writer
    > perspective.


    Because you get to design the instruction set, you can make it more
    "friendly" to the compiler writers.

    In the case of the JVM or SafeTSA you can make it simple to perform a
    safety validation; safety proofs for other machine codes are far more
    difficult.

    But then again, most of the VM's benefit is portability - it is usually
    easier to write an interpreter for virtual machine code than for, say,
    intel x86 machine code.

    CU
    Dobes

  4. Default Re: Do we really need virtual machines?

    Nicola Musatti wrote:

    > According to their proponents virtual machines such as JVM and CLR
    > are the solution to all our (programming) problems, of which
    > portability is but one.


    You are right. Distinct instruction sets are an obstacle to
    portability. But my experience with learning Java tells me another
    lesson: The instruction is hard enough to create portably (see below)
    but it is only the first step of portability. Look at Java and C#: The
    most important obstacle in portability is the amount of libraries with
    all their quirks and dead ends (AWT).

    Has anyone ever noticed that the "standard libraries" that come with
    Java and C# are attempts to recreate Unix-like Operating Systems ?
    Including APIs for memory, file system, scheduler, terminal, printer,
    network, clock, GUI ... O'Reilly publishes dozens of Java books. What
    are they all about ? Library details; most of them becoming obsolete
    if C# succeeds. Stuffing Java library details into my brain seems like
    a waste of brain capacity.

    > Now, this being the compiler forum, I'm interested in learning about
    > the advantages of virtual machines from the compiler writer
    > perspective.


    Our moderator (John) has pointed out _very_ often that language
    designers should first learn the lessons of the UNCOL period (1960s)
    before they start inventing yet another UNCOL-variant. Nobody listens
    to John; they are just too busy.
    [The original UNCOL proposal was published in the CACM in 1958, and
    the report on the first (and last) version was in the 1961 winter JCC
    proceeedings. Also see a collection of UNCOL references I pulled
    together in comp.compilers 13 years ago at
    http://compilers.iecc.com/comparch/article/91-12-058 -John]

  5. Default Re: Do we really need virtual machines?

    On 2004-10-02, Jürgen Kahrs <Juergen.Kahrs@vr-web.de> wrote:
    > Nicola Musatti wrote:
    >
    >> According to their proponents virtual machines such as JVM and CLR
    >> are the solution to all our (programming) problems, of which
    >> portability is but one. [...]

    >
    > Has anyone ever noticed that the "standard libraries" that come with
    > Java and C# are attempts to recreate Unix-like Operating Systems ?
    > Including APIs for memory, file system, scheduler, terminal, printer,
    > network, clock, GUI ... [....]
    >
    >> Now, this being the compiler forum, I'm interested in learning about
    >> the advantages of virtual machines from the compiler writer
    >> perspective.

    >
    > Our moderator (John) has pointed out _very_ often that language
    > designers should first learn the lessons of the UNCOL period (1960s)
    > before they start inventing yet another UNCOL-variant. Nobody listens
    > to John; they are just too busy.


    I mostly agree with that comment, but I tend to believe that work
    could still be done to define an intermediate language (not
    necessarily a VM) for a common family of languages. For exemple, I
    would believe that it could be possible to define an intermediate
    language suitable to Ocaml and SML, and perhaps (possibly) also to
    Scheme. This form won't be suitable to Java or Eiffel or C++ or C.

    In other words, I would imagine that an intermediate form similar to
    the "lambda" representation of the Ocaml compiler could be suitable
    for SML and perhaps Scheme. Of course, the current "lambda"
    representation is not it, but could be a little bit extended or
    adapted.

    All this is just a belief, not a result of hard work.

    On a vaguely related note, I feel very sorry that JVM or CLR did not
    evolve to incorrporate the few necessary features -notably closures &
    tail recursive calls- to make them really usable for functional
    languages like the ML family or Scheme. I suppose that the major
    reason is not technical, but economical or political. (IIRC, some
    relevant extensions to the JVM have been proposed by the functional
    community but rejected by Sun).

    Regards/

    Regards.
    --
    Basile STARYNKEVITCH http://starynkevitch.net/Basile/
    email: basile<at>starynkevitch<dot>net
    aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
    8, rue de la Faïencerie, 92340 Bourg La Reine, France
    [Common intermediate languages work OK if the source languages are
    semantically similar and the targets are all about the same, e.g.
    32 bit byte addressed twos-complement machines with flat addressing.
    They collapse when you try to generalize them. -John]


  6. Default Re: Do we really need virtual machines?

    On 2 Oct 2004 16:35:11 -0400, Jürgen Kahrs <juergen.kahrs@vr-web.de> wrote:

    > Has anyone ever noticed that the "standard libraries" that come with
    > Java and C# are attempts to recreate Unix-like Operating Systems ?


    Yes, this is true. But I think that this attempts are very useful.

    > Including APIs for memory, file system, scheduler, terminal, printer,
    > network, clock, GUI ... O'Reilly publishes dozens of Java books. What
    > are they all about ? Library details; most of them becoming obsolete
    > if C# succeeds. Stuffing Java library details into my brain seems like
    > a waste of brain capacity.


    I don't agree with your opinion. I have done some big java
    applications and I can run them with Windows, Solaris and Linux with
    ANY problems and without needing to compile again. In fact, I don't
    need to modify anything. And this is true because Sun has done the
    effort to recreate the standard libraries and unify them in the java
    library.

    And if you use for example C++ , that is possible the most standard
    language, with standard libraries you have more problems with
    portability. Because the standard libraries don't covers all of the
    functionallity you want in most of your programs. And you have to use
    system dependent libaries. For example what if you want to do an app
    with a GUI? (Yes, you have QT, but...) And also there are compilers
    incompatibilities. A lot of times you have some code that runs well
    with GNU G++ but not with MSVC.

    Well, in conclusion, I think that the simple fact to do a VM don't
    solves your portability in a magic way. In every platform you want to
    run code, you should battle writting a VM2NativeCode and also portting
    libraries if you define them. But I think that this isn't a waste of
    time.

    And about Nicola:

    >I gain from a virtual machine that I don't already get from a good old
    >compiler/runtime support/standard library chain.


    I think that if you implement this you can get the same functionality
    that you can get with a VM (except that you should compile in every
    platform). But in constrat you will have more or at least the same
    work to do that with a VM. And an advantage of a VM, is that you can
    get a VM like JVM that has been already done.

    Cheers,
    --
    Joan Jesús Pujol Espinar


  7. Default Re: Do we really need virtual machines?

    Jürgen Kahrs wrote:

    > Our moderator (John) has pointed out _very_ often that language
    > designers should first learn the lessons of the UNCOL period (1960s)
    > before they start inventing yet another UNCOL-variant. Nobody
    > listens to John; they are just too busy.


    In addition, despite the fact that most people were reminded of P-code
    when Java came out, Sun attempted to put the JVM on silicon and
    achieved EXACTLY the same results Western Digital did when they tried
    to put the P-machine on silicon, namely a processor that could not run
    bytecode as fast as a general purpose machine. Turns out all that
    register manipulation and multiple modes makes a difference after all.

    The tired saying that applies is: The first thing you learn from
    history is that nobody learns from history.
    --
    Samiam is Scott A. Moore

  8. Default Re: Do we really need virtual machines?

    In a sense we are all running on virtual machines all the time, even
    when programming in C++ or Assembler. Until IBM introduced the System
    360 in the 60's every computer was hardwired for its own instruction
    set. The 360's were different: there were a number of
    microprogrammable machines that all executed the 360 instruction
    set. The trend since then has been to have a standard architecture and
    instruction set that ranges over all sizes and speeds, but implemented
    by different microprocessors running different microcode.

    So the a better question might be: at what level do we want
    compatibility?

    (And, yes, there were nanomachines that were programmed to look like
    micromachines, but you need to find someone like Sam Cohen to find out
    about them.)

    john slimick
    slimick@pitt.edu
    [Microprogramming was invented in about 1952, but it wasn't until the
    1960s that ROMs got fast and cheap enough to make it practical. -John]

  9. Default Re: Do we really need virtual machines?

    Joan Pujol <joanpujol> writes:
    |> On 2 Oct 2004 16:35:11 -0400, Jürgen Kahrs <juergen.kahrs@vr-web.de> wrote:
    |>
    |> > Has anyone ever noticed that the "standard libraries" that come with
    |> > Java and C# are attempts to recreate Unix-like Operating Systems ?
    |>
    |> Yes, this is true. But I think that this attempts are very useful.

    For some meanings of the word "useful". Unfortunately, they also
    attempt to implement every restriction of those languages, such as:

    A minimal (and often useless) diagnostic model - no, a single integer
    code is NOT useful in practice. When you get ENOMEM from a write to a
    descriptor that is connected via TCP/IP to a remote server, what have
    you run out of and in what part of the system?

    A synchronous, copying I/O model that gives really poor efficiency
    (and I don't just mean bandwidth). Many of the old mainframe models
    were vastly better, and we used to get very high bandwidths with very
    low memory and CPU utilisation on very slow CPUs.

    There are other examples, but that should do.


    Regards,
    Nick Maclaren.

  10. Default Re: Do we really need virtual machines?

    Dobes Vandermeer <dobes@dobesland.com> wrote:
    >Nicola Musatti <Nicola.Musatti@ObjectWay.it> wrote:
    >
    >> After all, isn't gcc the most ported virtual machine of all?

    >
    >I think it's not a virtual machine; when the program is running, gcc
    >is no longer running.


    All languages require some kind of run time support. They also require
    standard cross-module calling conventions. To some extent you can view
    the combination of the run-time library and the stylized machine code
    emitted by the compiler as a virtual machine. This view is made
    explicit by a large proportion of functional programming language
    compilers, where the technique is to compile the language to an
    abstract virtual machine which can be compiled to efficient machine
    code.

    It's also worth considering the partial evaluation view of compilers,
    where the run-time system is the residual part of the interpreter that
    is left after it has been partially evaluated with respect to a
    program.

    Tony.
    --
    f.a.n.finch <dot@dotat.at> http://dotat.at/
    LUNDY FASTNET IRISH SEA SHANNON: WEST OR SOUTHWEST 6 OR 7, OCCASIOANLLY GALE 8
    AT FIRST IN LUNDY AND IRISH SEA, AND PERHAPS AGAIN LATER. RAIN OR SHOWERS.
    MODERATE OR GOOD.

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Similar Threads

  1. Replies: 1
    Last Post: 07-09-2007, 06:58 PM
  2. Senior Instructor ~ Own Training for Java Virtual Machines
    By Application Development in forum Java
    Replies: 0
    Last Post: 07-09-2007, 02:04 PM
  3. Need clarification for virtual method and pure virtual function
    By Application Development in forum c++
    Replies: 7
    Last Post: 06-28-2007, 07:38 AM
  4. non-virtual call to a virtual function using pointer to member
    By Application Development in forum c++
    Replies: 4
    Last Post: 05-30-2007, 03:59 PM
  5. Re: Virtual Memory Minimum Too Low: Your system is low on virtual
    By Application Development in forum DOTNET
    Replies: 0
    Last Post: 09-14-2004, 08:58 PM