what is the difference between IBM JVM and Sun JVM?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

rookie1010

Senior member
Mar 7, 2004
984
0
0
thanks for the replies guys

so with .net i can write code written in java and get it to work with say c# code?

is the CLS a microsft specification?

so c# is a subset of c++?

C# there is no multiple inheritance (sounds like java)

wha tis a good compiler to use when programming using the .net environment?

so if a person has learnt java, he can move to the .net environment by programming in j#?


That isn't entirely accurate. Java was not designed specifically to support multiple languages but there are other languages that compile to java byte code, run on the standard jvm and can access java class librarires. Scala for instance.
can i get c,c++ to interwork with java?


That's fascinating. I wasn't aware that there was a java class library imitation for j#. Particularly curious because I think many parts of java's libs are way better than .net's and yet they chose to do a redesign
java did a resdeign of their classes?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: rookie1010
thanks for the replies guys

so with .net i can write code written in java and get it to work with say c# code?
Not normally, no. You can write code in j# and get it to work with c# code. But it really depends on what you mean by "work with". If you mean the same virtual machine, then no, but you can use things like webservices to get a decently high level binding between java and .net.
is the CLS a microsft specification?
Yes.
so c# is a subset of c++?
Not really, it's a different language. MarkR was more meaning that it inherited a lot of concepts. I always thought c# was more descending from java which descends from c++, but I've never been a c++ coder so...
C# there is no multiple inheritance (sounds like java)
That's what I thought :p
wha tis a good compiler to use when programming using the .net environment?
Depends on the language. csc.exe is the c# compiler with the microsoft distribution. I'm sure there's similar equivalents for vb, etc. But most people never touch those, they just use visual studio. You can also use mono (open source .net implementation) on more than just windows but I'm not sure what it's compilers are called specifically. But when you're talking about virtual machine languages, compilers don't really matter as much, it's the runtime that counts. I assume a mono compiler would produce something almost identical to a microsoft compiler and both runtimes should be able to run the compiled bytecode.
so if a person has learnt java, he can move to the .net environment by programming in j#?
Probably, but I've never actually heard of anybody using j#. I've been doing java for 5 years or so and last summer I did a co-op term programming in c# with no prior experience. It took me no time at all to have c# worked out and just a little while to get up to speed with the class libraries (I started with asp.net so it was a bit of a paradigm shift over anything I've done in java). But generally, anybody who has java experience can hop right in on .net. It probably doesn't work quite as well the other way around because certain things in java can require more work to use properly (xml parsing, jdbc etc) but it wouldn't be a big deal if you were working with a team that took care of the gory details for you.
That isn't entirely accurate. Java was not designed specifically to support multiple languages but there are other languages that compile to java byte code, run on the standard jvm and can access java class librarires. Scala for instance.
can i get c,c++ to interwork with java?
Yep, using jni (java native interface). I have only seen a bit of it but it looks pretty darn ugly. gcj (java platform for gcc) also has cni (c native interface) that is supposed to be much easier to use and faster, but gcj isn't really java :p

But both cni and jni are completely different concepts than something like scala, or the ability to use multiple languages in .net. With jni, your c code must be compiled with a regular c compiler (plus some java-specific libraries) and it runs on it's own, rather than being managed by the virtual machine. With scala, or c# and vb.net, everything compiles to byte-code that gets run in the same way by the virtual machine. Using vb and c# together is nearly seamless because they are the same thing underneath. Using c and java together is far from seamless because they are completely different underneath.

Note that you can also run un-managed code fairly easily from .net (never done it myself though). Microsoft has taken a lot of criticism for this because of security reasons. But I think most developers dedicated to a microsoft platform are more interested in the convenience :p
That's fascinating. I wasn't aware that there was a java class library imitation for j#. Particularly curious because I think many parts of java's libs are way better than .net's and yet they chose to do a redesign
java did a resdeign of their classes?
No, microsoft redesigned their classes, but only in the sense that they didn't directly copy a lot of concepts from the java libraries. For instance, I think the .net collections libraries are dismal compared to java's (java.util.*). I also dislike .net's database connectivity stuff. It's easier to get started with but doesn't tend to encourage database agnosticism.

In general, microsoft takes the approach of giving a developer a fairly easy, quick way to do something. Java takes the approach that you might want to change what goes on in the background so it provides a set of interfaces for you to use but makes you put in some configuration work to get the interface implementations going.

Jdbc is the perfect example. In java (as you've been doing) you can load up a driver behind the driver manager and get connections from there. But that's a simplistic (and pretty bad) way to do it. In j2ee there are a million different ways to set up a database connection factory that allow you to tweak the backend. Tedious but powerful.

In .net, assuming you're talking to sql server, you just do something like new SqlConnection("server=foo;database=bar") and you get it all, connection pooling and everything. It's all most people need, but I doubt more than a select few have the slightest clue what's going on in the background (I sure as hell don't).

Xml parsing is another very similar example of how java is a fair bit more complicated but also much more flexible (which possibly is unnecessary).
 

rookie1010

Senior member
Mar 7, 2004
984
0
0
thanks once again for the insight

but you can use things like webservices to get a decently high level binding between java and .net.

you mean that in a single application, i can use both java and c#, what is a high level binding?

why do you say it is the runtime that matters?

 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Depends on your definition of "single application". If you mean a single executable that results in one process running on one machine, then no. If you mean an application broken into two parts, one running on .net and the other on java and communicating via web services, then yes.

I didn't use "high level binding" in any sort of a technical sense. I just meant that you can, without a ridiculous amount of effort, expose methods from one side that can be called from the other almost as if they were on the same platform. The restriction is that you can pass data objects but not code, so you're essentially reducing the arguments to c-like structures.

I said it's the runtime that matters because that's what executes your code. A compiler for a virtual machine like .net or java isn't quite as fancy as, say, a c compiler (although I guess it could be). It basically translates source code straight into byte code and the majority of the optimization goes on at runtime, instead of at compile time. So microsoft's c# compiler probably produces byte code that is very similar to mono's c# compiler but microsoft's runtime will run the code from either compiler much faster than the mono runtime. Virtual machine optimization is, imho, one of the most interesting things going on in computer science right now and I don't think there's any open source implementations that are on par with the big commercial ones (ms, sun, ibm, bea etc).
 

rookie1010

Senior member
Mar 7, 2004
984
0
0
thanks for yet another insight dude

does the optimization speed up the application. would it also mean less load on the processor and hence low usage of battery (good for applications on the phone)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
I can't think of any purpose for optimization other than to speed an application up :p

Jvms on phones do not tend to use just-in-time compilers (they require too much memory) so optimization is a whole different bag there. They just interpret the byte code.