Discuss Scratch

BookOwl
Scratcher
1000+ posts

Which is faster, Java or Python?

Which is faster, Java or Python?
CatsUnited
Scratcher
1000+ posts

Which is faster, Java or Python?

Java probably. Python is pretty slow as far as I heard.
iamunknown2
Scratcher
1000+ posts

Which is faster, Java or Python?

CatsUnited wrote:

Java probably. Python is pretty slow as far as I heard.
It isn't about programming languages. It's about the interpreter/compiler.

It's like asking “Which is faster for reading? English or French?” it depends on the person and their education.

Last edited by iamunknown2 (June 26, 2015 13:24:47)

CatsUnited
Scratcher
1000+ posts

Which is faster, Java or Python?

iamunknown2 wrote:

CatsUnited wrote:

Java probably. Python is pretty slow as far as I heard.
It isn't about programming languages. It's about the interpreter/compiler.

It's like asking “Which is faster for reading? English or French?” it depends on the person and their education.
Java is quite a heavy platform then, so I'm not quite sure.
Znapi
Scratcher
500+ posts

Which is faster, Java or Python?

Java should definitely run faster than Python. Java is compiled into binary .class files, and is run in a virtual machine. Python is interpreted from the source code you write, like Scratch does behind the scenes.

iamunknown2 wrote:

CatsUnited wrote:

Java probably. Python is pretty slow as far as I heard.
It isn't about programming languages. It's about the interpreter/compiler.

It's like asking “Which is faster for reading? English or French?” it depends on the person and their education.
I'm confused as to what you mean. Are you saying it depends on their implementation of the Python interpreter or Java VM?
Firedrake969
Scratcher
1000+ posts

Which is faster, Java or Python?

Sometimes Python is compiled (such as in .pyc files)
bobbybee
Scratcher
1000+ posts

Which is faster, Java or Python?

Firedrake969 wrote:

Sometimes Python is compiled (such as in .pyc files)

.pyc isn't actually compiled — it's just turning the python plaintext into Python bytecode. Granted, this does give a speed boost, but it's not due to compilation – it's simply that there is no need to parse the source code anymore. In fact, CPython, one of the most popular Python implementations, doesn't have a way to interpret python directory. If you notice, pyc files are generated when you interpret Python code… because that's how the Python interpreter internally works!
Firedrake969
Scratcher
1000+ posts

Which is faster, Java or Python?

So compilers optimize as well as compile?
iamunknown2
Scratcher
1000+ posts

Which is faster, Java or Python?

Znapi wrote:

Java should definitely run faster than Python. Java is compiled into binary .class files, and is run in a virtual machine. Python is interpreted from the source code you write, like Scratch does behind the scenes.

iamunknown2 wrote:

CatsUnited wrote:

Java probably. Python is pretty slow as far as I heard.
It isn't about programming languages. It's about the interpreter/compiler.

It's like asking “Which is faster for reading? English or French?” it depends on the person and their education.
I'm confused as to what you mean. Are you saying it depends on their implementation of the Python interpreter or Java VM?
Yep.
iamunknown2
Scratcher
1000+ posts

Which is faster, Java or Python?

Firedrake969 wrote:

So compilers optimize as well as compile?
Compilers are smart nowadays, as they convert your Java into machine code.
iamunknown2
Scratcher
1000+ posts

Which is faster, Java or Python?

CatsUnited wrote:

Java is quite a heavy platform then, so I'm not quite sure.
The people who criticise Java with the “heavy” problem are C/C++ developers - C is quite fast, as most implementations of it require you to compile the program into machine code before running it. On the other hand, MOST Java compilers compiles on the go - it only compiles when it needs to!
blob8108
Scratcher
1000+ posts

Which is faster, Java or Python?

This StackOverflow question is informative. Java is JITed, so it can be a bit faster for some things. But if you want your Python code to run faster, you can just use PyPy, which is a JIT for Python.

In practice, the difference between Java and Python is not that massive: they're both a lot slower than C, for example. Pick which of the two you prefer based on the language, not speed.
__init__
Scratcher
1000+ posts

Which is faster, Java or Python?

They're both slow.
irvinborder
New Scratcher
2 posts

Which is faster, Java or Python?

There is a general problem with this question in that it is too absolute. It does not really make sense to say “language X is faster than language Y”. A computer language itself isn't “fast” or “slow” because it is merely way of expressing an algorithm. The actual question should be something on the order of “why is the implementation X1 of language X faster than implementation Y1 of language Y for this particular problem domain?”

Some speed differences are certainly going to fall out of the language itself as certain languages are easier to implement certain domains than others. But much of what makes an implementation fast isn't the language. For instance, you can't really say "Python is slower than Java" without considering whether you are talking about CPython, IronPython or PyPy. This is particularly true for languages that use a VM as the speed is going to be directly impacted by the quality of the VM.

http://net-informations.com/python/default.htm

Last edited by irvinborder (Oct. 16, 2019 06:29:01)

TheAspiringHacker
Scratcher
100+ posts

Which is faster, Java or Python?

irvinborder wrote:

There is a general problem with this question in that it is too absolute. It does not really make sense to say “language X is faster than language Y”. A computer language itself isn't “fast” or “slow” because it is merely way of expressing an algorithm. The actual question should be something on the order of “why is the implementation X1 of language X faster than implementation Y1 of language Y for this particular problem domain?”

Some speed differences are certainly going to fall out of the language itself as certain languages are easier to implement certain domains than others. But much of what makes an implementation fast isn't the language. For instance, you can't really say "Python is slower than Java" without considering whether you are talking about CPython, IronPython or PyPy. This is particularly true for languages that use a VM as the speed is going to be directly impacted by the quality of the VM.

http://net-informations.com/python/default.htm
This is a good answer, but this topic is from 2015. You shouldn't post on inactive topics (necropost).

Powered by DjangoBB