By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 820 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

Compiling code at runtime

P: n/a
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.

http://msdn.microsoft.com/library/de...omCompiler.asp

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
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jo Vermeulen wrote:
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.


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

Jul 17 '05 #2

P: n/a
Op Tue, 25 May 2004 11:47:21 -0400, schreef Paul Schmidt:
C# and VB.Net are NOT programming languages, real or otherwise, they are
Microsoft specific implementations of languages.
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.
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.


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
Jul 17 '05 #3

P: n/a
Jo Vermeulen wrote:
Op Tue, 25 May 2004 11:47:21 -0400, schreef Paul Schmidt:

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

Could you explain this further?


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.

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.

..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.
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.

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.


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

Jul 17 '05 #4

P: n/a
Op Wed, 26 May 2004 10:29:05 -0400, schreef Paul Schmidt:
Jo Vermeulen wrote:
Op Tue, 25 May 2004 11:47:21 -0400, schreef Paul Schmidt:

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

Could you explain this further?


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.


Indeed.
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#.
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.
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.
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.
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.


.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).


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:

http://msdn.microsoft.com/net/ecma/

Although it may not be called .NET, important parts *are* standardized.
The language *is* standardized, unlike Java.
Mono is really a tail
chasing a dog, as they get close, Microsoft hacks on, and changes stuff.
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.
Java isn't a standard either, for the same reason, no standards
organization has published a Java standard.


Sun has always opposed standardizing, because then they would not be able
to update the specification soon enough.
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.

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.


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.


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
Jul 17 '05 #5

P: n/a
Paul Schmidt wrote:
Java isn't a standard either, for the same reason, no standards
organization has published a Java standard.


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...
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.