LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-31-2005, 05:20 PM   #1
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445
Blog Entries: 9

Rep: Reputation: 48
Java questions


Is Java a compiled language? How does the Java Runtime Evrionment do anything then, since if Java is compiled, there will be binary files. Right?

Also, whats the relation between Java and Javascript?
 
Old 12-31-2005, 05:34 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Java is compiled into byte code, which is then interpreted by the Java Virtual Machine (JVM).

There are also "Just in Time" compilers which, instead of interpreting and executing the byte code, compile the byte code into native code and pass it to the OS for execution.

In addition to the byte code from your own classes, Java also provides its own built-in classes. You can consider the combination of JVM (byte code interpreter) + all the standard runtime classes as the "Java Runtime Environment" (JRE).

When someone executes your Java program, they need a (JRE == ((JVM || JIT) + standard run-time classes)).

All of the above, of course, is also pretty much 100% applicable to .NET.

And none of it's applicable to JavaScript. Netscape changed the name from "LiveScript" to "JavaScript" at the last minute, for purely marketing reasons. Java and Javascript have little or nothing in common, except the name and except for somewhat C-like syntax.
 
Old 12-31-2005, 05:45 PM   #3
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
what is byte code? is it programmer readable? Why would one do programming this way as opposed to straight binary code(a la C, C++)?
 
Old 12-31-2005, 06:11 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"Portability" is the big reason.

Other benefits include the ability to dynamically load at the class-level (instead of just at the library level), the possiblity of real-time ("Hotspot") performance optimization and (another biggie) automatic memory management/garbage collection. Compactness (especially important for distributed/web based apps), security (ditto) and flexibility (another variation of the "dynamic loading" argument) come to mind.

Again, the pros/cons for Java are almost indistinguishable from the pros/cons of .NET.

Here are some links that might help:

http://en.wikipedia.org/wiki/Bytecode

http://cem.colorado.edu/archives/fl1997/matt.html

http://docs.msdnaa.net/ark/Webfiles/WhitePapers/CLR.pdf

http://www.unix.org.ua/orelly/java-ent/jnut/ch01_02.htm
 
Old 12-31-2005, 06:19 PM   #5
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Byte code is machine readable, not human readable. One of the main reasons for doing it is to abstract away the OS specific stuff so that code compiled on one platform, can run on any platform that the JVM will run on. Because the JVM takes care of memory management, it also removes the need for things like pointer manipulation.

I'm generalising - of course there are exceptions and disadvantages in the real world, but it has worked well on many of the projects I've been involved in.
 
Old 12-31-2005, 06:19 PM   #6
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Quote:
Originally Posted by microsoft/linux
what is byte code? is it programmer readable? Why would one do programming this way as opposed to straight binary code(a la C, C++)?
Java bytecode is instructions for the Java virtual machine, which is kind of like machine code, but more abstract. It has the advantages that it is compiled, so that it only represents the instructions and so many languages can be compiled to it; while at the same time it is not specific to any specific processor or machine architecture, but can easily and quickly be run on any processor architecture using the Java virtual machine.
 
Old 12-31-2005, 06:28 PM   #7
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
so Java is compiled though(or at least, kind of compiled)? Are there open-source "compilers" for linux? or do we have to use Suns'?
 
Old 12-31-2005, 06:34 PM   #8
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Yes, there are:
* GCJ
* Jikes
But some new Java features might not be supported
 
Old 12-31-2005, 07:15 PM   #9
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
And don't forget the Kaffee JVM:
http://www.kaffe.org/

or the Blackdown compiler:
http://www.blackdown.org/

I would argue that Sun has done a pretty decent job of balancing making Java an "open" standard, yet keeping it stable and well managed.
 
Old 12-31-2005, 07:31 PM   #10
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
Ok, thanks. I was mostly curious, seeing as I'm planning on being a CS major, and Java is pretty prevalent.
 
Old 12-31-2005, 08:13 PM   #11
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Most popular programming languages...

Here are two links you might want to check out:

http://www.tiobe.com/tpci.htm

http://www.dedasys.com/articles/lang...opularity.html

Neither of these sites necessarily *mean* anything in terms of the question "which programming language will be of most use to me five years from now?", or even "should I be a CS major ... or go into Business ... or French Literature?" But they're definitely both interesting reading ;-)

Happy New Year .. PSM
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
More Java Questions Matir Programming 4 03-07-2005 04:42 PM
Questions in regards to learning C, C++ and Java... eBopBob Programming 8 12-21-2004 10:09 AM
Want to use Emacs for java but have a few questions vdogvictor Programming 5 06-26-2004 12:02 AM
2 Questions: java calling system commands? PERL vs Java? randomx Programming 28 11-28-2003 08:24 PM
Questions about Java wh33t Programming 2 11-03-2003 04:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration