Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 16th, 2005, 8:57 AM   #1
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile Java vs Python and C++

I am looking at Java and Python and like to know if Java is an interpreted language. What are its benefits over a language like C++?
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Aug 16th, 2005, 9:12 AM   #2
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Java is a strongly typed, compiled language. Learn C++ or Java before Python. Google C++ vs. Java for more information about their differences.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Aug 16th, 2005, 9:58 AM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The ostensible benefit to Java (aside from language-utility issues) is that it compiles to byte-code. Machines which have a JVM (java virtual machine) then map the byte code to the appropriate machine instructions. This supposedly provides a "write once, run anywhere" capability, no porting issues. All JVMs are not created equal. As Grumpy has said, it sometimes results in a "write once, debug everywhere" situation. MS's C#/VB ala .NET entree (I'll take Eggs Benedict, thank you) is supposed to capitalize on the same approach (distributable byte code or whatever name is the flavor of the day) and it would be great for El Bill if he could succeed well enough to make substantial inroads on the Java market.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 18th, 2005, 5:38 PM   #4
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
Another benefit of Java over C++ (specifically) is that while they're both C-derived object oriented languages, Java is a bit neater and simpler. C++ has been accused of being a bag on the side of C - i.e. a big lump of irrelevant extra features - and while this isn't necessarily fair, it's certainly not as neat and 'pretty' (for want of a better word) as Java.

C++ is a bit of an industrial strength language. I suppose Neal Stephenson might call it the "Hole Hawg" of programming languages. Java is a bit like a cute, cut-down C++, lacking features like operator overloading and multiple inheritance. The absence of these features could be good or bad - depending on who you ask - but there's no denying it's simpler and therefore ought to be easier to learn.

As a beginner's language, I'd recommend Java over C++. Both are commercially and practically reasonable first choices, and Java's simplicity and essential similarity to C++ make it the better of the two in my opinion. Even little things like having a universal, standard abstract windowing toolkit (for creating GUI applications) rather than a whole horde of competing ones makes it more appealing to a newcomer.
mackenga is offline   Reply With Quote
Old Aug 19th, 2005, 4:52 PM   #5
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
Smile

Thank you very much for the nice answers! I am still a little confused.

I know that C++ code compiles and then links to give an executable file (.exe). Python compiles to a byte code and is then interpreted. Is Java more like Python or more like C++?
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Aug 19th, 2005, 4:54 PM   #6
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
It's more like C++ in my mind, but i wouldn't trust my mind.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Aug 19th, 2005, 7:29 PM   #7
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Quote:
Originally Posted by Dietrich
Python compiles to a byte code and is then interpreted. Is Java more like Python or more like C++?
Python interprets on the fly I believe, no compilation. Java on the other hand, compiles the source code to byte code which can be run on any machine with the Java Virtual Machine installed (linux, MacOS, or Windows). Usually, java executables end with .class or .jar. However, it can be wrapped into an exe but it still needs the JVM.
OpenLoop is offline   Reply With Quote
Old Aug 20th, 2005, 6:58 PM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by OpenLoop
Python interprets on the fly I believe, no compilation. Java on the other hand, compiles the source code to byte code which can be run on any machine with the Java Virtual Machine installed (linux, MacOS, or Windows). Usually, java executables end with .class or .jar. However, it can be wrapped into an exe but it still needs the JVM.
Close. If I may be needlessly pedantic, Python is a dynamically compiled language, rather than an interpretted language (such as QBasic). When Python executes a script, it first compiles the program into object code, which it caches as a .pyc file. It then uses this object code to run the program.

This makes it faster than interpretted languages, since it only reads through the user's code once. After that, it uses the intermediate object code to determine what to do.

Java, on the other hand compiles into low level bytecode, rather than higher level object code, and this probably gives it a benefit in speed.

Correct me if I'm wrong, but I believe Java can also be compiled to native machine code using gcj. Once that's done, the JVM isn't needed (although the Java SDK is needed for compilation).

Python, on the other hand, can only currently be turned into an exe via a wrapper, such as py2exe. And that's not exactly a neat and tidy process

Quote:
Originally Posted by Pizentios
It's more like C++ in my mind, but i wouldn't trust my mind.
Java is very much like C++. I believe it was designed that way, in order to attract C++ programmers to the language, since C++ was the most popular Object Orientated language at that time (and might still be).

Python, on the other hand, has more in common with ABC and Modula 3, at least according to this diagram. As a language, Python has a more advanced syntax than Java, but tends to be slower to execute.

( Programming Languages are something of an interest of mine )

Last edited by Arevos; Aug 20th, 2005 at 7:03 PM. Reason: correction
Arevos is offline   Reply With Quote
Old Aug 20th, 2005, 9:21 PM   #9
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Quote:
Originally Posted by Arevos
Close. If I may be needlessly pedantic, Python is a dynamically compiled language, rather than an interpretted language (such as QBasic). When Python executes a script, it first compiles the program into object code, which it caches as a .pyc file. It then uses this object code to run the program.

Correct me if I'm wrong, but I believe Java can also be compiled to native machine code using gcj. Once that's done, the JVM isn't needed (although the Java SDK is needed for compilation).
Didn't know that Python compiles, but it still slow compared to Java and too slow compared to C++. See my thread where i made a small comparison
Thanks for the info and the GCJ link.
OpenLoop is offline   Reply With Quote
Old Aug 20th, 2005, 11:49 PM   #10
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5 grumpy is on a distinguished road
Java (like any language, actually) can be compiled to native machine code if someone puts in the effort to write a suitable compiler. In practice, Java is usually compiled to java bytecodes, which implies a need for a JVM to interpret them.

Strictly speaking, Java can be dynamically compiled (just look up topics like JIT [Just In Time] compilation). Like Pyton, it blurs the distinction between an interpreted language and a completely compiled one.

I would say that Java has little in common with C++ although, syntactically, it looks rather similar. It does well in some niche areas (eg rapid prototyping, applications that can run in a web browser), but those areas are rarely targetted by C++ programmers. It also forces programming in particular styles, regardless of what one is trying to do, which tends to rub experienced C++ programmers the wrong way. Java is significantly simpler than C++ (which is either an advantage or a disadvantage, depending on what you're trying to do). The reliance on garbage collection makes life easier for the programmer for some types of work (eg without gc, it would be very difficult to write non-trivial web applets), but makes it much harder in other ways (eg unpredictable performance hit makes Java less suitable for hard real time or mission critical applications, even if the RT java extensions are employed).
grumpy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:12 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC