Why is Python 150X slower than C?

Поделиться
HTML-код
  • Опубликовано: 15 янв 2025

Комментарии • 296

  • @yashkhd1100
    @yashkhd1100 Месяц назад +186

    it's dam simple thing why it C type languages runs faster.
    => Don't want to harm anyone's feelings but originally Python was created for "Power users" i.e. people who wanna play around with things here and there. It was never meant to b full blown development language. Due to it's ease of use purpose people started use it everywhere.
    -> Python is Interpreted so when you run it compiles and execute the code.
    ->Python is tapeless/dynamic typed that means at runtime it will keep checking for which type of variable it is.
    => Being C/C++ system languages it has mammoth amount of optimization from Compilers and optimizers like LLVM toolchain. A experienced c/c++ dev can even make it run more faster by using specific compiler flags when compiling C/C++.

    • @knowledgedose1956
      @knowledgedose1956 Месяц назад +7

      python is not typeless, it is strictly typed and dynamic typed language.

    • @yashkhd1100
      @yashkhd1100 Месяц назад +4

      @@knowledgedose1956 Well theoratically it's typed but it just doesn't help to improve runtime performance. The interpreter keeps track of type but because type can change dynamically...it can't do much.

    • @cristianoo2
      @cristianoo2 Месяц назад

      ​@@knowledgedose1956wrong. Python is typeless. You can declare a var, put an int on it then put a string on it and the language will accept that.

    • @cristianoo2
      @cristianoo2 Месяц назад +3

      ​@@knowledgedose1956sure you can hint the interpreter that you will pass a certain type, but the interpreter still accepts other types. Thus, it is not typed at all.
      I've never studied it under the hood but I bet it uses some sort of void pointer and meta information accepting anything that comes from the user and using an algorithm to determine how to deal with the void pointer using the meta information.

    • @knowledgedose1956
      @knowledgedose1956 Месяц назад +2

      @cristianoo2 it is typed. if an object doesn't have method, you won't be able to call it. yes, you probably will understand this later than needed, unless you use typechecking, but python has types. it is just not compiled language.

  • @luminsky
    @luminsky Месяц назад +68

    iirc, the reason you were getting 0s in C was because the OS sets memory to 0 for security reasons. for example if you close Chrome, you wouldn't want some other program to be able to read your bookmarks from memory.

    • @comradepeter87
      @comradepeter87 Месяц назад +6

      That is correct. But, the garbage data could still happen say, when you've called a function, it pushes its elements on the stack, and then when it returns your local variables are pushed in the same overlapping region. Then, the 'dead' data from that function would still be reflected here.

    • @dragonloverlord
      @dragonloverlord Месяц назад +2

      ​@@comradepeter87 this pretty much and let's not forget the possibility of other programs not handling garbage collection of miss managing memory as that could also result in "oddities" anyways I've always said hope for the best but prepare for the worst and C seems to be pretty good at proving why it's important to prepare for things to go wrong as no matter how fool proof or secure an OS may claim to be there will always be another fun oopsie moment sooner or later.

    • @souptime1554
      @souptime1554 Месяц назад +1

      I believe it is also categorized as undefined behavior, so the C standard doesn’t say what should happen if you use an uninitialized value, meaning it could be entirely up to the compiler or operating system.

    • @samconnelly7630
      @samconnelly7630 15 дней назад +1

      On Linux systems, whenever you request a page of memory from the kernel, it is always zeroed out before you get it, unless your kernel was compiled with the CONFIG_MMAP_ALLOW_UNINITIALIZED option AND you specify MAP_UNINITIALIZED in the flags argument to mmap.

    • @dragonloverlord
      @dragonloverlord 15 дней назад +1

      @samconnelly7630 That's a good point! I had actually forgotten about the whole different systems have different base standards aspect of things so if you give a C language example that works fine on Linux (and is valid in a standard use case scenario) it could be insecure or even unstable on another system if not properly adapted by the viewer which if I'm being honest I can't really imagine many people are going to consider such details aside from actual dedicated/career programmers that is.

  • @RustedCroaker
    @RustedCroaker Месяц назад +73

    The most satisfying thing in the test is the fact Java perform almost as good as C and Rust.

    • @AyushVachhani
      @AyushVachhani Месяц назад +13

      Then the tests are flawed lop

    • @RustedCroaker
      @RustedCroaker Месяц назад +20

      @@AyushVachhani No, that means modern Java JIT is technological marvel that can beat any AOT with ease

    • @comradepeter87
      @comradepeter87 Месяц назад +17

      @@RustedCroaker Nope, these microbenchmarks are very flawed in general. The main thing that'd impact Java's performance in the real world isn't its ability to JIT such a simple hot-loop, it's the garbage collection and the large amount of memory pressure that Java applications exert on the host system.

    • @AyushVachhani
      @AyushVachhani Месяц назад +2

      @@RustedCroaker I agree that Jit is really great ( I myself use it ), but I will be honest, I have spent a lot of time on systems programming ( the code can be optimised a lot, like for example verterization, enabling agressive loop unrolling, passing release mode compiler flags, building for machine specific using compiler flags again ).
      I don't mean to say that java is bad, it's just that C is always going to faster ( assuming the person writing knows every inch of C ).

    • @AyushVachhani
      @AyushVachhani Месяц назад +1

      @@RustedCroaker Also trust me, the optimized version could run a lot faster than java ( no hate to java again )

  • @comradepeter87
    @comradepeter87 Месяц назад +22

    Can I just say that looking at more and more Indian developers, I had gotten jaded at our industry as it was very rare where I found developers that would actually care about what's going underneath the layers of abstraction or know about it. As a consequence, there's so much knowledge gap that people are not aware of.
    BUT, after watching this channel and reading the comment section here, I'm glad to say that it's not all developers and some indian devs do actually care to go in depth and to all of you, I respect you. I wish I had more fellow devs like you I could chat to, it's topics like these that are actually fascinating and not what's the next framework.

    • @KeshariPiyush24
      @KeshariPiyush24 Месяц назад

      Really enjoying the insights in this thread! It’s awesome to see so many like-minded people here. Hope we can keep the conversation going and exchange ideas!

    • @paca3107
      @paca3107 Месяц назад

      this kind of lazy devs ai will replace first

  • @volodumurkalunyak4651
    @volodumurkalunyak4651 Месяц назад +31

    6:36 No. Your code IS direcly running on the CPU (or GPU/NPU). It is running is Ring 3 mode - it has to call OS for allocating RAM, storage acsess, or talking to somewhere (other processes or network).

    • @codedamn
      @codedamn  Месяц назад +11

      exactly. obviously your code has to run on CPU but it cannot bypass OS. ring 3 IS part of your operating system. kernel IS part of your operating system

    • @volodumurkalunyak4651
      @volodumurkalunyak4651 Месяц назад +5

      @codedamn and there is a mistake in the video saying "code doesnt run direcly on the CPU" when it clearly does. Mistake at 6:36.

    • @matthiasbendewald1803
      @matthiasbendewald1803 Месяц назад +6

      @@codedamn ring 3 is the user-mode, has to do with what the CPU will allow the software to do. Doesn't have to do with the OS itself, all programs run on the CPU directly. What do you even mean by "it cannot bypass OS"? The OS can't execute programs, only the CPU can. The CPU cares for all the details, assigning Memory allocations, file access and even stopping/interrupting the program. So there is nothing to bypass, it's quite the opposite: The OS will start the program, which will then run directly on the CPU.

  • @anshupandey6260
    @anshupandey6260 Месяц назад +9

    In python 3.13 they introduced JIT within the language and performance for cpu Bound task will increase in future version of python.

  • @JitendraSingh-lr4nu
    @JitendraSingh-lr4nu Месяц назад +254

    Okay but I am still gonna use Python.
    edit : Y'all boomers need to chill as if Python is the only language I know. I have used Java, C++ and JavaScript too. Language is just a syntax when you know the basic concepts.

    • @DebdutBiswasOnline
      @DebdutBiswasOnline Месяц назад +9

      😂 me too

    • @Sandeep-zd6dq
      @Sandeep-zd6dq Месяц назад +8

      We are even using it because of it’s simplicity 😢😂

    • @thekokoserver
      @thekokoserver Месяц назад +8

      I choose it all day 😂

    • @davidrich27
      @davidrich27 Месяц назад +27

      As long as you aren’t writing a program that requires a billion nested loop iterations.

    • @_vk03
      @_vk03 Месяц назад +1

      I wished he would have tested mojo too.

  • @comradepeter87
    @comradepeter87 Месяц назад +15

    It's a bit misleading to say that userland applications "don't run on the CPU". They DIRECTLY, NATIVELY run their machine code on the CPU. There is no translation happening on-the-fly or otherwise by the OS except at startup by the OS' loader which might resolve .so/DLL dependencies (yes, not even virtual address mapping). It's better to think of OS as a bunch of "dead"/inactive code that CPU is responsible for invoking/calling on specific triggers/interrupts. If OS actually actively participated in your code execution every cycle, nothing would ever get done.

    • @KeshariPiyush24
      @KeshariPiyush24 Месяц назад

      Better to put it in this way, our user application just translates to op-codes and system calls when we need to access hardware/network etc.
      When we need to do something that is outside the scope of our program we raise an interrupt. Now OS handles all the interrupts and toggles the user/kernel mode flags in CPU if some restricted tasks needs to be performed.
      SO basically our program at interrupts just calls some code/function that is the part of the os and is handled directly by the OS and not the program. Obviously this is done to enhance security.

    • @Chief_Avy
      @Chief_Avy Месяц назад

      @@KeshariPiyush24 Hi i found your know remarkable can u kind of guide me how can i study/ gain exposure to this kind of knowledge .

    • @KeshariPiyush24
      @KeshariPiyush24 Месяц назад

      @@Chief_Avy I have a degree in Computer Science so I have studied about how OS and CPUs works in my college as well. All the best keep learning and growing 😊

  • @AllMightGaming-AMG
    @AllMightGaming-AMG Месяц назад +17

    The way you explained how operating system sits between your code and the CPU is misleading. Your code directly runs on the CPU, but it runs on user mode. The operating system manages the MMU so that the times when your program is scheduled, it is not allowed to access memory outside of the allocated region.

    • @codedamn
      @codedamn  Месяц назад +5

      It’s a simplified explanation and just to invoke curiosity. I can cover everything in depth and it will become a 2 hour video

    • @AllMightGaming-AMG
      @AllMightGaming-AMG Месяц назад +6

      @codedamn true, but that simplification should be pointed out, because the video explanation makes it look like your program is running on a vm, not on the cpu directly.

    • @codedamn
      @codedamn  Месяц назад +1

      @@AllMightGaming-AMG the program has to run on CPU at the end (where else would it run), even on a VM, underlying physical core is responsible for running your computer. to your statement, "user mode" and "kernel mode" are constructs defined by your OS. your physical CPU core does not know/care about permissions

    • @AllMightGaming-AMG
      @AllMightGaming-AMG Месяц назад +10

      @@codedamn Hey, the CPU does know about user mode and kernel mode, it is a bit set in the cpu itself. It is fine if you didn't know this but I'm surprised that you'd say this without doing your own research, it's just a search away.

    • @AllMightGaming-AMG
      @AllMightGaming-AMG Месяц назад +2

      @@codedamn it'd be impossible to write secure os where the user mode application is able to access anything without a hardware feature like a kernel mode flag. OS alone can't do this. A lot of microcontrollers are there without this feature, and you can't write an os with this kind of user mode application feature on them because of this reason.

  • @KeshariPiyush24
    @KeshariPiyush24 Месяц назад +1

    Really enjoying the insights in this thread! It’s awesome to see so many like-minded people here. Hope we can keep the conversation going and exchange ideas!

  • @SiddharthPant
    @SiddharthPant Месяц назад +7

    There is PR in repo which enables JIT for PHP and it gains some ground by reducing till 2.6s instead of 9.9s shown.

    • @MelroyvandenBerg
      @MelroyvandenBerg Месяц назад

      Yea that is nice. I also have php jit enabled.

  • @jeffg4686
    @jeffg4686 Месяц назад +3

    a lot of libraries for python are implemented in other languages though, like Rust, so the user code will be slow, but not always the library code.

  • @this.tushar
    @this.tushar Месяц назад +4

    Getting addicted to this channel

  • @luizgrocco
    @luizgrocco Месяц назад +10

    The fact PyPy is 3x slower than C and Python is 150x speaks volumes about Python despite everything you explained wouldn't you say?

  • @cmdr_scotty
    @cmdr_scotty Месяц назад +5

    This is what I've been telling everyone, yes python is faster to throw a program together, BUT it's very unoptimized in comparison to C/C++

    • @Aditya-p4t
      @Aditya-p4t Месяц назад

      u can increase python speed using PYPY

    • @cmdr_scotty
      @cmdr_scotty Месяц назад

      @Aditya-p4t you shouldn't need to install additional modules to make a coding language faster that has inherent issues running fast

    • @hemanthkumar5438
      @hemanthkumar5438 Месяц назад +2

      You have to differentiate the use cases here. Python is usually used for running something like web framework where the bottle neck is I/o.
      And C is run for something like device drivers and encoder/decoders which run billions of loops the bottle neck is CPU itself.
      In simpler language you don't need to spend hours to write a C program to spend 0.001 seconds in execution and 100ms waiting for I/o. While you can spend minutes writing a python code that will execute in 0.1 ms and wait 100 ms for I/o.
      So both have their use cases.

  • @isenksaja5333
    @isenksaja5333 Месяц назад +2

    python very friendly for observer (teacher or trainer or non professional coder) to read code.
    very expensive for real or production system, just like performance ratio from this video title, at least when on production, using c we only need 1 server, but using python we need 150 server for same output

  • @Takatou__Yogiri
    @Takatou__Yogiri Месяц назад +2

    JS/Bun, JS/Node, and JS/Deno - we are definitely going to see more JavaScript runtimes in the future. We might even see compiled JavaScript, offering a flavor similar to compiled languages. The syntax would remain the same, but the compiler would handle the code differently from how the V8 engine does. like a true compiled language.

    • @comradepeter87
      @comradepeter87 Месяц назад +2

      It'd be very complex to create a truly compiled (AOT) JS version while still being 100% spec compliant. Immediately what stands out to me are functions like `exec()` that execute a JS string. An obvious shortcut would be spin up a JS compiler that, at runtime, compiles that JS string. But that string could have variables referencing the exact current state of your own program, so this compiler now needs to tap into your program state as well. Probably not impossible, but difficult enough to be impractical - especially because JS' JIT is very impressive anyways.

    • @Takatou__Yogiri
      @Takatou__Yogiri Месяц назад

      @VivekYadav-ds8oz it might be complicated. But it's not impossible. Js ecosystem is very large. And someone might be insane enough to start the project 😶

    • @KeshariPiyush24
      @KeshariPiyush24 Месяц назад +1

      @@Takatou__Yogiri how would a weakly typed dynamic programming language such as Javascript be compiled AOT? The best we can get is JIT which is already there. Maybe we can do that for Typescript though

  • @ykmnkmi
    @ykmnkmi Месяц назад

    Additional 4 chars places Dart near C.

  • @venkatmanian2256
    @venkatmanian2256 Месяц назад +1

    Lot of the delay is due to the OS. Any round robin scheduler will only allow a slice of the CPU time (to create the illusion of servicing all other open tasks/application). This exacerbates the slow down for interpreted languages (Since a pre-compiled binary can be executed in the slice of time the OS provides to the app). Try running this on an embedded micro with an RT OS. I tried it on a Peta Linux running on a Xilinx SOC(ZCU 104) and the difference is not that bad. But I understand for people working on old Batch processing/ Round robin OS like windows this might be an issue.

  • @bhushanlaware
    @bhushanlaware Месяц назад +5

    All HLL have guardrails including Java and Javascript however they are not that slow.
    The main reason I guess python is being interpreted language. Javascript is also interpreted language however due to JIT compiler and v8 engines optimisation make it faster. Pypy is JIT for python which as very close performance to javascript as we can see in experiment. But for normal python environment since it’s completely being interpreted line by line it’s slow

  • @Sandeep-zd6dq
    @Sandeep-zd6dq Месяц назад +1

    I guess in C int variables has 0 as the default value (not a garbage value) so it also has some guardrails but yeah it’s possible that assembly instruction for C might be less compare to other languages and most of complied languages can opt in to have less guardrails as they already do a lot of checks prior to conversion and awesome video as always.

    • @AyushVachhani
      @AyushVachhani Месяц назад +1

      Default is garbage, not 0

    • @comradepeter87
      @comradepeter87 Месяц назад +2

      I don't think that "0" part is because of C as it doesn't offer any such guarantees. It's just the OS clearing any memory to 0 before giving it to the userland application. You can verify this by first calling a function that allocates a ton of stack variables with arbitrary values and then returns out. Then, in the main function, you allocate some uninitialised integers on the stack and print their values. I bet this time they would have non-zero values.

  • @iWillAvert
    @iWillAvert Месяц назад

    Python's slowness is especially interesting when you consider that it's not just an interpreted language. It is a VM similar to Java. The only real difference is that the bytecode is not precompiled to a file and run through the VM separately. That in itself can contribute to some of the slowdown, but still does not account for how slow it is at the end of the day.
    I might be talking out of my ass as I am not 100% sure at the time of writing this, but I would guess that it is does multiple passes during compilation to bytecode. This has a lot of advantages, but it is also significantly slower. That would again not fully explain it. Factoring in what I've mentioned, it should at least be up there with JS or even Kotlin.
    There is definitely a lot more to the story as this test is not the only one where you can see such a significant difference in speed between Python and even other scripting languages/VMs.

  • @heliumcloudgaming182
    @heliumcloudgaming182 Месяц назад +2

    Only Native Codes (Rust , C , C++) Compiled into Assembly then binary. Vm languages Uses Jit , Aot or Normal Iteration.

    • @mattmmilli8287
      @mattmmilli8287 Месяц назад

      JavaScript should be slow as Python or slower in this bucket. They go way way beyond JIT. V8 optimizes the living heck out of the code as well in deeeeep ways. I bet Python could have this too

  • @tomjerry0796
    @tomjerry0796 Месяц назад +2

    At the end of this video "I'll see you in the next video very soon"😂 that is tomorrow daily one video 🔥🎉

  • @shailmurtaza9082
    @shailmurtaza9082 5 часов назад

    5:37 No! They necessarily aren't unpredictable. Depends upon the compiler you are using. Some compilers don't rewrite garbage value with 0 and some do. And it looks like your compiler is initializing int with 0.

  • @timur.shhhhh
    @timur.shhhhh Месяц назад +2

    this is a very incorrect comparison, maybe the code does the same thing, but the implementation is bad:
    1. c/c++ is first compiled and then executed, while py/js is executed as it is implemented.
    2. Python uses methods: range and random, which greatly slows down the program, especially randint

  • @hemanthkumar5438
    @hemanthkumar5438 Месяц назад

    I have seen that graphic before, and i thought it was some fallacy, as i myself had done similar comparisons in past.
    Your explanation makes sense.

  • @rretro2042
    @rretro2042 23 дня назад

    Wow Java being only 8% slower that rust and c in this case is what surprised me the most here

  • @TrongNguyen-lq8gd
    @TrongNguyen-lq8gd Месяц назад

    Java is crazy speed for a managed code platform

  • @abymohanan9403
    @abymohanan9403 Месяц назад +1

    3:29 what software you using to write and draw in this video, please tell me

  • @enricmm85
    @enricmm85 Месяц назад +1

    Where is assembly?

  • @Watch-Kiran
    @Watch-Kiran Месяц назад +4

    So I'm maglu(jo jaadu na jane) in this language and all
    That means stable diffusion was written in c language rather than python it could be faster?

    • @Mayank-lf2ym
      @Mayank-lf2ym Месяц назад

      No

    • @Watch-Kiran
      @Watch-Kiran Месяц назад

      @Mayank-lf2ym ok

    • @nirbhaykumarchaubey8777
      @nirbhaykumarchaubey8777 Месяц назад

      @@Watch-Kiran yes

    • @comradepeter87
      @comradepeter87 Месяц назад +1

      Not really, most of the actual inference/ML libraries have actual core performant part written in C anyways. The performance impact would not be big enough.

    • @Watch-Kiran
      @Watch-Kiran Месяц назад

      @@comradepeter87 thank you

  • @pwhv
    @pwhv Месяц назад +1

    where is c#?

  • @maddada
    @maddada Месяц назад

    Very intrigued by "static hermes" and how much it would speed up JS code.

  • @mattmmilli8287
    @mattmmilli8287 Месяц назад

    The fact JS is that high up there is a modern miracle. Google really went hard with v8 way back when now 😮

  • @ammarahmed7566
    @ammarahmed7566 Месяц назад

    we are doing course of data science and our instructor just told that R language is slower than Python however we see a difference here

    • @Aditya-p4t
      @Aditya-p4t Месяц назад

      u can increase python speed

    • @ammarahmed7566
      @ammarahmed7566 Месяц назад

      @@Aditya-p4t yes, its just a language there are many gpu accelerated workloads like cuDF , cuPy, Dask-cuDF, PyTorch and TensorFlow (with GPU acceleration) etc. that is why python is preferred in data science (however bend programming language can be significantly faster as it is based on C)

  • @kyesil
    @kyesil Месяц назад +4

    Python best for using. Not for production.

    • @Aditya-p4t
      @Aditya-p4t Месяц назад

      i maybe wrong but we can increase the python speed

    • @scratch-9097
      @scratch-9097 Месяц назад

      OpenAI uses FastAPI for their ChatGPT Backend

  • @M0h1tKum4r
    @M0h1tKum4r Месяц назад

    I feel pity for those who compares languages based on their execution speed.Every language has it's own pros and cons, they will not talk about how fast the development becomes while using python but all they want is to ask their c++/rust doubts using pyhton built LLMs

    • @electronnuclear
      @electronnuclear Месяц назад

      Those python built LLMs have AI libraries written in low level languages like C. All the matrix operations and stuff are handled by the C code. Python only makes the necessary function call. The reason you can do fast development in python is bcz of having vast majority of libraries that already does most of your job. You're right about the rest.

  • @hexarium4817
    @hexarium4817 Месяц назад

    Dynamic Types dont slow the language as much as u think

  • @Luix
    @Luix Месяц назад

    How can be Java way faster than Go?

  • @v1Broadcaster
    @v1Broadcaster Месяц назад

    150x is magnitudes fastest than it was a few years ago

  • @white_d3vil
    @white_d3vil Месяц назад

    Don't blame it 😢 like this, it's definitely gonna improve in future

    • @MelroyvandenBerg
      @MelroyvandenBerg Месяц назад

      With jit it will improve. Both php and python.

  • @picklenickil
    @picklenickil Месяц назад

    IntrEsting.. Mehul Bhai... Entrusting is something else

  • @curtis1397
    @curtis1397 Месяц назад

    Seems like it must be a very specific pitfall. Why would most of the ai packages use python if it's so slow?

  • @oboynitro
    @oboynitro Месяц назад

    node is just c++
    the sooner you understand that the better

  • @gto433
    @gto433 Месяц назад +6

    Disappointed to see no C#

    • @husreihn1070
      @husreihn1070 Месяц назад +2

      c# is faster then java tho

    • @imakhlaqXD
      @imakhlaqXD Месяц назад

      ​@@husreihn1070 i don't think so i have used both and their architecture is almost similar with jit and vms. So i don't think their will br any difference.

    • @RustedCroaker
      @RustedCroaker Месяц назад +1

      @@husreihn1070 It's a bit slower actually. Similar to Kotlin.

    • @sanampakuwal
      @sanampakuwal Месяц назад +2

      ​@@imakhlaqXDyou're so uneducated for the topic, and writing comment blindly

    • @sk_jay
      @sk_jay Месяц назад +1

      I think it will be similar to Java if not better

  • @ALOKSHARMAMD
    @ALOKSHARMAMD Месяц назад

    thats why you dont use python in production but use mojo or something else.

  • @owaisahmed2063
    @owaisahmed2063 Месяц назад

    Good one. Please also create an in depth video that explains everything from code to compiler etc then assembly , op code OS , CPU etc.

    • @codedamn
      @codedamn  Месяц назад +3

      Most people won’t be interested in watching that

    • @owaisahmed2063
      @owaisahmed2063 Месяц назад

      @@codedamn may be you can create part 1 and see the response. but it will be worth it as such contents are rare

  • @thanatosor
    @thanatosor Месяц назад

    Where is Zig

  • @MiebakaIwarri
    @MiebakaIwarri Месяц назад

    I'm very sure I won't be conventinally running a billion iteration in production

    • @hardtech1010
      @hardtech1010 Месяц назад

      No you are mistaken. Every request from your user creates an iteration even packages you use have some kind of looping and iterations going on. Yes you can easily hit a billion iteration in prod.

    • @MiebakaIwarri
      @MiebakaIwarri Месяц назад

      @hardtech1010 like I said, I won't be running a billion iteration conventinally, if the server or any package installed cares do it that's it's own.

  • @sagarchakraborty007
    @sagarchakraborty007 Месяц назад

    Those extra 74 seconds you have spend writing the code in C😂

  • @hareTom
    @hareTom Месяц назад

    Except syscalls, native code runs directly on CPU
    memory access are handled from the OS

  • @drswapnil1234
    @drswapnil1234 21 день назад

    Then why is python defacto for machine learning? Noob here

  • @vinayak2450
    @vinayak2450 Месяц назад

    Where is swift

  • @pritishranjan
    @pritishranjan Месяц назад

    Yes python is really slow! Thats why libs like Pandas are written in C under the hood. Sometimes i is a tool. It makes you develop things faster than any language. I love it.

  • @shubhamdhameliya4756
    @shubhamdhameliya4756 Месяц назад +1

    There is llvm step and it will optimise lots of things

  • @mayankbhaisora2699
    @mayankbhaisora2699 Месяц назад

    Where is Swift?

  • @netron66
    @netron66 Месяц назад

    If that is the case would it be faster if using ai to convert all the python to c be something can be done to "optimise" a software back script?

  • @AslamNazeerShaikh
    @AslamNazeerShaikh Месяц назад +1

    C# is better than all the shit langs showed in video 🎉

  • @mateonikolic6984
    @mateonikolic6984 Месяц назад

    Java ftw.
    You get a built in gc. Nice syntaxes, easy to understand beautiful language and still fast af

  • @roccociccone597
    @roccociccone597 Месяц назад

    I guarantee you that nothing running on the JVM is that close to native speed. Every time I have compared the JVM to Go or Rust it loses.

  • @krishnasonawane6664
    @krishnasonawane6664 Месяц назад

    Eh, it makes up for the slower speed with faster development time

  • @sanjaybhatikar
    @sanjaybhatikar Месяц назад

    Python is most loveable but code in whatever works for you and enjoy ❤

  • @gardnmi
    @gardnmi Месяц назад

    Python is probably the fastest at adding value.

  • @sanjaybhatikar
    @sanjaybhatikar Месяц назад

    Homo Sapiens is 100 times slower than Cheetah

  • @emmanuelatikese3645
    @emmanuelatikese3645 Месяц назад

    Don't worry gophers they didn't use go routine

  • @arvnd619
    @arvnd619 Месяц назад +2

    Bro, rather than the subject, I love and admire the way you speak English fluently and clearly, I just enjoy that.....

  • @mayankhacker1
    @mayankhacker1 Месяц назад

    What about c#

  • @imranhussain8700
    @imranhussain8700 Месяц назад +1

    C# is missing :(

    • @RustedCroaker
      @RustedCroaker Месяц назад

      Nobody likes Microsoft

    • @imranhussain8700
      @imranhussain8700 Месяц назад

      @RustedCroaker Sad. But is it true?
      There are lots of enhancements improvementa in Microsoft World.

    • @smtkumar007
      @smtkumar007 Месяц назад

      i tested it the performance is just below go at 0.78s

    • @imranhussain8700
      @imranhussain8700 Месяц назад

      @@smtkumar007 you can send a pull request to that github repo

  • @AlmirBispo-CSV-Comp-DB
    @AlmirBispo-CSV-Comp-DB Месяц назад

    Put pascal on the test too

  • @aabhishek4911
    @aabhishek4911 Месяц назад +1

    The code does not get converted to ASM . Assembly is a separate language itself.

    • @Chat_De_Ratatoing
      @Chat_De_Ratatoing Месяц назад

      compilation converts code to ASM to a binary. You can avoid the compile to a binary step adding -S like this:
      gcc file.c -S -o file.S

    • @comradepeter87
      @comradepeter87 Месяц назад +1

      @@Chat_De_Ratatoing I recently learned that most modern compilers (including LLVM) just generate machine code directly from their IR. So, it's actually the opposite.
      Compilation converts code to binary. You can add the compilation to assembly by adding -S like this:
      gcc file.c -S -o file.S

    • @johnpekkala6941
      @johnpekkala6941 Месяц назад

      C/C++ compilation are multiple steps including ASM. There are 5 to 6 steps in total including compiling, optimization, assembler and linking. These all happen at compile time however and so don't affect execution speed whatsoever. The actual program execution is done on pure binary machine code (.bin or .exe) wich is one of the main reasons i think behind the blazing speed of languages like C/C++ and Rust. These many steps are however why languages like C and C++ in contrast to the fast execution speed instead takes forever to compile. This is seen clearly when using game engines like Unity and Unreal Engine. Higher level languages like Unity C# and Unreal Blueprint have fewer compile steps but more execution steps so they compile much faster but execute slower because they don't compile right down to machine code so extra steps are needed then during the execution. In contrast Unreal C++ is blazing fast to run but it takes between 10 - 20 minutes each time to compile. Also however C++ is an old language and I heard somwhere that much of the long compile time is because the compiler reads each file like 100000000000000 times during compilation to see if anything has changed. More modern low level languages like Rust don't do that and so compile faster.

    • @Axel_Andersen
      @Axel_Andersen Месяц назад

      @@johnpekkala6941 You are, I think, right on the money why C++ takes forever to compile. The language semantics pretty much force the compiler to read and parse and stuff the same files over and over again. This is the main reason I abandoned C++ years ago. The insane compile times. Plus the way people avoid using name spaces and spell out everything std::xxx::yyy instead of writing code that concentrates on the actual thing being done. And the corner cases of the language do not help either.

    • @hemanthkumar5438
      @hemanthkumar5438 Месяц назад

      Yes it does.

  • @Yukiixs
    @Yukiixs Месяц назад

    Java faster than go?? Suprising, even quarkus is a slower microservice framework than builtin golang, not even talking about spring

  • @kaplansedat
    @kaplansedat Месяц назад +3

    .net ?

    • @Ctrl_Alt_Elite
      @Ctrl_Alt_Elite Месяц назад

      I dont even code in C# but was also curious where it would place here

    • @imakhlaqXD
      @imakhlaqXD Месяц назад

      Its gonna be same level as java they have mostly similar architecture with jit and vms.

    • @kaplansedat
      @kaplansedat Месяц назад

      @@imakhlaqXD native aot

    • @sanampakuwal
      @sanampakuwal Месяц назад +1

      ​@@imakhlaqXDnop you're still on past

  • @urname-animator
    @urname-animator Месяц назад

    wheres asm?

  • @martinsanchez-hw4fi
    @martinsanchez-hw4fi Месяц назад

    Dont see Julia there

  • @user-eg3ft4hi8j
    @user-eg3ft4hi8j Месяц назад

    simple answer , because of GIL Lock , that will not let you use full power of multiprocessing. Also , C is closer to processor commands , that no one else , except assembly.

  • @Serizon_
    @Serizon_ Месяц назад +1

    Very interesting to see bun being equal-ish to golang in these loops and kotlin beating golang.
    I guess the point of golang is simplicity. which I appreciate.
    I would've liked a lua benchmark

    • @kevinnadar6077
      @kevinnadar6077 Месяц назад

      Its really surprising to see go having similar speeds to JS/Bun...
      And the fact that Java/Kotlin beating them is even more astounding
      I guess I have the wrong notion regarding golang, thinking that it will slightly slower speeds than Rust

    • @bardeebooboo
      @bardeebooboo Месяц назад

      @@kevinnadar6077 but go is still good in low memory environment

  • @charlesabju907
    @charlesabju907 Месяц назад

    No way Java is that much faster than Go

  • @marcuss.abildskov7175
    @marcuss.abildskov7175 Месяц назад

    I'm still flabbergasted that Python is used for data science / machine learning 😂

    • @JamilKhan-hk1wl
      @JamilKhan-hk1wl Месяц назад +1

      Only as the wrapper. Most of the framework is written in C

  • @favouronwuchekwa
    @favouronwuchekwa Месяц назад

    Ruby is faster than python?😢

  • @humtohchutiyehai1016
    @humtohchutiyehai1016 Месяц назад +2

    So isn't python better than cpp if it is making sure that everything is correct at runtime as we can detect error early?And i only use cpp for dsa so i dont know much in details but i heard neetcode say that cpp is much much more than what we use regularly for dsa ,is it this stuff he was talking about like in big companies the developer define everything by themselves but for language like js it is pre defined ( i dont know much about python)

    • @AyushVachhani
      @AyushVachhani Месяц назад +1

      Cpp is low level, and the cpp used to software development is completely different from the one you use in DSA

    • @comradepeter87
      @comradepeter87 Месяц назад +4

      Language scope for C++ is incredibly insane. I stopped moments after learning about "concepts" (an actual term, basically similar to traits in Rust) when I saw what's more to come. Learning about STL and templating would get you far enough, but learning the entire language is incredibly difficult. I'd wager to say there's less than 10 people in the whole world that understand all the ins-and-outs of C++ in every edge case.

    • @Axel_Andersen
      @Axel_Andersen Месяц назад

      @@comradepeter87 Yeah. I knew C inside and out to the minute details so I thought I'd do the same with C++. Nope. Never. And that was 20 years ago, now the language is an order of magnitude more complex. Yes, you can comfortably use it without knowing it all but I would prefer to understand it all.

    • @Axel_Andersen
      @Axel_Andersen Месяц назад +1

      @@AyushVachhani I think it is totally wrong to call C++ low lever, on the contrary.

    • @AyushVachhani
      @AyushVachhani Месяц назад

      @@Axel_Andersen I am talking relative to Java. Else even C is high level, only binary and assembly would be lower level.

  • @hellelo.5840
    @hellelo.5840 Месяц назад

    JVM faster than Go doesn't make sense

  • @raph151515
    @raph151515 Месяц назад

    I thought Python was overall thousands of times slower than C

    • @AyushVachhani
      @AyushVachhani Месяц назад

      What world do you live in 😂

    • @raph151515
      @raph151515 Месяц назад

      @@AyushVachhani in some use case it's true, just that the test you are referring to isn't the worst case.

    • @AyushVachhani
      @AyushVachhani Месяц назад

      @@raph151515 lol, then what's the worse case, am genuinely interested to know

    • @raph151515
      @raph151515 Месяц назад

      @@AyushVachhani the most syntax volume and memory allocation/GC possible per iteration. I don't know if python will progressively optimize like the modern JS engine do or keep interpreting and I wonder about the hard limits of its GC. I'm not saying that the language is wrong, I know it's used in performance context like in AI but because it's barely scripting/orchestrating native binaries doing the heavy lifting. In the optics of testing the language, I don't know if we can use the best use case if their point is to rely on native binaries. The equivalent for JS would be to test it using c code compiled in WASM, it wouldn't make sense as a valid JS entry.

  • @DK-ym9zv
    @DK-ym9zv Месяц назад

    Python is for shell scripts. Its easily to write shell scripts in python than real shell scripts. Period stop using it for backend and stuffs

  • @sonessz
    @sonessz Месяц назад

    ok. who cares? Its only the 5020503205th video talking about speed of languages.

  • @WalterWhite-yk5fn
    @WalterWhite-yk5fn Месяц назад +31

    Python is overrated

    • @koder_k14
      @koder_k14 Месяц назад +2

      🤧 ohh really?

    • @Rxlochan
      @Rxlochan Месяц назад +9

      Said mostly by people who haven’t written python and shipped it to production

    • @RustedCroaker
      @RustedCroaker Месяц назад +2

      @@Rxlochan Said by people who force others to use this garbage in production

    • @Rxlochan
      @Rxlochan Месяц назад +1

      @@RustedCroaker What No one is forcing anyone to write only in python

    • @NightDay1
      @NightDay1 Месяц назад

      Everyone before I learn python : it's the best language ever.
      Everyone now : Python is trash☠️

  • @rubyciide5542
    @rubyciide5542 Месяц назад +1

    Bruh js being faster than python lmao 💀💀💀

    • @mrmadhan8557
      @mrmadhan8557 Месяц назад +1

      Js is always faster than python. Python is a shit

    • @comradepeter87
      @comradepeter87 Месяц назад +1

      I don't know who fed this to you, but JS is surprisingly fast - miles ahead of Python. V8 is an incredible piece of engineering and I recommend more people to read/watch content on it. Just check how V8 handles strings (it's not a simple vector of bytes).

  • @akasjoe
    @akasjoe Месяц назад

  • @mathijs9365
    @mathijs9365 Месяц назад

    Python is developed for easy programming not speed.

  • @MahirArinLabib
    @MahirArinLabib Месяц назад

    replace t with d to sound indian

  • @davidkroods811
    @davidkroods811 Месяц назад

    Wtf no c#

  • @saikatdutta1991
    @saikatdutta1991 Месяц назад

    What's the point of running a simple loop and benchmark 😂... In real world you will never be writting simple loop only.. if this was the only job of a language then all these languages wouldn't have been invented.. each language has it's own usecases, solves difference types of problems,
    One language would be enough in that case.😊

  • @timmygilbert4102
    @timmygilbert4102 Месяц назад

    Cython😂

  • @guilherme5094
    @guilherme5094 Месяц назад

    👍

  • @albincr
    @albincr Месяц назад

    Kotlin is faster than Golang lol😂😂😂😂😂

    • @KeshariPiyush24
      @KeshariPiyush24 Месяц назад

      why not this is just one aspect. When we say some language x is faster than language y, it doesn't necessary means that all the things will be 100% faster in x than y. Some things could be faster in y even though generally it is slower language in average compare to x.

    • @albincr
      @albincr Месяц назад

      @@KeshariPiyush24 lol

    • @KeshariPiyush24
      @KeshariPiyush24 Месяц назад

      @@albincr yeah keep doing LOL on everything....... I guess you have ostrich syndrome.......LOL 🤡🤡🤡🤡

  • @nodistractionsjustgoandstu1842
    @nodistractionsjustgoandstu1842 Месяц назад

    Let's go

  • @john-schumandr
    @john-schumandr Месяц назад

    acha bhai

  • @MG-yc6jr
    @MG-yc6jr Месяц назад

    All this python is slow talk is bullshit. Programming languages are tools made to do different things efficiently . You want to write something to be very fast and resource efficient go with c, c++ or rust . You want to make a backend of a website quickly go for python , php or something else . These tools are there for us to choose and use them according to our requirement. If we are writing the backend of a site in c and site has 2 visitors per day then we are just wasting our time

  • @joshuasanders4302
    @joshuasanders4302 Месяц назад

    What an absolutely useless test lol... God benchmarks like this are so dumb. And I say this as a C++ SWE.

  • @TheMathues123
    @TheMathues123 Месяц назад

    Python is 150x slower than C, but you are 35000x slower with C than with Python.