On performance in different sources they write different things, in some that Python is ten times slower, according to other sources of the same order. In general, what are the disadvantages of each other? In Python, as I understand it, there are more different chips, but dynamic typing is confusing, it seems inconvenient (never used). In general, the collection of opinions)
Closed due to the fact that off-topic participants Nick Volynkin ♦ , Visman , aleksandr barakin , insolor , Peter Olson 26 Aug '15 at 9:02 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- " Questionnaires are forbidden on Stack Overflow in Russian . To get an answer, rephrase your question so that it can be given an unambiguously correct answer." - Nick Volynkin, Visman, aleksandr barakin, insolor, Peter Olson
- oneprobably you meant not the language itself, but the existing compilers and interpreters)) - megacoder
- 2Here's a similar question on SO: stackoverflow.com/questions/4559618/about-speed-python-vs-java - cy6erGn0m
- oneAnd in general, where is the question from? I can not imagine that somewhere there was a question of choice between them. It all depends on the task. The task and determines the answer to this question is quite clear. - cy6erGn0m
- oneand most importantly, let's think about why and why the language was made of strictly dynamic typing? and compare with what I wrote above and what caused a storm of emotions? - alexeych
8 answers
The language itself does not have such characteristics as speed of execution. Important means of execution time.
- CPython is interpreted and is usually slower than Java, especially if JIT is used in Java compilation;
- JYthon is interpreted in the JVM and is not different in speed from Java;
- Cython is compiled into native code and surpasses Java in speed.
- onein addition: during JIT compilation, the code is compiled while the program is running, when it is in demand, then it is cached and used when next needed, so the first click on the button takes a little longer than the next. - megacoder
- But about the third point in more detail .. I have never seen a python somewhere faster than Java except for tests less than 300 ms long - cy6erGn0m
- oneCython, judging by what glimpsed, is not a python (a tool for writing c-extensions for python). Doubt is caused by line 2 - jython (in the last century jpython). I don’t know how it is now, but earlier a python with numeric overtook java on calculations, since heavy enough library functions are written in c. Well, the issue of static typing in java is quite subtle due to oo inheritance. - alexlz
- It is necessary to count productivity not in times, but in "acceptable / unacceptable"
- The motto of the development of programming languages and techniques starting from the 50th: How to reduce the development time / change programs, while maintaining an acceptable speed of program execution and memory consumption . There is still no universal recipe, because, on the one hand, iron never had infinite speed and memory size, and on the other hand, as the program's complexity increased (and as a result, the number of developers increased), there were difficulties to ensure an acceptable quality of development.
- Dynamic typing is designed (and increases) the speed of development. At the expense of - reducing the effectiveness of the program. And with an increase in the size of the program and the number of developers, measures to ensure an acceptable quality of development can eventually equalize the overall speed of development ( exaggerated - we write in Python as if in Java and divorce the bureaucracy of the approval process, etc. ).
The minuses-pluses in the end are the same qualities of PL.
For example, like this:
Java:
Minus - static typing
Plus - static typing
Python:
Minus - dynamic typing
Plus - dynamic typing
These are the cons they have relative to each other
- Somehow it all became incomprehensible at once. Even what seemed to be more or less clear. And why dynamic typing is designed to increase the speed of development. Not a fact at all. (Well, how to put down cons-pluses, so in general - fog). And where does the bureaucracy of the process? Those. that when using a bureaucratic process, the use of OOP does not lead to serious increases in overhead costs, I read. But comparing java-python here what side? - alexlz
- one1. The speed of development, especially of simple applications, is another fact that has already been tested by generations of programmers. Moreover, from the reverse - if it were not for the fact - there would not be any popular PL with dynamic typing at all. 2. Folding the pros and cons of a spoon and a hammer - yes, the matter was initially vague. Disadvantages - this is a continuation of the merits or "you have to pay for everything." 3. OOP - in general nothing to do with what he said. 4. "Java or Python" - the cardinal difference between them - in the form of typing. The rest is the effect. If "Java or C #" or "Ruby or Python" then the answer would be different. - Skynin
- and if you pay attention to the purity of static (type conversion in java heir-> ancestor-> heir)? And, by the way, life here set an interesting experiment. How many libraries of any container classes were there before, and how many remained after introduction to the template language. :) And the PLO was mentioned solely because of the incomprehensible reference to bureaucratization. And yet, the serious differences between java and python are not just typing. One of the others is snake functionality. Well, you can also see Norvig's slides about design patterns in dynamic languages. - alexlz
If taken in pure form, then
Pros Java:
- Execution of Java bytecode is orders of magnitude faster than the Python interpreter.
- Static typing in Java helps to catch a multitude of errors at the compilation stage.
- The PLO in Java is very well developed, compared to the rather strange implementation of classes in python.
- non-weak debugging capabilities in modern IDE sharpened for Java (netbeans, eclipse, IDEA).
Pluses advantages:
- scripting language does not require compilation, therefore you can view the result instantly after making changes.
- a bunch of nice buns in terms of syntax, type of array slices and other features for working with collections.
Total In each case, the problem is solved by a set of advantages, or even the presence of only one advantage. Often, a little changing and demanding in terms of speed of implementation of the project turns on Java. and frequently modified components are made on python. By the way, a similar approach is often used in toys: the basis and graphics are written in C ++, and the game logic is written in Python, Lua.
Ps. I agree to the account C # - smart descendant of sishka + great IDE. But it has a lot of disadvantages like any MS product. Platform-dependent, fairly expensive, the prospects depend only on the MC policy. Non-software flaws ts :)
- java: 1. The loss of performance in the serpentine interpreter can only be explained by the impenetrable dullness of serpentine breeders. I do not believe. :) 2. Discussed nearby. 3. Strange and unconvincing argument (about the best elaboration of Org. Liberation of Palestine) 4. In the python debugging tools (due to interpretation) are very, very (by the way, in the listed tools is it possible to debug python code?) Python: 2. probably all this - not "syntax buns" :))) C # - rather strange characteristics (and standards like there are not from ms) - alexlz
- 2alexlz, learn assembler, and do not engage in beliefs. You need to know what the method call turns to in Java and Python at runtime, then you will understand why any dynamic dynamics is static. The advantages of python are not disclosed, there are not just buns, but operator redefinitions, multiple inheritance, metaclasses, lambdas, context managers, decorators, etc. By the capabilities of the Python language, you need to compare it with Haskell or Scala, and not with Java. In general, the picture is typical, the majority of young programmers know one language at best, and they take to talk about a very different language and implementations. - Skynin
- If it's not a secret, which assembler should be studied to understand the above? "Autocode BM-4/220" is suitable? And according to the possibilities (not according to the graphic properties), different languages are approximately equal, because the same task (theoretically) can be solved in very many languages (those that cannot be - leave out of the box, not them) - alexlz
- onealexlz, assembler - any. The question suggests that you do not know any. 2. Write yes, everything is possible in machine codes. Once you ask a question about the existence of programming languages on top of machine codes, they did not understand this question either. - Skynin
- Well done! Ok, I already set it. (But still, what does not suit the assembler for the 8051?) - alexlz
Try to solve a couple of simple tasks, first in one language, then in another. It is necessary to use both languages at the same time, one for more labor-intensive tasks, the other for any small things, like parsing logs :-)
One of the main advantages of python is that it has an insane amount of any extensions. The external numpy and scipy libraries implement heavy math, and all control constructions in python. The result is a symbiosis of speed of execution and the beauty of the code. On the other hand, java is tied to hardware, only the JVM should be
- oneYeah, and the python is not tied to the hardware, shouldn't there be a CPython VM? And the number of Java libraries will completely shut up the Python belt. - Vladimir Gordeev
- Yeah, by the number of libraries it’s not with Java :). Python has an indisputable advantage in the speed of writing (according to estimation - from 2 times to 10 vs java). Accordingly, in time-critical applications - the python can be used to write prototypes, tests and study java :))). Well, jython - java salvation in the 21st century (quoted from www.jython.org - alexlz
Always wrote on C and Shell. Now I study java (work got) on Gosling. For some reason I do not like it, especially the streams. And in general, too much abstraction is not immediately obvious (apparently due to a lot of inheritance and method overrides) how this will work. It seems that the main thing is not to solve the problem effectively, but to create for them a set of universal tools, then to make new tools from them, etc.
- oneThat's just the flows that are made mega-awesome, especially compared to the native junk;) You just have to know how to work with the flows and write whole books on this topic separately. Regarding abstraction: read classic books about application architecture and then you will understand why classes and abstractions are needed. And more advice - do not trust Gosling. Gosling is an artificially promoted character. - cy6erGn0m
- one"Mega-awesome" is from Hansen's article "JAVA'S INSECURE PARALLELISM"? citeseerx.ist.psu.edu/viewdoc/ ... And about abstractions in OOP, this is for specialists. www.dreamsongs.com/Files/PatternsOfSoftware.pdf. With abstractions there must be more careful ... - alexlz
- oneWell, you would have found the source in the 65th year. Do you know how much water has flowed in 12 years? Even in Java, a lot has changed over the years. - cy6erGn0m
- oneYes, but ignoring the quarter-century experience of working on the problem didn’t prevent the developers of Java :). And, by the way, a lot is what, if specifically, (out of curiosity, honestly). - alexlz
- oneTo @ cy6erGn0m. If possible in more detail about the comparison with the "native junk." Do not think that I cling, really interesting. And why do separate books write about working with a simple, essentially thing (parallel sequences of commands, shared memory, locks)? - avp
I use both, just for different purposes. As stated above, Java as the basis of the application, various "tasty" modules on python. For example - we write for the needs of the EvaluationEngine application. The interface, the factory and the context structure are set on Java - everything is strictly and the implementation will not change. We write on python, everything is very simple due to human syntax. And the most delicious thing is that you can create so-called python. named rules are functions that are external to your program, which can then be used at runtime WITHOUT recompiling the entire project. The customer already squeaks - every whim in 5 minutes (and your money)
1 - Dynamic typification is an incredible evil. You will understand after poddebazhish assignment of a line to intu which falls once out of ten.
2 - The speed of your program, oddly enough, now few people care about now if it fits within a reasonable framework.
3 - C # is better :) Strong typing + plush
- one1 - Not true. - Vladimir Gordeev
- onetrue true. dynamic typing assigns type checking to the execution stage and not to the compilation stage. Compile errors are much simpler to fix than ClassCastException. - Andrew Frolov
- to Andrew Frolov: 1. About the incredible evil - I liked it. Down with the toad, c ++, c # and all obedo-oriented programming (objections are accepted only with the decoding of the term RTTI). 2. Ie reasonable framework still have a place to be? 3. "Better than Georgians"? (By the way, there is a python there too. And even an iron one) - alexlz
- Not true. Non-conformity types are pretty typical error and are usually quickly corrected during the testing process. Trifle. - Vladimir Gordeev
- oneKinks are not necessary. Testing (at an acceptable cost) is far from catching errors. And if the error manifests itself during operation - this is not a gut. So without extremes, please. The situation is seriously affected by the complexity of the project and the qualifications of the developers. Personally, I prefer static typing, but I do not consider dynamic "incredible evil." (And, by the way, do many coders have the rule: "not a single compiler when compiling"?) - alexlz