@@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.
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”
Exactly. The real problem is the way some people misuse Python and other scripting languages as if they were your average compiled language. They're not, as we call them scripting languages for a reason.
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
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" 🤓 ☝️
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.
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
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.
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.
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.
@@AndersJackson Not sure about Java, but C# has reflection which does allow you to call arbitrary code by name, which has become the backbone of several important frameworks like wpf. However personally I hate it because it makes the code way more fragile and you lose a lot of the benefits of the ide when making heavy use of reflection. iirc it's also fairly slow (though normally not enough to be a problem)
am a C++ programmer and i use python daily, i love using it for anything! except code that needs to be fast... prototyping is better in python, web dev, backends, building small tools, etc etc
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.
How to write fast in Python: write as little of your code as possible in Python. I.e. use preexisting functions and libraries whenever possible so that as much code as possible is run in C instead.
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.
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.
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✌️
@@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 annoying part is not that it's slow, but that it's not obvious when it's slow, and it gives a fake sense of being fast due to the libraries written in C/C++ which are usually considerably faster than the average/shitty code you'd write in a faster language, but then you try to do something fancy in Python, and it becomes weirdly slow
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.
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
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 @@vaolin1703
I started programming with python and loved it. Now I’m starting to dislike it more and more. Still gonna use it for LC cus the syntax is quite simple.
@@OGTennyson hate is probably too strong of a word but I’ve worked at companies where they had entire backends written in python and it’s a disaster to debug a large dynamically typed codebase. Similar errors would be caught in compile time in a OOP language like Java, c#, go etc. obviously efficiency is a problem too as the short mentions. Still a great choice for a beginner, leetcode or making small projects/scripts.
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'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)
As a Data Scientist, I don't need python for that (still use it a ton though, although most of it is actually just calling C++ libraries), just a large enough dataset. When you dataset is millions of rows, you'll want to turn that O(n^2) algorithm into O(nlog(n)) real fast.
So you suck at writing code then. That’s your fault. Try using an interpreter to check syntax errors or just practice more and don’t blame the language. Cause every other language has indentation
@@okthisisepic9218 nope, with brackets or alternatives it's not a problem at all. I write code every day and I don't have a problem with it. Python's indentation system makes you check your tab count every time and it sucks. And no, not every language has indentation by forcing, you can write one liner program with most of them.
@@okthisisepic9218 No, indentation is not every, or even a significant majority, of programming language uses it as anything other than a way to write code that's more readable. Only structured languages do. Here is a quote from the wikipedia article about it: In computer programming, indentation style is a convention, a.k.a. style, governing the indentation of blocks of source code that is intended to result in code that conveys structure. Indentation involves using the same width of whitespace before each line of a group of code so that they appear to be related. As whitespace consists of both space and tab characters, a programmer can choose which to use - often entering them via the keyboard space key or tab key. Indentation applies to every text-based programming language. This article primarily addresses free-form languages, with special attention to curly-bracket languages (that delimit blocks with curly brackets, a.k.a. curly braces, a.k.a. braces) and in particular C-family languages. As the name implies, free-form language code need not follow an indentation style. Indentation is a secondary notation that is often intended to lower cognitive load for a programmer to understand the structure of the code. Indentation can clarify the separation between the code executed based on control flow. Some free-from languages use keywords instead of braces - for example BEGIN and END. Structured languages, such as Python and occam, use indentation to determine the structure instead of using braces or keywords; this is termed the off-side rule. In such languages, indentation is meaningful to the language processor (such as compiler or interpreter); not just the programmer. A convention used for one language can be adapted for another language.
@@okthisisepic9218 Most other languages have flexible indentation purely for making code easy to read for a human. It's totally unnecessary for the compiler/interpreter. You can write an entire JS module in a single line and it will totally work. It will be nearly impossible to read, but it will work fine. (That's what minification does anyway.) So no, forcing indentation as a syntax requirement doesn't give you the right to call people who hate it as bad programmers. It was a poor choice of the language designers that makes code maintenance a bigger chore than it could have been.
@@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
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
most positives you just gave python is a bigger positives in JavaScript with Node.JS it also does not have the extend of the draw back python does with it's interpreter, the only thing is the code syntax and i would actually argue that Pythons syntax is not as clean as a C Syntax language like JavaScript.
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.
As a diehard Pythonista I really don't value the dynamic typing so high! I like typing stuff pretty often and could actually do without it being dynamic. I like python because of it's availability and inclusiveness! If you want speed: Try the dedicated data structures, try the plugins (numpy, scipy, pandas, keras), embed it as a plugin, try the flavors pypy, mojo ...
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.
I'm planning to learn more in python but because of this short video.. it makes me not continue to learn that.. by the way I'm Javascript user specially node.js and sveltejs
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.
@@twoandhalfbengals 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.
Python is mainly incredibly useful due its ecosystem for some specifc tasks. For example data science is almost completely dominated by python since the libraries available are incredibly efficient and easy to use with massive dat sets. I'm sure these libraries are written in faster languages but the user never sees this. For some tasks python is well suited. Other languages are good at other things. Simple as.
@@ДмитроПрищепа-д3яthe concept Python is slow is a dead concept. Python runs C most of time... Also, Python can easily be jit compiled, where it's simply fast enough for 99.9% usecases
Yeah only reason I use it as a Data Scientist, all the libraries it has. I'd have much prefered those libraries to exist in a language more conducive to Data Science (where efficiency of a program is real important, these programs take forever to run sometimes), but such is life, sometimes you have to adept to what already exists, and the historical argument becomes a big deal. Of course that is all Cython, but if you ever forget that and try to write something yourself, you're in for a lot of coffee breaks.
У питухона НЕТ положительных сторон. Динамическая типизация, отсутствие нормальной рефлексии и подсветки синтаксиса усложняет разработку и ничего не даёт взамен. Те, кто говорит что писать на питухоне проще чем на других языках, обычно приводят в пример hello world, или аналогичные небольшие программки. Чтож, питухон - это действительно самый простой язык чтобы написать hello world, но в серьезных проектах он будет проигрывать нормальным языкам во всех аспектах.
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 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.
Thats why you should use different languages for different usecases. Use python for simple things like APIs or small calculations or small algorythms, use Java or C for calculating graphs, physics and other stuff
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.
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.
Ppl always say python is slow and I've yet to meet a person who actually came up with an example where it bothered them. Nowadays computers are very powerful and for 99.9999% of programmers python's speed is enough. That comes from a c# programmer who learned python for ML
Note that Python is a scripting language. It is not designed to write everything from scratch. Use the right package for your work, Python works way faster than a custom C or C++ code that is not properly optimized.
Yeah, sorry no. Development time might be fast if you are just spaffing out bullshit scripts that only need to be run once and never changed then thrown away. if you are trying to write anything that needs to be worked on for years or maintained that "fast" development time ... its not that much faster if at all faster btw, fast turns to much much slower development time. At least its strongly typed, if it was weak and dynamic it would be even more of a clusterfuck.
If you are not using ML libraries, python 3 is most dumbest language I've ever seen. Maybe it can used for learning algorithm logic, but that's it. Sorry newbies. That's truth.
That is why Rockstar games Used Py on GTA 5's source code. Yes I'm not joking I have the src myself and most of the codings are either CS or py Which is Interesting to me