General discussion


then need of portabality

By rohitkar ·
java ssems to be sellling mailny for the reason
of portablity and bytecode advantafges.
but i heard some experts question the need
portability. can u explain this whole concept of portablility and language independence.
also advantages if any like thses expersts say of java?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

then need of portabality

by TimTheToolMan In reply to then need of portabality


When a program is compiled, say a C++ program, the result is an executable that is specific to the CPU that it was compiled against. That means that a C++ program compiled on a PC cant run on say a Mac because a Mac has a different CPU to a PC.

When a Java program is compiled, it produces the bytecode file you mentioned. This isn't specific to any CPU and has to be further interpreted at runtime to be able to run.

It is interpreted by the "Java Virtual Machine" (or JVM) which is another program that knows what to do with that bytecode. On a PC, the JVM interprets the bytecode and does things with "windows", whereas on a Unix box, the JVM might do equivalent things with Motif - kind of windows for unix.

That makes the java code portable.

One of the problems with java is that its much slower than a "native executable" because of the need to interpret each command as its executed.

The need for portibility is an interesting question. Some programs are really designedto run on a particular platform like a PC so there isn't a real benefit to it being able to run anywhere else.

Some programs benefit from being able to run on any platform. If nothing else, it doubles the market size for that program for little or no extra work.

...but also means that a program can have "cross platform components" written in the same language. Which is great for support and cost.


Collapse -

then need of portabality

by TimTheToolMan In reply to then need of portabality

Personally I believe that java has succeeded so well in the past because it was a great language to program in. Platform independence is a great concept but rarely used in practice.

Microsoft's .NET technology has taken the best bits of java and C++ and combined them into a new language C#. I reckon this will be the future for many people...

C# is slightly different again. It compiles to an intermediate code (like java) but at runtime is actually compiled to native code (Like C++)

Bestof both worlds.

Hope this helps.

Related Discussions

Related Forums