@@MoveAlongPeasantwhat a foolish comment. Static typing allows the compiler to check a massive amount of possible bugs at compile time rather at run time. If it was worse than dynamic typing why does almost every other major language use static typing. Why is typescript so beloved by developers. You sound like a clueless first year comp sci student.
@@nathaaaaaa yet we still use python for ai. good composition doesn't make stuff good as well. plus, c++ and fortran are just some wrappers for assembly.
first of all, compilers ARE the wrapper itself. second, chil, mofo, calm the f down and read the context, then try to figure out why I would say that to the previous guy. if you can't that's ok, you tried. but remember, everything is a wrapper.
It's crazy because JS has dynamic typing as well and the rules are so much more loose and weird but it's speed is atleast sometimes within an order of magnitude of ahead of time compiled languages.
It's important to clarify what the test is when comparing speeds. Python looks much worse on shorter tasks due to the overhead Python requires on startup. This can be mitigated somewhat when compiling python to .pyc files. At medium tasks, python looks much better. At massive tasks we see the gap widen again, and this can be somewhat mitigated by compiling with optimized bytecode into .pyo files. Dev time is worlds faster for python and it's portability is fantastic. Debugging is all just personal familiarity, because neither are that hard if you work with it. Portability can be matched by few compiled languages, but most include varying levels of additional steps/setup/tests. Fighting over languages is silly, because at the end of the day the reason you use one over the other is because: I'm paid to use [My Language] I like the control/safety of [My Language] I like the syntax/structure of [My Language] I only know [My Language] I'm conditioned to make fun of [Your Language] At the end of the day there are workarounds to alter the standard behavior, mitigate the shortcomings, and interact with most APIs with whatever language you choose. If it's Turing complete, then you just need to get gud, lol.
So true, people love to bicker, but there is a million reasons to choose a certain language for a task. For my projects a few seconds has never been a deal breaker and the development time is most important
6 seconds is not a task where startup time is of any influence, like what? Also I feel like the "we shouldn't fight over languages" is just used to excuse bad implementations. Yes, languages make a difference and we can and should talk about differences of programming languages to learn their use cases and to improve them.
I don't know about this benchmark but I have seen another benchmark that doesn't include start times in it. It just measures the task itself and there Python is extremely slow. I'm sure you can improve it further, but why not using an Language that is also simple to write but much faster in the first place?
You also forgot about the compatibility, Python can easily be paired with fast languages like c or rust. I like to write most of the code in python, and write the important functions in rust, that way my code is fast and easity to read.
@@petrlaskevic1948 yeah, otherwise i wouldn't do it. Most projects don't need to be fast for 90% of the project, and writing 10% of my code with rust makes my code look almost the same (i use maturin/pyo3, which allowes me to run rust functions as python functions), but the code is 100x faster when it needs to be
Funnier fact: Java was made when every computer had their own gimmick so by having 1 JVM you "solve everything". Now computers are more standardized with few relevant combinations while JVM have multiple vendors (OpenJDK, Oracle, ...), multiple versions and multiple word size (you can have a 32bit JVM on a 64bit OS) so Java main feature is now a bug.
I remember one twitter post by Francois chollet(author of keras) in which he says , “The complaints "Python is slow" or "Python is unsafe" seem misguided. The point of Python isn't to be fast or safe, it's to be flexible and hackable, and to interface well with everything else. It has become successful by serving as a frontend from which to call other libraries”
Python *is* compiled to machine code, just on the fly. You can also compile Python to intermediate code just like other languages and this improves the runtime a lot.
technically the actual code is not executed line by line, that would be horribly inefficient, it first gets compiled into byte code which is what's executed "line by line" 🤓 ☝️
things to note is languages like java and c# are also "interptred" or rather use a runtime. but they also have JIT compilers which convert it into the target machine code on the fly
And they doesn't look up names, like class, variables, functions and other scopes during exevution like Python. They do that in compilation stage, not in execution. That is why they are faster and Python slow.
I just wish there was a mode to have it so you can specify a variables type yourself so Python doesn’t have to do it for you. Would significantly speed up run time.
Python's json module is fast because some of it is implemented in C. Also dynamic typing does NOT makes software development easier. Only in the context of a repl it's easier, e.g. for stuff like Jupyter. But when developing serious bigger software you want static typing, even just for refactoring and clearness of APIs etc. Python gives you the speed of a dynamically typed interpreted language with optional pretty lacking typing capabilities that aren't used by all libraries. yay
Yeah for me the biggest downside of Python is it's dynamic typing. I hate it. As a Data Scientist I use it a lot anyway, because I kinda have to, since all the good libraries are in Python, but yeah, I type as much as possible manually anyway (which is possible in newer versions of Python), and having documentation that isn't typed is just annoying. Also IDE's work way better in typed languages, the predictive text is just on a whole different level. Tab is probably the key I press the most when programming in a static typed language, you type 2 letters, and the IDE knows what you mean already.
For our codebase we are using Mypy to enforce types and new 3.11 and 3.12 typing features. is not perfect but allowing parameters to have custom types via "structs" and know the return type of a function (even know if it can return exceptions) is a bless for debuggin stuff
The python ML libraries wrap C++ (or similar) code, which is why real world python isn't that slow. The idea is: python 'interprets' one line then passes off all the heavy lifting to precompiled binaries, so the interpreting time is tiny compared to the execution time. If your code is not doing that you are probably doing somthing wrong. If your code is doing that, in my experiance, it's probably faster than the naive C I would have written becuse the C python is calling is very well optimised.
One of Python's strengths is its use as a front end to libraries like NumPy, SciPy, and TensorFlow, which are written in high-level compiled languages like C and C++. I'm guessing that the particle simulation program Lewis described was written entirely in Python. If it had been written using NumPy, it may very well have been faster than the Java version.
It depends on use case. Remember that Python is de facto standard scripting language for creative software. Where it’s used to produce a lot of lore full functions.
I've said this before. Python is really good for concept builds before using something like Kotlin for the real build. (I decided to use Kotlin as an example because it's stable and compiled)
First of all you have to know why you are learning a language if you have to be a problem solver then you should go with c++ and c. If you want to make a platform friendly application you should go with Java and python✌️
i thied to make a ddos tool with python and it worked but i was pulling 20mbps with 1000 req/s i writed the same code with java and i was pulling 10gbps with 8m req/s
I agree. I love to write code in a line and let the formatter do the job of making the code look nice. But as the formatting of python changes the behavior of it, that's just not possible with python.
And Java can also be considered slow depending on what you compare it to. Also if parts of the Python code is really slow you can create that function in C / C++ and just call it.
Python is always the better second option. But never the first one. Being "easy to code" ends up with lack of knowledge about what are you doing. Magic happens under the hood and then weird and disturbing bugs appears out of nothing. Compilation and type safety is there to minimize human errors.
Type help humans find errors. It ALSO help the compiler make fast compiled code. Python had nothing of that. Languages like Ocaml do have the speed and ready syntax like Python. And you dont need to write the type of all variables and methods unless some fee exceptions. But you can write types in the code if you want to.
In the modern world, coding is not only for developing apps, but just the means to an end. Try downloading and manipulating satellite datasets with C++ or doing ML in any other language without PyTorch or TF and tell me again that it's the second best option.
I mean everyone has to start somewhere... But I do think the field in general has a problem with a lack of trained professionals. There's a certain dicipline required in writing good maintainable code that most people that learned it by themselves just don't have. It's one of the few technical fields where this is commonplace. You don't see a civil engineer without a degree in civil engineering design buildings or roads, but in IT it happens all the time.
Python is not so slow. Python is an interpreted platform and it's most important libraries are writen in C or C++, then, the important stuff is already optmized. Better, the most prevalent source of slowness is I/O, what is SO dependent and/or network bottleneck. This is independent of any language.
Honest question would it make sense to build a system to translate python to C++ or other languages like a google translate for languages to speed up prototyping while maximizing speed
@@user-qw1rx1dq6n theres multiple versions of that. The main issue is preformance and language spesific features. Normally it's more popular to add a final executable script with optimization, but python doesn't have that since it's an interperted language (and the compilers kind of sucks)
optimize the first assignation out because the second one renders the first one useless, if you do something with it prior though, just seperate them into 2 variables, or allocate for the biggest of the 2 types, and replace with the second one (with it being a void*) when you reassign it @@cholobok
tbh, python is just a good language to learn for things that don't need to run insanely fast, like robotics, some web development, and many other things, in robotics in particular i would always use python because it has good support for it and unless you are making something really complicated it's much easier
Dynamic typing SLOWS down development time. It is only for small scripts where dynamic typing feels faster. Static typing is much better for large programs.
Yeah it's the worst part of Python. I don't like dynamic typing at all. It just makes everything way less clear. At least in Python you can type still, but it is just not nice and the fact that it's not enforcable, removes all the predictablility of enforced static variables. Dynamic typing causes so many bugs, it's unreal. I still use Python all the time, but that's because as a Data Scientist you kind of have to, since it's where all the good libraries are, but that doesn't mean I like it.
I mean compilation time has to be considered when you're considering for time to complete a task, but if you're gonna be repeating a complex enough task many thousands of times after the code is written, or a simpler one many thousands of times a second for a while, the compilation times start mattering less and less. That's why some compilers have optimizations that increase compilation time of large programs by several minutes yet performance by a fraction but if you're gonna be running it sparsely, or even run it only once per each time you tweak the code, havin no compilation time matters a lot
For most languages. Ocaml have a fast compiler, and generate code that execute almost in C speed. It is functional and object oriented and have a REPL that compile the code when you load it into the REPL. And it have a full type system that do hard type check. But you mostly only need to write types when you like, for clarity and a few cases when it can resolve to different types. Which is rare.
Dynamic types do NOT let you program faster, they just lower the barrier to entry and make it easy to do really stupid things for no good reason. Especially when you can still have type inference and static typing. Idk, dynamic typing held me back for a while and prevented me from learning important concepts bc it was always too easy to just use python. I learned Nim a while ago and write way better code as a result, regardless of what I'm using now. I can do way more, with far less debugging compared to dynamically typed languages.. It feels closer to test driven development, if anything. Nim's the first thing I reach for when thinking of what to use to build something with because I can compile tiny little binaries for any system and it actually frees my brain up to think more about orienting my design around data, not classes.
As someone who used to develop in R, I noticed a very bad performance in python to execute simple tasks like plotting or transforming data. I don’t like neither, but in the end they are useful to integrate with other faster APIs written in C/Fortran
The language has not the properties to be sble to make fast code. Unless you change syntax and most important semantics of the language. It depends on looking up names, like classes, metjods and cariables, in tables during exevution, which make it slow. These tables are representing the scope of the language. And to make fast code, you really need type information. Which is really hard to get from Python. Better to change language after prototyping in Python if you need speed and security of type checking. Look for Ocaml and make a serious go, if you want to know what I mean.
@@AndersJackson i really appreciate your reply and i liked it Also i recommend learning go because its a compiling language, i mean the code need to be compiled to run like c# And C++ etc... Go is a pretty good language its close to python in the syntax and a i recommend learning python to understand the programming languages and the computer language at all and then go to GO language.
You don’t know how to write the modern python code. It doesn’t force you to do it correctly but you should be experienced enough to do things pythonic way that is use types, pydantic, asynchronous await so on whereever it is needed which speeds up the code and also makes debugging much easier
It’s important to remember that slow also means energy inefficient. As engineers we have an obligation to the planet. We have an obligation to build systems that are as efficient as they can be made to be. Languages like Java script and python are horrible when you consider their environmental impact.
@@Awesomesauce0096 I’m not arguing that we should abandon technology. I’m arguing that we shouldn’t solve software engineering problems with pollution, but rather with thought.
You exhale co2, you know what to do about that. It's like people in 1800 worrying about manure build up or food running out. Technology overcame it. If anything these python people seem first to get to the AI scene that will set up a comfy future for you nervous Nellys
@@kapytanhook “exhale co2” try harder, this argument is a straw man. But it is also true that in order for humanity to survive we will need to radically reduce the human population. Hopefully this can be done in an orderly manner. Also, I’m not arguing that inefficient tools aren’t useful - they are. But… it is immoral to deploy them at scale. For example the cost of Python is typically considered to be 30x. That is unconscionable.
@@user-pe7gf9rv4mwhy? It’s the most common language if you are seriously interested in most CS fields python is necessary to learn. If you are so bad at python maybe you just don’t know how to code
The take away is that you should use the right tools for the right task. Build your components in c and your interface in python. Get the best of both worlds.
Yeah Static is faster imo. The predictive text gets way better when you're in a static typed language, you're IDE actually knows what you are doing. I actually write the name of a method/function exactly once fully when I'm programming, after that you just tab through.
As a developer, Python is much much much harder to debug than C, C++, or Java are. I have worked on some large Python projects. They were absolute nightmares to deal with, nothing has a reason , but everything happens (i know it doesn't make, but it is what i felt debugging it)
really? I just build web servers, but back end skeleton system tell you the error 99% of the time, line to go to, and how to fix it... Java looks so messy to me, I hate it. Here some random variables a,b,c,x, alien signs.
@@calamity3007 Em... You are not really interfacing with Python, you are using a Python binding to the backend, which is written in other languages. If you are talking about flask or django, they are high level server tools that have python bindings. You are not really writing programs. You are defining jobs to do for the framework using python. Java's error "looks so messy" because the language itself knows exactly which part of itself is wrong and why. It is printing out the call stack to help you understand why it's not working. In python... there are no types. So, you cannot deterministically say a function works or not before it runs. This is drastically difficult to work with if you are working on a larger Python project. Try to write a 50,000 lines Python project yourself. Because I tried to do that and had to switched to C++ half way, best choice ever. Using C++ saved me probably 2 months of development time.
@@Mars86442or you could just use google and quickly research the library which takes a few moments the same amount of time it would take to learn a different solution
The biggest advantage of python for me is that you can run your script on every type of machine/os, personally I only use it for writing pseudo code on my phone
Okay first off Python is still fast. Millions of operations per second fast. Turns out all computers today are super duper fast. It's a good math tool cause it's popular. So people write library code for it, that other people can then use in their projects. It's not all about relative speed with other programming languages. In fact most programmers don't even think about that when they go to choose a language. These speed differences in languages are often so inperceptible at human time scales that to you the programmer they're really not even worth considering. Focus on how you can make your code faster. You're much more likely to notice speed gains by improving your own code, rather than switching languages. It is possible to be inefficient code and end up with slower programs in faster languages.
There is a lot of overhead. When comparing Python execution time to C, C++, C# and Java even, you can clearly see the amount of resources used. Python is a SCRIPTING language, not Programming, since you do not compile the code then run it, it is compiled at runtime, which slows it down.
@@wassafshahzad8618Scripting is about controlling an application, not controlling the computer itself. You can call writing a script programming, but the result is a script and not a program.
@@wassafshahzad8618 It isn't technically, it's scripting, not coding nor programming. The same way one can't claim to be a Shellscript developer por a Powershell developer. It's just not meant to be used standalone on large codebases, it's meant as a complement.. yet people adapted It to do so., I work on such Python codebases and let me tell you, It can become a nightmare yo refactor and scale properly. Also It's heavy ( almost 90% ) relience on libraries to be useful on the mosy básic tasks, brings up dependency hell early. Dynamic typing obscures too much important codebase information, even some advanced LSP, linters AND formatters have trouble parsing complex modules.
@@edwinontiveros8701 I agree with your first para but not completely since programming has evolved and we are no longer ties down to the idea of "scripting" in the Powershell way. Since Python can effectively communicate with other services such as an HTML server even without libraries and frameworks. In response to your second paragraph, which codebase or production server is ont relient of external libraries ? Javascript ? GO ? Rust? All of them are, even JAVA, In java even defining dependencies is hell. I also work on Large python codebases and if you not using type annotations then thats not really python issues they have added types to the standard libraries. Refactoring Python bad code is hell cause python unfortunately does make writing bad code quit easy but its also gives you the4 ability to hook into everything you may need. Every thing a developer working on python can do you can do it too. You can even hook into a classes create function and define relevent features at that time.
@@KanjiasDev Yep you learn this pretty quick in Data Science for example (where everyone uses Python). Don't try to do actual stuff in python. Stick to calling libraries. Don't create a 2d list, create a Pandas dataframe (for example, for the real big stuff you'll probably use spark, but that's a whole different beast). If you don't, you're gonna have a cardiac arrest real soon from all that coffee you're getting while waiting for the code to run.