473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.

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
5 5894
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Martin Bless | last post by:
The good news: Along with Python-2.4 comes really good news to Windows users. Yes, you now CAN build extension modules yourself using the SAME C++ compiler and linker Python is built with...
4
by: Aaron Queenan | last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the following error message: Linking... LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport LINK : error...
12
by: Markus Ewald | last post by:
I'm just experimenting around with the VisualC++ 2005 Express Edition Beta and found some strange behavior for which I can't seem to find a workaround. What I've done is set up two static library...
7
by: Sverker Nilsson | last post by:
I have been informed that Guppy-PE (http://guppy-pe.sourceforge.net) has failed to compile its extension modules with a Microsoft .NET 2003 compiler under Windows 2000. One of the problems,...
7
by: Victor | last post by:
I've got a website that is very fast. I just added a subroutine in the file global.asp (global.asp is run each time any page is called). The subroutine determines the user's country by comparing...
0
by: Pucca | last post by:
Hi I'm using vs2005. I am getting a bunch of compiler warnings after I made some changes to my code that was compiling clean. I'm also getting memory errors when I run my program and it's...
9
by: Andreas Schmitt | last post by:
I am workin on a 2 part project right now. The first part is a DLL, the second part a normal exe using that DLL. When I use the VS2005 standard setting for compiling with the Multithreaded-DLL...
8
by: rays | last post by:
Hi, I am trying to port a C++ program which is supposed to be standards compliant. It works fine on Linux with GCC (4.x). But as I try to compile it on Windows, all hell breaks loose. I have been...
9
by: rory | last post by:
I'm having some inconsistencies in my program that I can't seem to debug. Below is code that makes a copy of a binary file, appends a unique ID and string to the copy of the binary file and then...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.