performance differentiations between interpreted languages

General discussions related to Python.

Moderators: KDoiron, ChrJim, mawe, python

performance differentiations between interpreted languages

Postby bsod1 on Tue Mar 09, 2010 11:36 pm

I really wonder, how can Java be this faster than Python, while both of them are compiling, and then interpreting by a virtual machine? :?
bsod1
New Python User
New Python User
 
Posts: 41
Joined: Sat Nov 28, 2009 2:23 pm

Re: performance differentiations between interpreted languag

Postby waz on Tue Mar 09, 2010 11:54 pm

bsod1 wrote:I really wonder, how can Java be this faster than Python, while both of them are compiling, and then interpreting by a virtual machine? :?

What? You might want to post the machine specs, the code you're benchmarking with, and any other special considerations...
҉ 囧 ҉
waz
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 1348
Joined: Tue May 05, 2009 7:02 pm

Re: performance differentiations between interpreted languag

Postby bsod1 on Tue Mar 09, 2010 11:56 pm

waz wrote:
bsod1 wrote:I really wonder, how can Java be this faster than Python, while both of them are compiling, and then interpreting by a virtual machine? :?

What? You might want to post the machine specs, the code you're benchmarking with, and any other special considerations...
What? I mean, in general, not in my code and machine, it's common that Java is faster and faster than Python, I wonder, why(because working logic is same)?
bsod1
New Python User
New Python User
 
Posts: 41
Joined: Sat Nov 28, 2009 2:23 pm

Re: performance differentiations between interpreted languag

Postby waz on Wed Mar 10, 2010 12:20 am

bsod1 wrote:
waz wrote:
bsod1 wrote:I really wonder, how can Java be this faster than Python, while both of them are compiling, and then interpreting by a virtual machine? :?

What? You might want to post the machine specs, the code you're benchmarking with, and any other special considerations...
I wonder, why(because working logic is same)?

Dynamic typing is usually slower. Interpreting is usually slower. The trade off is productivity.

http://en.wikipedia.org/wiki/Type_system#Dynamic_typing
http://en.wikipedia.org/wiki/Interpreted_language

For example, since Python doesn't make you say "this variable is going to be an int an only an int" it has to check what type the variable is before using it when it sees it.

There are many hits on Google for "Python vs Java" if you're interested in further reading.
҉ 囧 ҉
waz
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 1348
Joined: Tue May 05, 2009 7:02 pm

Re: performance differentiations between interpreted languag

Postby bsod1 on Wed Mar 10, 2010 12:45 am

I'm not looking for a py vs java article,

OK, let's ask in a different way, how can Java code run faster than CPP code, while Java code is first compiling and then interpreting?!
bsod1
New Python User
New Python User
 
Posts: 41
Joined: Sat Nov 28, 2009 2:23 pm

Re: performance differentiations between interpreted languag

Postby octopez on Wed Mar 10, 2010 5:32 am

OK, let's ask in a different way, how can Java code run faster than CPP code, while Java code is first compiling and then interpreting?!

Depends on WHAT you want to achieve.
For small stuff, Java is slow. But if it runs on a server 24/7 it's fast. Then the garbage collector and the hotspot engine is faster than C/C++ (Java needs to "warm up" first).
It's always depending on what you're doing.
If you have a wxPython App it starts a lot faster than a Java Swing app, because Python is calling the wxWidgets DLLs and they are binary and damn fast. Same for Pygame (calling SDL, a C written lib). Java can not be that fast in such cases.
But if you have a server (read as enterprise) application it performs very good, because Java compared to C/CPP, does not need so much instructions for requesting and freeing memory (an advantage of the garbage collector). The GC just takes a bunch of memory and works with it as it's needed, independently from the systems memory usage and handling.
The hotspot engine meanwhile keeps looking, where it can change the interpreted code to run faster and faster.
waz wrote:The trade off is productivity.

And that's what it's all about. I can deal with having an app that's a little (speak as milliseconds) slower if I can finish it in a tenth of the time I would need doing it in Java and a 30th of the time I would need in Cpp (including memory leaks).
Regards,

Octopez.
User avatar
octopez
Python Heavy Programmer
Python Heavy Programmer
 
Posts: 243
Joined: Sun Aug 23, 2009 11:28 am
Location: Europe, Austria

Re: performance differentiations between interpreted languag

Postby bsod1 on Thu Mar 11, 2010 12:00 am

Well, thank you, let me think about it :P
bsod1
New Python User
New Python User
 
Posts: 41
Joined: Sat Nov 28, 2009 2:23 pm


Return to Python General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Dreamlink Web hosting and Traduzioni Rumeno Italiano and ASSP Deluxe for cPanel.