Compiling code at runtime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jo Vermeulen

    Compiling code at runtime

    Hello,

    I was wondering if Java supports a feature of C# (or .NET in general),
    namely compiling code at runtime.

    This is nice for scripting purposes. Users can script the application in
    real programming languages (such as C#, VB.NET, ...). This is done using
    the System.CodeDom. Compiler namespace, if I recall correctly.



    Is such a feature available for any version of Java (perhaps JDK 1.5 beta
    1)? Ofcourse it would then only be able to compile Java code.

    Thanks in advance!

    --
    Jo Vermeulen
    Student Computer Science at the tUL
    email: jo@lumumba.luc. ac.be
    www: http://lumumba.luc.ac.be/jo
  • Paul Schmidt

    #2
    Re: Compiling code at runtime

    Jo Vermeulen wrote:[color=blue]
    > Hello,
    >
    > I was wondering if Java supports a feature of C# (or .NET in general),
    > namely compiling code at runtime.
    >
    > This is nice for scripting purposes. Users can script the application in
    > real programming languages (such as C#, VB.NET, ...). This is done using
    > the System.CodeDom. Compiler namespace, if I recall correctly.
    >[/color]

    C# and VB.Net are NOT programming languages, real or otherwise, they are
    Microsoft specific implementations of languages.

    Compiling at run-time defeats the purpose of using a compiler in the
    first place, there are other languages like Perl, PHP, Javascript and
    TCL that are interpretive, that make it easy to run changes on the fly.
    However one really needs to know why you want to compile at run time.

    If you changing source code, and recompiling, then you really should
    write the program differently, so that your not doing this, because
    there are issues, like what if there is a compiler error?

    Paul

    Comment

    • Jo Vermeulen

      #3
      Re: Compiling code at runtime

      Op Tue, 25 May 2004 11:47:21 -0400, schreef Paul Schmidt:
      [color=blue]
      > C# and VB.Net are NOT programming languages, real or otherwise, they are
      > Microsoft specific implementations of languages.[/color]

      Could you explain this further?

      For your information, I write C# programs on Mono
      (http://www.go-mono.com/). .NET is standardized you know, unlike Java. The
      biggest disadvantage of Java is in my opinion the fact that it is
      controlled by one company (Sun namely).

      I'm certainly not a Microsoft zealot (on the contrary! I'm a GNU/Linux
      user and I favor the concept of free software), but I quite like
      their .NET platform, just as a like Java. Both have their respective
      advantages and disadvantages.
      [color=blue]
      > Compiling at run-time defeats the purpose of using a compiler in the
      > first place, there are other languages like Perl, PHP, Javascript and
      > TCL that are interpretive, that make it easy to run changes on the fly.
      > However one really needs to know why you want to compile at run time.[/color]

      For easy extensibility, and doing things at runtime, without recompiling
      the entire code. But I still require a powerful programming language,
      because the things users might add to the functionality are not
      really trivial programming tasks.

      Kind regards,

      --
      Jo Vermeulen
      Student Computer Science at the tUL
      email: jo@lumumba.luc. ac.be
      www: http://lumumba.luc.ac.be/jo

      Comment

      • Paul Schmidt

        #4
        Re: Compiling code at runtime

        Jo Vermeulen wrote:[color=blue]
        > Op Tue, 25 May 2004 11:47:21 -0400, schreef Paul Schmidt:
        >
        >[color=green]
        >>C# and VB.Net are NOT programming languages, real or otherwise, they are
        >>Microsoft specific implementations of languages.[/color]
        >
        >
        > Could you explain this further?[/color]

        Sure, C# was invented by Microsoft, as a Java like system, because Sun,
        didn't like the concept that when using a Microsoft compiler VisualJ I
        think they called it, produced code that would only run on Windows,
        because half the code depended on Microsoft hacks. When Microsoft tried
        this, Sun said, see you in court, and you can't call your product Java,
        until the court says you can. Microsoft lost, in the mean time, they
        hacked some more and called the result C#.

        VB isn't a language either, the language behind it is BASIC, but it's
        been hacked so much over the years, adding Pascal like features
        actually, that even the inventors wouldn't recognize VB as BASIC,
        however that does't make it a separate language.
        [color=blue]
        >
        > For your information, I write C# programs on Mono
        > (http://www.go-mono.com/). .NET is standardized you know, unlike Java. The
        > biggest disadvantage of Java is in my opinion the fact that it is
        > controlled by one company (Sun namely).
        >
        > I'm certainly not a Microsoft zealot (on the contrary! I'm a GNU/Linux
        > user and I favor the concept of free software), but I quite like
        > their .NET platform, just as a like Java. Both have their respective
        > advantages and disadvantages.
        >[/color]

        ..NET is not a standard, no matter how much Microsoft's prophet William
        Gates V3.0 says so. There is no standard called .Net, as identified by
        any standards organization (like ISO or ANSI). Mono is really a tail
        chasing a dog, as they get close, Microsoft hacks on, and changes stuff.

        Java isn't a standard either, for the same reason, no standards
        organization has published a Java standard.
        [color=blue]
        >[color=green]
        >>Compiling at run-time defeats the purpose of using a compiler in the
        >>first place, there are other languages like Perl, PHP, Javascript and
        >>TCL that are interpretive, that make it easy to run changes on the fly.
        >> However one really needs to know why you want to compile at run time.[/color]
        >
        >
        > For easy extensibility, and doing things at runtime, without recompiling
        > the entire code. But I still require a powerful programming language,
        > because the things users might add to the functionality are not
        > really trivial programming tasks.
        >[/color]

        Just because a language is compiled, doesn't make it more powerful then
        one that is interpreted, I still think you would be better off using TCL
        to extend your software, it's fairly easy to learn, and was designed to
        work with other programming languages to do this kind of thing.

        Paul





        Comment

        • Jo Vermeulen

          #5
          Re: Compiling code at runtime

          Op Wed, 26 May 2004 10:29:05 -0400, schreef Paul Schmidt:
          [color=blue]
          > Jo Vermeulen wrote:[color=green]
          >> Op Tue, 25 May 2004 11:47:21 -0400, schreef Paul Schmidt:
          >>
          >>[color=darkred]
          >>>C# and VB.Net are NOT programming languages, real or otherwise, they are
          >>>Microsoft specific implementations of languages.[/color]
          >>
          >>
          >> Could you explain this further?[/color]
          >
          > Sure, C# was invented by Microsoft, as a Java like system, because Sun,
          > didn't like the concept that when using a Microsoft compiler VisualJ I
          > think they called it, produced code that would only run on Windows,
          > because half the code depended on Microsoft hacks.[/color]

          Indeed.
          [color=blue]
          > When Microsoft tried
          > this, Sun said, see you in court, and you can't call your product Java,
          > until the court says you can.
          > Microsoft lost, in the mean time, they
          > hacked some more and called the result C#.[/color]

          I don't find C# a hacked together version of Java to be honest. There are
          very nice features in C# or .NET in general that Java lacks (including a
          lot of syntactic sugar):

          - enums
          - value types (structs)
          - properties
          - attributes
          - indexers
          - boxing/unboxing
          - versioning (and "override" keyword when overriding a virtual function)
          - pre-processing
          - aliases
          - at runtime code generation
          - unsafe code (using pointers)
          - passing by reference (the ref keyword)
          - variable lists of arguments (cfr. varargs in C/C++)
          - overflow detection
          - when having multiple inherited interfaces with the same methods, it
          is possible to specify which method to use
          - versioning of assemblies

          C# might look like a "raped version of Java" on first sight, but it isn't.
          It includes things from C++ Java had left out, but which are pretty
          useful, even in a true object-oriented language.

          Pretty funny Java is including TypeSafe Enums in JDK 1.5.
          [color=blue]
          > VB isn't a language either, the language behind it is BASIC, but it's
          > been hacked so much over the years, adding Pascal like features
          > actually, that even the inventors wouldn't recognize VB as BASIC,
          > however that does't make it a separate language.[/color]

          I agree with you about the comparision with BASIC. I don't know much about
          the details of VB or VB.NET though. Never used it. I just used VB.NET as
          an example of a programming language in my previous post, although you
          might see it as a Microsoft specific hack of BASIC. Could be, but
          even then it is a language you can use to create applications, which in my
          definition, qualifies as a programming language.

          I noticed VB.NET has been completely revamped compared to VB 6 to be more
          object-oriented.
          [color=blue][color=green]
          >> For your information, I write C# programs on Mono
          >> (http://www.go-mono.com/). .NET is standardized you know, unlike Java. The
          >> biggest disadvantage of Java is in my opinion the fact that it is
          >> controlled by one company (Sun namely).
          >>
          >> I'm certainly not a Microsoft zealot (on the contrary! I'm a GNU/Linux
          >> user and I favor the concept of free software), but I quite like
          >> their .NET platform, just as a like Java. Both have their respective
          >> advantages and disadvantages.
          >>[/color]
          >
          > .NET is not a standard, no matter how much Microsoft's prophet William
          > Gates V3.0 says so. There is no standard called .Net, as identified by
          > any standards organization (like ISO or ANSI).[/color]

          The CLI (runtime) and C# are ECMA (an international standards
          organisation) standards. They were then submitted to ISO, and became
          ISO/IEC 23270 (C#), ISO/IEC 23271 (CLI) and ISO/IEC 23272 (CLI TR).

          More information:

          .NET is a developer platform with tools and libraries for building any type of app, including web, mobile, desktop, games, IoT, cloud, and microservices.


          Although it may not be called .NET, important parts *are* standardized.
          The language *is* standardized, unlike Java.
          [color=blue]
          > Mono is really a tail
          > chasing a dog, as they get close, Microsoft hacks on, and changes stuff.[/color]

          Don't judge too soon. Mono is very important for Novell, and a lot of
          resources are put into it. This summer we should see Mono 1.O which would
          implement most of .NET 1.1.
          [color=blue]
          > Java isn't a standard either, for the same reason, no standards
          > organization has published a Java standard.[/color]

          Sun has always opposed standardizing, because then they would not be able
          to update the specification soon enough.
          [color=blue][color=green][color=darkred]
          >>>Compiling at run-time defeats the purpose of using a compiler in the
          >>>first place, there are other languages like Perl, PHP, Javascript and
          >>>TCL that are interpretive, that make it easy to run changes on the fly.
          >>> However one really needs to know why you want to compile at run time.[/color]
          >>
          >>
          >> For easy extensibility, and doing things at runtime, without recompiling
          >> the entire code. But I still require a powerful programming language,
          >> because the things users might add to the functionality are not
          >> really trivial programming tasks.
          >>[/color]
          >
          > Just because a language is compiled, doesn't make it more powerful then
          > one that is interpreted, I still think you would be better off using TCL
          > to extend your software, it's fairly easy to learn, and was designed to
          > work with other programming languages to do this kind of thing.[/color]

          Could be, I'll consider it, although the BeanShell alternative looks good
          too.

          Kind regards,

          --
          Jo Vermeulen
          Student Computer Science at the tUL
          email: jo@lumumba.luc. ac.be
          www: http://lumumba.luc.ac.be/jo

          Comment

          • Craig Hennessey

            #6
            Re: Compiling code at runtime

            Paul Schmidt wrote:
            [color=blue]
            > Java isn't a standard either, for the same reason, no standards
            > organization has published a Java standard.[/color]

            What right does a standards organisation have to define standards? What is a
            "standard" anyway? Java have published a standard, there are many versions
            of Java compilers / interpreters, why is this not a standard?

            Craig

            --
            # Random Comment...

            Comment

            Working...