Python vs C/C++ vs Assembly side-by-side comparison

  Рет қаралды 4,631,175

xmdi

xmdi

Күн бұрын

Пікірлер: 3 300
@xmdi0
@xmdi0 3 жыл бұрын
stop cyberbullying me over python semicolons. it's a coping mechanism
@dictatorship7413
@dictatorship7413 3 жыл бұрын
Haha. Get cyberbullied
@hinzster
@hinzster 3 жыл бұрын
Long ago I began my programming "career" (not really) with Pascal, and I still remember that I was frequently screaming at the screen that "IF YOU KNOW THERE SHOULD BE A SEMICOLON, WHY DON'T YOU JUST PUT IT THERE?" You don't know cyberbullying until you've been bullied by your compiler. Oh, and you could have counted all the extra development time you used in C and assembly to just run the program you wrote in Python. Writing it and letting it sit until the assembler programmer who is paid by the hour has finally finished juggling registers is just unfair.
@russianyoutube
@russianyoutube 3 жыл бұрын
Wait, I didn't even notice that, I'm just too used to semicolons
@Zeioth
@Zeioth 3 жыл бұрын
Pep8 or else
@iLeno
@iLeno 3 жыл бұрын
😂😂😂😂😂😂 everyone here is guilty of mixing up language syntax, the amount of times I have written python code into a c file is insane.
@richardfarrer5616
@richardfarrer5616 2 жыл бұрын
In my company, we have a C program which takes three hours to load some data to a database. A modern Java program has been written to replace it. That takes six hours.
@zuberk8812
@zuberk8812 2 жыл бұрын
I laughed so hard with this one XD!
@reihanboo
@reihanboo 2 жыл бұрын
well the next logical thing is to rewrite the whole code in asm!
@Tenchi707
@Tenchi707 2 жыл бұрын
It's evolving just backwards
@gabehcuodsuoitneterp203
@gabehcuodsuoitneterp203 2 жыл бұрын
IBM?
@chessplayer5728
@chessplayer5728 2 жыл бұрын
lmaoooo that made me laugh
@arkfish
@arkfish 3 жыл бұрын
"Use ASM if you are paid hourly" That's such a genius trick
@realedna
@realedna 3 жыл бұрын
Becoming replaced in no time by a C programmer doing the same in less time! GENIUS
@mamneo2
@mamneo2 3 жыл бұрын
@@realedna Not if you work for the public sector, where nobody cares about efficiency xD
@yasserarguelles6117
@yasserarguelles6117 3 жыл бұрын
@@mamneo2 Even outside the public sector companies love being inefficient because they don't seem to realize that certain projects don't need 500 people or 10M lines
@Vysair
@Vysair 3 жыл бұрын
@@yasserarguelles6117 you sure they dont love shortcuts instead?
@thmsrttg
@thmsrttg 3 жыл бұрын
Nah, try coding in binary 😁
@hzi88
@hzi88 2 жыл бұрын
When a c/c++ guy writes python code. You can immediately tell, even without semicolons. The parentheses which are not necessary. The str() inside the print for no reason. The camelCase names.
@baranjan6969
@baranjan6969 Ай бұрын
I feel called out by the camelCase.
@dorsetengineering
@dorsetengineering 6 күн бұрын
Nothing wrong with camelCase
@Tumbolisu
@Tumbolisu 3 жыл бұрын
Python users: Just use a package for that! C/C++ users: Who do you think made the package? C/C++ users: BTW you should compile with -O3, the compiler knows everything! ASM users: Who do you think made the compiler?
@keykeyjean2003
@keykeyjean2003 3 жыл бұрын
The C/C++ compilers are written in C but ok.
@Tumbolisu
@Tumbolisu 3 жыл бұрын
@@keykeyjean2003 ok but who makes the incredible asembly-level code optimizations? (i know you can write asembly within C files, but that requires you to know asembly)
@element4element4
@element4element4 3 жыл бұрын
@@keykeyjean2003 It's not important which language you wrote the compiler in, you could even write a C compiler in python. You still need to understand assembly language of whatever architecture you are targeting very well, to be able to compile efficient code into that.
@johndododoe1411
@johndododoe1411 3 жыл бұрын
Hardware engineers: Who do you think made the instructions. Hardware engineers: Use the VHDL optimizer, it knows everything.
@jeremykothe2847
@jeremykothe2847 3 жыл бұрын
Physicists: ... Philosophers: !
@mrfluffy9273
@mrfluffy9273 3 жыл бұрын
Everyone is forgetting that his code has the same form for all 3 languages. Yes there is better ways to do it in python but same goes for c and c++. Python is slower its just a fact doesn't mean its useless. All the man did was test code of O(n^2) in 3 languages to see witch runs faster. And how long it takes to develop it.
@xmdi0
@xmdi0 3 жыл бұрын
"Never thought I'd die fighting side-by-side with an anime profile pic." "What about side-by-side with a friend?" "Aye"
@S3Kglitches
@S3Kglitches 3 жыл бұрын
exactly in which part he tested the code to see which runs faster? The code was not executed
@Zirkumflox
@Zirkumflox 3 жыл бұрын
​@@S3Kglitches I think you need to re-watch the video as the programs clearly were run after being coded.
@Alexander-jm1oi
@Alexander-jm1oi 3 жыл бұрын
Yeah. Try using C for networks. You will regret that you were born.
@ahmedhamza3939
@ahmedhamza3939 3 жыл бұрын
@@Alexander-jm1oi and for machine learning and you will decide to destroy entire humanity
@apricotapple4305
@apricotapple4305 2 жыл бұрын
Don't forget that.. • Python is an interpreted programming language. • C and C++ are compiled languages which get optimized during compilation • Assembly is just sequence of instructions labeled with names typeable on a Latin keyboard. It isn't optimized or whatever. As long as it gets the job done 👍 C/C++ was the winner, but there are contexts where Python or Assembly would be a better tool for the job :)
@Rudolf215
@Rudolf215 2 жыл бұрын
Overall, assembly language is still the faster language.
@MarkVonBaldi
@MarkVonBaldi Жыл бұрын
In what case Python is better? Genuine question. Because in FE you use JS because that´s what the browser understands, and even then JS is just faster than Python. In BE its always a fight between performance (the faster a routine runs the less Besos steals your money) and easily of use (likeness). I think the only use case on top of my head is Django but at some amount of usage it is just a bad architecture decision to use that over Java, Rust, Go, etc. And machine learning I think there are libraries for other programming languages other than Python.
@ryans3979
@ryans3979 Жыл бұрын
@@MarkVonBaldi As a general programming language, it's popular because it's an easy to learn, easy to use scripting language. What does it matter if your program runs in 1 msec or 100 msec if you don't need to run it that often? Especially if the quick python script only takes 10 minutes to make vs 1 hour for the C or C++ code; you're end up actually saving time overall. There are libraries written in other more efficient languages that optimize any intensive tasks you would want to do anyways, so Python's performance usually isn't a bottleneck Realistically though, nobody is using Python for its performance. Python is known as a 'glue' language and similar to other scripting languages, it's used to glue other languages and programs together. Scripting languages actually evolved from bash scripts, which were small scripts we used to glue programs together; take the input of a text file and replace every word with another word, take that output and pipe it into a java program, take that output and do something else to it, etc. The idea is that they're optimized so you can write code quickly and efficiently with almost no boilerplate, which speeds up development. They're just another level of abstraction up. With that in mind, as a programming language, you should be using Python to perform very high level coding that 'glues' other libraries together. You shouldn't be writing Python code that's performing hundreds of thousands of loops and manipulating integers. In a similar sense you're not going to write your base neural network class in Python, that would be incredibly slow, but if you're only using tensorflow functions? You can prototype your ideas in a fraction of the time it would take you in a language like C++. It's all about how you use the language.
@hsyrhkytbm
@hsyrhkytbm Жыл бұрын
fair enough❤
@youtubesuckme
@youtubesuckme Жыл бұрын
don't forget that interpreter and compiler are programs written by asm programmers.
@ruroruro
@ruroruro 3 жыл бұрын
Kind of surprised that nobody mentioned this, but when people talk about "Python saves development time", they don't mean the time that it takes you to type out an algorithm, that you already know ahead of time. Like, this is really obvious. "Development time" includes everything from "Let's start thinking about how I would solve this problem" and until "The program is written, documented, tested, packaged and ready to be shipped to production". Also, development time includes "Oh, I'll just use this library" vs "Oh, let's go implement a B-Tree in ASM".
@MechanicalMooCow
@MechanicalMooCow 3 жыл бұрын
"YoU cAn UsE pAcKaGeS!" Says everything python user. The lazy, most unintelligent response, especially when you have to remind them that "pAcKaGeS!" aren't exclusive to python, but that near every language out there, even javascript (lmao) has the ability to use third party libraries.
@zitronekoma30
@zitronekoma30 3 жыл бұрын
@@MechanicalMooCow your point?
@ruroruro
@ruroruro 3 жыл бұрын
@@MechanicalMooCow strawmen are made of straw 1) The video compares Python to C and ASM. Name 5 C packages. Then explain, how to install and use them. Then do the same for ASM. I'll do it for Python: numpy, pandas, matplotlib, flask, requests (not even counting stdlib packages btw). pip install {package}, import {package} 2) My point was that the video attempts to sell "time spent typing out a program" as a useful metirc for "Programming time", which is an *obviously* flawed approach. By the videos logic, some esoteric golfing language would be the winner in the "Programming time" category.
@asronome
@asronome 3 жыл бұрын
@@ruroruro One difference I've personally noticed is that distribution is a lot nicer with c/c++, because it includes all the libraries without bundling in the entire thing, it only compiles the functions that you use. The vast majority of python software I've used required a lot of debugging before I could get it to run and often would bundle dozens of libraries in their entirety
@asronome
@asronome 3 жыл бұрын
@@ruroruro But it's pretty much unbeatable when it comes to writing scripts for use by other programmers and backend stuff or knocking out a quick program to process some data. It's just not great for consumer stuff imo
@nightfox6738
@nightfox6738 Жыл бұрын
Python: Use for prototyping or when performance doesn't matter C: Use for when you need code to run fast, fairly easy to interface with hardware, but can't spend too much time dealing with hardware C++: Use when you need code to run fast but don't need an extremely high level of hardware control and would like to abstract away a lot of complicated stuff and improve readability. Assembly: Use when you just need a simple algorithm to run fast and to run well, the algorithm has a big impact on your runtimes, and you have the dev time to devote to your optimizations. You ended up with the same runtime for your assembly code as the C/C++, but assembly can give you significant speedups. I wrote a fastmath library for graphics calculations in assembly and halved the runtimes of the stl functions. It really depends on the problem/algorithm and the implementation in assembly and the C compiler you're using. There are some cases where certain algorithms can't really be improved by writing by hand in assembly and others where you see massive improvements. I haven't had a chance to really dig through your assembly code there but it's certainly possible that there are some optimizations that can be made to improve that runtime.
@lashlarue7924
@lashlarue7924 Жыл бұрын
Bro I have no idea why nobody else has liked your comment, it is extremely well thought out. Here, take my like.
@ytano5782
@ytano5782 4 ай бұрын
It becomes harder and harder to write faster ASM than C. In the past, I often take the assembly from C and optimize it by hand. To be honest, the current compiler for the Xilinx Zynq Ultrascale plattform does some magic optimization shit, I don‘t fully understand 😂
@TheHighborn
@TheHighborn 3 ай бұрын
​@@ytano5782no shit. At the end of the day, you're competing with a cold calculating machine that has been created for the sole purpose of translating and optimizing code. The fact that you can sometimes hand roll ASM and get better results is amazing in itself. Compliers beating humans is expected
@left_eyebr0w
@left_eyebr0w 3 ай бұрын
That comment is really thorough, context is key ! Just commenting to say that I, a random internet stranger, concur 😂
@linuxshell8804
@linuxshell8804 3 ай бұрын
This is false.
@shizuka.yashiro
@shizuka.yashiro 3 жыл бұрын
"Use ASM if you are paid hourly" 😂
@NicholasRenotte
@NicholasRenotte 3 жыл бұрын
*goes to KZbin....'Assembly crash course for beginners'*
@Adamreir
@Adamreir 3 жыл бұрын
Still laughing!
@akumaquik
@akumaquik 3 жыл бұрын
Personally i love asm.
@Deon2137
@Deon2137 3 жыл бұрын
@@akumaquik becouse youre paid hourly
@typ0_cratz
@typ0_cratz 3 жыл бұрын
That one had me crying 😂
@commandprompt7171
@commandprompt7171 3 жыл бұрын
now do a Assembly vs Punching cards side-by-side comparasion
@johndododoe1411
@johndododoe1411 3 жыл бұрын
All languages can be done on punched cards, as long as you stay within 80 characters per line and don't drop the deck.
@SwampKryakwa
@SwampKryakwa Жыл бұрын
Would give essentially the same result
@chrisakaschulbus4903
@chrisakaschulbus4903 11 ай бұрын
@@SwampKryakwa You can get some children from ozher countries to do that coding for you, it saves a lot of time
@pako4555
@pako4555 2 жыл бұрын
Total Time : Python: 1min 50.4 sec C/C++: 1 min 24.3 sec x86 ASM: 2 min 25.3 sec So overall C/C++ takes less time for this specific program. Not talking about other big programs which has complexity and lots of debugging and errors takes in.
@animesderrotados8223
@animesderrotados8223 10 ай бұрын
Quem escreveu o ASM não o escreveu tão bem como o compilador. Pense, você acha que o programa em C foi transcrito como? Não é uma questão de linguagem é uma questão de otimização.
@mertuarez
@mertuarez 3 ай бұрын
Sure try do it same without include stdlib or python packages. 😄
@irmandade1mausoleu
@irmandade1mausoleu 2 ай бұрын
nice review. did you got any job during this time?
@gamerk316
@gamerk316 3 жыл бұрын
Once upon a time, when the first extended instructions (MMX, etc.) first came out, and C/C++ compilers were still being optimized, it did make sense to go with hardcoded x86 assembly if you needed the bleeding edge performance. I've maintained embedded systems written entirely in x86 (technically 286) assembly because at the time that was the only way to get the necessary performance (at least, without going with a 68k instead :/). But nowadays? C/C++ compilers (yes, even GCC/MSVC) are going to extract more performance then anything you will ever write. Let them do their job.
@IamTheHolypumpkin
@IamTheHolypumpkin 3 жыл бұрын
Occasionally Assamby still can beat the optimizer. I know a library which PWM or bitbangs something which actually has AVR assamby within the c++ library. The optimizer ain't good enough. Obviously this is an rare exception and only applies to a very specific Achitecture which is predominantly used in embedded systems. I would even claim, that most of the time the optimizer beats hand written assamby.
@noop9k
@noop9k 3 жыл бұрын
They still can fail at few lines of trivial code
@gamerk316
@gamerk316 3 жыл бұрын
@@IamTheHolypumpkin Yeah, but those are generally *Very* specific situations. You are right they do pop up more often in embedded systems though. Same with legit compiler bugs (of which I've encountered two in my lifetime).
@ethanpeters3047
@ethanpeters3047 3 жыл бұрын
@@IamTheHolypumpkin optimiser is better than the average c/c++ user's understanding of assembly code though, which is whats important. an experienced assembly programmer might be able to write faster code than the compiler, but anybody teaching themselves assembly to try to reach that point is going to struggle to write something faster.
@theshermantanker7043
@theshermantanker7043 3 жыл бұрын
Wdym "even" gcc, it's the literal best compiler for C and C±+ that's around in terms of the speed of the resulting binary
@rodricbr
@rodricbr 3 жыл бұрын
python semicolons, you're on another level
@akkudakkupl
@akkudakkupl 2 жыл бұрын
I use python to generate lookup tables and the sort of preprocessing that is done once, because slapping something together in python is fast and intuitive. Everything else I do is C/C++ (I play around with embedded stuff).
@svagoio
@svagoio 6 ай бұрын
yeah i use py because its easy and has a shit ton of libararies i can use. also for my aplication i see no need to have faster code for now. maybe ill change my mind when i start developing the gui version
@memetech-
@memetech- 5 ай бұрын
I like Python, but C is fast
@memetech-
@memetech- 5 ай бұрын
I also like HTML
@tastenheber
@tastenheber 3 жыл бұрын
I think, this is a little bit like comparing command line and GUI. The command line is in many situations more efficient, but only, if the commands are already known by the user. Still, with a GUI, even a noob will most likely succeed with simple tasks, simply by clicking and reading what is already on the screen. Less efficient, but still better than someone who doesn't know what to type at all. Python will be most tolerant to missing technical understanding, while ASM doesn't care about the users feelings at all. 🙂
@CAG2
@CAG2 3 жыл бұрын
why check from 2 to n/2? you only need to check from 2 to sqrt(n) for prime numbers - you can implement this by doing "while i*i
@xmdi0
@xmdi0 3 жыл бұрын
good point - that would significantly decrease the number of iterations, but then I would have to massively increase the range (>>250,000) to get a similar disparity in C-vs-python performance :) . and at that point i*i would get even larger (i believe for this range, it already exceeds the maximum for unsigned int), or for even larger numbers maybe pull it out of the loop and do something fancy. or you can just use a sqrt, but I didn't want to include any math libraries (doing so in asm is a pain & a lot of typing), or have to implement that myself. obviously there are much better ways to compute & count primes than this - this is just something very quick to compare the relative speeds of execution when you have a lot of computations
@CAG2
@CAG2 3 жыл бұрын
@@xmdi0 i*i would get too large eh? no problem just compute an upper bound for sqrt(n) using a few iterations of newton's method - run n_ = n_ - 0.5n_ + n/(2*n_) a few times :)))), it's O(1) and should be negligible now you can iterate from 2 to approximately an upper bound for sqrt(n) now go make the range bigger :>
@CAG2
@CAG2 3 жыл бұрын
oh and just start with n_ = n>>1
@EmmanuelMayor
@EmmanuelMayor 3 жыл бұрын
I remember In C I had a case where prime numbers between 90 and 100 were not detected as primes if checking until sqrt(n), not the case with n/2
@CAG2
@CAG2 3 жыл бұрын
@@EmmanuelMayor that's odd, I just wrote a program using both the i*i method and the sqrt(n) using the math library and it still detect 97 as prime. (91, 93, 95 and 99 are all composite)
@tienson27
@tienson27 2 жыл бұрын
This comparison is for fun. Thanks for this. The important is what is your purpose.
@jhawley031
@jhawley031 3 жыл бұрын
One thing thats interesting about assembly vs high level languages is that back when high level languages were new, there was a similar sentiment about compiled languages as there is now with interpreted languages. The whole idea that compiled languages were so slow and unskilled. But now compiled has taken over since its way better optimized and allows for really complex programs to be way simpler. Maybe the same will happen for interpreted languages
@LundBrandon
@LundBrandon 2 жыл бұрын
Most things can still be done faster in assembly.
@109Rage
@109Rage 2 жыл бұрын
> maybe the same will happen for interpreted Nah. They just compile the code at runtime lol. Chrome started JIT (just-in-time) compiling JavaScript back in 2008, and now everyone does it. Chrome's JIT is the fastest in the industry, and it's still not even comparable to even the "slow" compiled languages.
@G4nd4lf
@G4nd4lf 2 жыл бұрын
I don't think so because each better optimalization of c/c++ takes generally more time to compile. In interpreted languages you don't have this trade off because "compiling time" is also execusion time. But is very likely that languages will become more and more easy to use and compilators would do more and more work for programmers.
@tbuk8350
@tbuk8350 2 жыл бұрын
Python compiles directly to bytecode in the first stage of it's compiler, so it has practically no overhead due to it being interpreted, it's mostly slow just because it's single-threaded and dynamic.
@nandowonka
@nandowonka 2 жыл бұрын
Good luck waiting for this!!! 🤣🤣🤣🤣
@alexandrel3804
@alexandrel3804 3 жыл бұрын
For all the people saying the Python could be faster, it could not, not in relations to other languages, at least. The WHOLE POINT of Python is to be flexible and easy do code, that's why it was the fastest to write in the video. But for that, CPyhton has to do a lot of work, like deciding all the types. That way, we can take advantage of dynamic typing. It's a tradeoff, and I think every python user should understand that.
@knowledgenews5343
@knowledgenews5343 3 жыл бұрын
How about Cython?
@arthurbc6
@arthurbc6 3 жыл бұрын
If you need that level of performance in your app you wouldn't even think about starting coding in python, otherwise, python is the best choice, always
@arthurbc6
@arthurbc6 3 жыл бұрын
@@AbeDillon Sure! I was in a discuss these days where one of my workmates was saying he doesn't like python because it's slow... ok, sure it is... But you're not writing a powerful algorithm that really needs performance, it wouldn't make any difference in the end and you would got job done faster with python.
@AnimaxNeil
@AnimaxNeil 3 жыл бұрын
@@arthurbc6 well, try making a sudoku generator in python. I did. Made it in python, c# and c++. Guess what. The difference is really visible. Now don't blame my algorithm. Because any algorithmic optimisation would always reflect well in any language. The only real advantage of Python is the many libraries or packages. But that's more because it is the most used language by non-programmers. And python isn't very readable imo. It's also harder to debug. The reason python isn't for me is it's syntax. I like more structure in my programs, which I'm sure many others do as well.
@gJonii
@gJonii 3 жыл бұрын
@@arthurbc6 If you know you need performance... You'd still probably write the code in easiest language you have available to you, regardless of speed, and then only when you have the program ready and provably be too slow, you'd profile the performance and optimize most important parts. I don't think there exists a program where more than 10% of the code has its slowdown by 100x actually in any measurable way impact performance. So even if you know for sure 100% that the program as whole can't run fully on Python, that's 90% of the code you could write in a clearer, cleaner language with absolutely no performance impact, no downsides whatsoever. And then you have numpy and such, which just might actually be enough for the missing 10% as well. Premature optimization is the root of all evil.
@syntaxed2
@syntaxed2 Жыл бұрын
0:10 you can see the python printf is already written and the c++ is not - He also does several enters which throws off the timing even more - C++ should be 1min
@sassuki
@sassuki 5 ай бұрын
you miss the point completely -.-
@maxmuster7003
@maxmuster7003 3 жыл бұрын
The winner is assembler.
@nebulium6641
@nebulium6641 3 жыл бұрын
Assembly*, the assembler turns the assembly into machine code. Like a compiler does with C.
@maxmuster7003
@maxmuster7003 3 жыл бұрын
@@nebulium6641 C compiler are very good optimized. But i like to use assembler to create some tiny executable. In assembly you see all instructions like the CPU.
@danapink2503
@danapink2503 3 жыл бұрын
Damn bro dont give out spoilers like that
@Alexis-hj6ci
@Alexis-hj6ci 3 жыл бұрын
@@nebulium6641 Python work over a C interpreter. C first translate the code to assembly. Assembly directly turn the file in machine code.
@nebulium6641
@nebulium6641 3 жыл бұрын
@@Alexis-hj6ci I know. I was saying that Max's terminology is wrong. The assembler is what converts assembly language source code to machine code.
@aaaaaaaaaaaaaaaaa98
@aaaaaaaaaaaaaaaaa98 3 жыл бұрын
I remember vividly taking this course called "Compilers"... and it was so much fun to know behind the scene how compilers work, how to save variable, how halt work... I am glad to take that course...
@neeljoshi3923
@neeljoshi3923 3 жыл бұрын
Please paste the course link 🙏
@banjoguy9000
@banjoguy9000 3 жыл бұрын
I'm taking a Compilers course right now. It's really interesting but the assignments are quite the challenge
@aaaaaaaaaaaaaaaaa98
@aaaaaaaaaaaaaaaaa98 3 жыл бұрын
@@neeljoshi3923 unfortunately at my univ this is closed course... but there are many online course you can choose. the thing is the concept of compiler course is converting program from a to b.... once you get the idea the rest is EASY!!!
@aaaaaaaaaaaaaaaaa98
@aaaaaaaaaaaaaaaaa98 3 жыл бұрын
@@banjoguy9000 yes, the mind set behind that is far complicated without good prior knowledge
@bobbytaraantino
@bobbytaraantino 2 жыл бұрын
I enjoyed this course so much more than any
@yechandev898
@yechandev898 2 жыл бұрын
For me personally, the one of greatest strength of python is the concise code. It makes it easy to read and maintain. It would be nice to see the number of characters for each language...
@Jefferson-ly5qe
@Jefferson-ly5qe 2 жыл бұрын
I love python for that, there are plenty of instances where your time is more important than shaving seconds off your runtime.
@h3xad3cimaldev61
@h3xad3cimaldev61 2 жыл бұрын
C++ to me is cleaner than python can ever be maybe because I'm more experienced but throwing somebody who's freshly learned how to program into a C++ project isn't a good idea
@Jefferson-ly5qe
@Jefferson-ly5qe 2 жыл бұрын
@HackerExecute idk, assembly is definitely a step below the others when it comes to legibility. It's a speciality tool these days for pretty good reason. Bad programmers will write shite code regardless of the language.
@Jefferson-ly5qe
@Jefferson-ly5qe 2 жыл бұрын
@@h3xad3cimaldev61 I think it also depends on what you've started with. If you start with something statically typed C++ makes sense. Now I'm more experienced I prefer Rust for anything performant and python for the rest.
@Jefferson-ly5qe
@Jefferson-ly5qe 2 жыл бұрын
@HackerExecute dabbled with assembly in uni, haven't dealt with it since. It's interesting but definitely not something I could pick up and use right now! Can I ask what area these assembly programmers are working in? Is it embedded stuff? Drivers? My impression is that it's pretty niche these days compared to higher level languages. Re: legibility, I'm not sure we're talking about quite the same thing. I'm saying the abstractions available in higher level languages make them more legible than assembly for large tasks. For example, good luck writing a game or a machine learning model in assembly, you'll be there a long time. I think you're maybe talking about smaller low level tasks? Can't say I've run into the same issues you have with types in python. If I wanted to get specific about types I'd probs use rust/C++. What were you working on in python that was giving you hassles? I mainly use python for higher level tasks eg data science workflows, manipulating files. If I spend a morning working on a python script and it runs 2 minutes slower than another language I really don't care. The data science libraries available in python save me that many times over. As always, the right tool for the job.
@primeprover
@primeprover 3 жыл бұрын
Would be very interested in a comparison of the asm code with the disassembly of the c code(also with optimizations)
@Fix_It_Again_Tony
@Fix_It_Again_Tony 3 жыл бұрын
Now this is interesting.
@Johnobomb
@Johnobomb 2 жыл бұрын
Theoretically, if you use the ASM optimized instructions generated from the compiled C code and you compare it to the C code, you should get the same results since it should generate the same object code (binary). The only way one would outweigh the other is if it uses different assemblers. In this case, OP seems to be using gcc for both C and ASM so it will be identical.
@dpeYoutube
@dpeYoutube 2 жыл бұрын
Note the C compiler won't do this but: since this code is entirely deterministic the most optimal compilation would be to compute the loop at compile time and then print the number.
@nathanoher4865
@nathanoher4865 2 жыл бұрын
if he is using x86-64 gcc 12.1 then his C code looks like this, without optimizations, just straight C translation: isPrime: push rbp mov rbp, rsp mov DWORD PTR [rbp-20], edi mov DWORD PTR [rbp-4], 2 jmp .L2 .L5: mov eax, DWORD PTR [rbp-20] cdq idiv DWORD PTR [rbp-4] mov eax, edx test eax, eax jne .L3 mov eax, 0 jmp .L4 .L3: add DWORD PTR [rbp-4], 1 .L2: mov eax, DWORD PTR [rbp-20] mov edx, eax shr edx, 31 add eax, edx sar eax cmp DWORD PTR [rbp-4], eax jle .L5 mov eax, 1 .L4: pop rbp ret .LC0: .string "%d " main: push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], 0 mov DWORD PTR [rbp-8], 2 jmp .L7 .L8: mov eax, DWORD PTR [rbp-8] mov edi, eax call isPrime add DWORD PTR [rbp-4], eax add DWORD PTR [rbp-8], 1 .L7: cmp DWORD PTR [rbp-8], 250000 jle .L8 mov eax, DWORD PTR [rbp-4] mov esi, eax mov edi, OFFSET FLAT:.LC0 mov eax, 0 call printf nop leave ret isPrime is the declaration of the isPrime function, and int i = 2; .L2 is the condition i
@JR-mk6ow
@JR-mk6ow 2 жыл бұрын
@@dpeKZbin true. I believe Java does that at compiling (at least that's what I recall from college).
@ishdx9374
@ishdx9374 3 жыл бұрын
even better, if you pass -O3 to the C solution it's gonna be much more faster than the hand written assembly
@xmdi0
@xmdi0 3 жыл бұрын
in general, yes, but not here. -o3 has no benefit on this simple procedural algorithm. give it a try if you don't believe me
@ishdx9374
@ishdx9374 3 жыл бұрын
@@xmdi0 I'll try it, it might be auto vectorized with clang
@James2210
@James2210 3 жыл бұрын
ironically gcc seems to make it worse with -O3 for me if I only pass -O1 it's better by a few tenths of a second
@cg0wamp
@cg0wamp 3 жыл бұрын
Also, you don't need to get up to n/2, sqrt(n) is enough, if there aren't any devisors up to that, there won't be any above that. But this would apply to all three of course. Plus, I don't know what the time cost of calculating the square root would be and if it would be worst in the end.
@renato360a
@renato360a 3 жыл бұрын
@@cg0wamp at the very least there's an old fast inverse square root algorithm out there, so just use it and use 1 over the result, that would be better than going up to n/2.
@ruckboger
@ruckboger 3 жыл бұрын
Started out with Basic as a kid on the C64, learned C/C++ for Windows development, then later in my career it was JavaScript as applications went to the Web. Funny how after moving to the cloud I've been using Python for the last 3 years and loving it.
@plumreid
@plumreid 3 жыл бұрын
I had a class in Fortran 77. You may actually know what that is.
@gurpwindoo1928
@gurpwindoo1928 3 жыл бұрын
@@plumreid Same. Did you take a class in Pascal too? Folks are writing malware in it now (Lazarus IDE).
@plumreid
@plumreid 3 жыл бұрын
No Pascal. I was getting an Engineering degree and for some reason the only programming language we were required to take was Fortran 77. I also used a truly terrible language called ISETAL in an experimental Calculus class. Looking back I'm sure that my professor was just using us as research subjects to get published.
@whitetiger9075
@whitetiger9075 3 жыл бұрын
Every language has its own pros and cons, a real programmer uses a language depending on what he/she is going to do. Python is slow (than others I mean) but is easy and has lots of libraries. actually even its more used for machine learning and scientific calculations, but it can be used for scripting small projects, backend of Web applications, etc.
@Katt1n
@Katt1n 3 жыл бұрын
A real programmer is someone who programs for a living. Gate keeping is cringe, even if you are right.
@wrong1029
@wrong1029 3 жыл бұрын
@@Katt1n how is that not also gatekeeping? Bisqwit is an excellent programmer, but he drives a bus for a living
@Katt1n
@Katt1n 3 жыл бұрын
@@wrong1029 I was referring to "programmer" as a job title. Obviously you can be a brilliant programmer without doing it for a living.
@wrnlb666
@wrnlb666 3 жыл бұрын
Python libs are literally in C
@lnx648
@lnx648 3 жыл бұрын
Python is easy for non programmers to learn, for example those who are interest in analysing data but don't want to learn something more complex and are willing to not learn a better language in exchange for much slower performances. Python is a scripting language, it can be good for that. Every language has libraries, C, C++, Java, Dart... literally every programming language does. Admittedly using a library with C++ might be harder than installing a package on Dart, but after you learn how the building process works, it's not hard at all, because you know what you're doing.
@HirschyKiss
@HirschyKiss 2 жыл бұрын
It just shows the power of the languages designed to be fast vs the one designed for ease of use/learning automation etc (plus it has numpy etc from the past languages, so there's really the best of both worlds)
@binguloid
@binguloid 2 жыл бұрын
it's not like they're designed to be fast, assembly is literally just telling the cpu exactly what to do.
@ivanjijon8647
@ivanjijon8647 3 жыл бұрын
"next i will compare fortran and 4chan" X'D you made my day
@GRBtutorials
@GRBtutorials 3 жыл бұрын
And this doesn't seem to include thinking time, only writing time. If you include the former, Python, C and C++ should be similar, but assembly would likely be even slower.
@agfd5659
@agfd5659 2 жыл бұрын
That would depend how experienced you are with writing assembly
@davidwuhrer6704
@davidwuhrer6704 2 жыл бұрын
@@agfd5659 I am experienced enough with assembly to avoid it where possible. Other people have to be able to read the code, too.
@agfd5659
@agfd5659 2 жыл бұрын
@@davidwuhrer6704 not other people, but other programmers
@davidwuhrer6704
@davidwuhrer6704 2 жыл бұрын
@@agfd5659 Fair enough, but they still have to be able to read it.
@LouisBarjon
@LouisBarjon Жыл бұрын
There is a math theorem that says you only need to check divisor from 2 to sqrt(n)
@wkluba
@wkluba Жыл бұрын
Yes, looks like this guy didn't pay attention in high school computer science class :)
@artemkotelevych2523
@artemkotelevych2523 3 жыл бұрын
one thing to take into account is that python can't inline func calls, so with such task where you have a lot of calls it's better to use nested loop instead of a separate function
@MrZnarffy
@MrZnarffy 3 жыл бұрын
Bahaha.... And it cares about whitespaces.. Idiotic, incapable and slow.... C however, where you can just typecast anything to anything, and use data as code and vice versa... Pointers rule!!!
@mcroyal8000
@mcroyal8000 3 жыл бұрын
@@MrZnarffy you're arguing that Fiskars axe is worse than Husqvarna chainsaw dude... Both languages have different purposes and are good at them, and your talk about some C features you like makes you look like one of those programmers that do only some code exercises online and no real job.
@MrZnarffy
@MrZnarffy 3 жыл бұрын
@@mcroyal8000 ahahaha... Dude, if you can't use pointers, and function pointers, you shoulndn't even speak about C... I started with Assembler waaay back, done verilog, and lisp, and python, and anything between them. Python is wrtten by morons for morons.. I mean indentation sensitive???? Come on.. Oh.. And interpretative language.. LOL you don't do serious stuff in that.. It's like the C++ hype.. Why on earth have classes and inheritance? So you can be lazy and make bloated messes that is impossible to maintain.. I know COBOL too, but I wouldn't use it if I possibly could avoid it, and Python is just as crappy
@mcroyal8000
@mcroyal8000 3 жыл бұрын
@@MrZnarffy you don't do serious stuff in Python and yet it's the 2nd most used programming language after JavaScript. Keep living in your bubble, thinking that only C is good and for everything "bEcAusE p0iNTerS" lol
@artemkotelevych2523
@artemkotelevych2523 3 жыл бұрын
@@MrZnarffy omg THAT type of programmer...
@mic08242000
@mic08242000 3 жыл бұрын
I would suggest to separate c with c++. After c++11 c++ has started to diverge from c. After c++20, it is basically a different language all together
@xeridea
@xeridea 3 жыл бұрын
For basic cases like this, C and C++ would likely produce identical code, assuming the compiler used the same level of optimization. C++ having many more features doesn't change how it compiles code not using any C++ features. Optimal generated assembly from C is likely the same, or similar in C++. Different compilers may have different methods of optimizing execution speed, but generally C code compiled in a C++ compiler will be the same or similar speed.
@au-lit
@au-lit 3 жыл бұрын
@@xeridea the problem isn't the code performance, it's the association of C and C++.
@squee222
@squee222 3 жыл бұрын
@@au-lit I don't think it's a problem. C++ is more or less backwards compatible and C++ compilers will compile C-like code.
@tristunalekzander5608
@tristunalekzander5608 3 жыл бұрын
If you don't use the new features (which are often slow and/or buggy) it's still exactly the same as C.
@au-lit
@au-lit 3 жыл бұрын
@@squee222 Backwards compatible with what? Any respectable C++ isn't backwards compatible with pretty much anything. Compiling any C(-style) code in C++ is a bloody bad idea.
@pabblo1
@pabblo1 2 жыл бұрын
Technically, assembly should always be faster, as assembly is basically the closest thing to raw machine code.
@lucaswebdev
@lucaswebdev 2 жыл бұрын
unless you write poorly in assembly and the compiler is more efficient with your upper level code
@Rudolf215
@Rudolf215 2 жыл бұрын
Yes, assembly should always be faster than any language. But it depends on how you write your program in assembly.
@LukeAvedon
@LukeAvedon 3 жыл бұрын
Now do one in straight machine code with just a hex editor.
@BrightBlueJim
@BrightBlueJim 3 жыл бұрын
Pf. Hex editor. Do one where the programmer is toggling the front panel switches on a PDP-11/45.
@LukeAvedon
@LukeAvedon 3 жыл бұрын
@@BrightBlueJim YES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@1creeperbomb
@1creeperbomb 3 жыл бұрын
I remember reading a post by some retired game dev who started out programming with assembly and ended with C++. So with the first consoles they used to write everything exclusively in the native assembly because it was the only available option. When consoles started supporting compilation from C, they still used assembly for any loops because the compiler wouldn't optimize them. Then when the compilers finally started becoming feasible to write only in C, C++ started getting popular. Except then the C++ compilers weren't well optimized either lol. One of the devs even made their own C++ compiler better suited for the console but it still wasn't great. so they opted to continue writing in C until publicly available C++ compilers became very effective. Then everything was done exclusively in C++ and the guy retired several years later. I believe he worked mostly with Nintendo consoles (NES, SNES, N64, Gameboy, etc.) but also did a few projects on Sega and PlayStation.
@KingLich451
@KingLich451 3 жыл бұрын
i'd like to read the full post, i wonder where it is
@drygordspellweaver8761
@drygordspellweaver8761 2 жыл бұрын
Neat
@coolbrotherf127
@coolbrotherf127 2 жыл бұрын
Yeah, C++ is the standard these days for pretty much any game development that's not just automation scripts. There's not a lot of reason to learn ASM unless you plan to work with it a lot for a specific type of job.
@sisyphus_strives5463
@sisyphus_strives5463 2 жыл бұрын
@@coolbrotherf127 Well it is useful learning it for edification, which is never a waste of time.
@coolbrotherf127
@coolbrotherf127 2 жыл бұрын
@@sisyphus_strives5463 It's better to create a goal and master skills that are vital to the accomplishment of that goal. Learning random stuff for the sake of learning is usually idle behavior that doesn't accomplish anything. A programmer who knows a few languages really well is more useful than one who only knows the basics of 20.
@mspeir
@mspeir 2 жыл бұрын
There are precious few reasons to write straight assembly anymore. Compilers are just too advanced.
@lanik8163
@lanik8163 3 жыл бұрын
Tbh I see python as just a scripting language. I use it only for prototyping small ideas or when I'm fed up with my current shell's scripting language.
@ianrust3785
@ianrust3785 3 жыл бұрын
Yeah I've had trouble finding something to do with it that I wouldn't prefer to use another language for. Network programming is something it's good at... it might be useful for writing some services or for gluing components together, but I haven't done any of that in a professional context.
@ogito999
@ogito999 3 жыл бұрын
Assembly gets extra credit for being 1337.
@idegteke
@idegteke 11 ай бұрын
I used to write assembly (Z80) on paper with pencil, looked up mnemonics from a printed chart, typed in the bytes one by one into a Basic program’s DATA, POKEed it into the RAM with a FOR loop, run the code, watched the PC to freeze 95% of the times with no info about what might have gone wrong, and started again from scratch.
@desrucca
@desrucca 3 жыл бұрын
There are 2 type of python guy : 1) a newcomer who pick python as his 1st language and always ridicule other programming language by saying the *syntax is ugly* & *too verbose* 2) a professional who had written many apps in many languages and *having passion* in statistic, calculus & linear algebra
@anon1963
@anon1963 3 жыл бұрын
My first language was C++, which was pain in the butt to learn. It however was worth it!
@universallyepicnarwhal9102
@universallyepicnarwhal9102 3 жыл бұрын
@ANoobyPlayer UwU this. I’m a C or V or Zig user but if I want to start a new project I’ll make as barebones as possible a basic thing in python before rewriting it in C or another low-level speedy language
@chuuni6924
@chuuni6924 3 жыл бұрын
I could argue that this algorithm doesn't make for a good example of the differences between C and assembly. Basically the whole inner loop will be completely bottlenecked on the integer division unit, and the whole rest of the processor will lie mostly idle just trying to feed it, so it doesn't showcase very well how a good assembly programmer may be able to outperform the compiler in various ways. When playing iwth microbenchmarks, I've often been able to improve register allocation or other minor details in the compiled output, but in this case, none of that will matter since it's all just waiting around for that one DIV instruction. That being said, if you really wanted to optimize this further is assembly, you'd probably convert the integers to floats and use the AVX division unit to increase parallelism.
@ashwinalagiri-rajan1180
@ashwinalagiri-rajan1180 3 жыл бұрын
I think he made his point even without all those optimizations
@funkle2645
@funkle2645 2 жыл бұрын
@G E T R E K T Especially when you consider systems that may run the same small instructions millions and millions of times in rapid succession. The small small speed difference really adds up and it can become mission critical to maintain code in ASM instead of even C.
@mattreigada3745
@mattreigada3745 2 жыл бұрын
With proper optimization from the compiler I suspect this is a case where the compiler will result much faster machine code than the machine code generated from the assembly that was written. Two easy optimizations a compiler could reasonably implement are (1) calculating the division a single time outside the loop and (2) substituting this division with a right bitshift. Implementing either of those would give a performance edge over the assembly that was written.
@LithiumDeuteride-6
@LithiumDeuteride-6 Жыл бұрын
About 99% of the time is taken by the DIV instruction, because of this it is useless to optimize this code, for example, the isPrimes inline function does not give anything. Tested the optimized version (i
@Kokurorokuko
@Kokurorokuko 2 жыл бұрын
you can check numbers up to sqrt(n) + 1 to check if it's prime. Don't know if it would make it run faster because less checking or slower because of sqrt call.
@Эдвард-ч3э
@Эдвард-ч3э 2 жыл бұрын
Of course much faster. You can go up to sqrt(n) and check only numbers of the form 6k+1 and 6k-1.
@thanakritpaisal2059
@thanakritpaisal2059 3 жыл бұрын
screw youtube for hiding dislikes i wanna see how many python users got pissed
@xmdi0
@xmdi0 3 жыл бұрын
currently 95.5% like to dislike, so they are outnumbered lol
@gr1mmd
@gr1mmd 3 жыл бұрын
@@xmdi0 cope
@Quique-sz4uj
@Quique-sz4uj 3 жыл бұрын
@@gr1mmd 1900 likes 153 dislikes. The api is still public
@paulooliveiracastro
@paulooliveiracastro 3 жыл бұрын
People don't consider performance optimizations and maintenance development time. That's very convenient, isn't it? As a Python developer, I find that one of the biggest time sinks in my day-to-day. Also, development happens with a limited number of people (1-10 devs usually), but the program will happen a million times more frequently than that. The impact on the customer is huge. Don't even get me started with environmental issues. Performance matters.
@michaelbuckers
@michaelbuckers 3 жыл бұрын
It's very convenient to just burn more oil for power and generate more e-waste when you're not the one paying to clean that up.
@VencaCZ666
@VencaCZ666 2 жыл бұрын
When I saw this I wanted to test Lua as well and I was surprised. Writing: 61s Execution: Lua: 38s Luajit: 7.8s PS: Writing was calculated based on number of characters in python file compared to lua (+9.5%) since Everyone has different writing speed
@AbhimanyuAryan
@AbhimanyuAryan 3 жыл бұрын
it's interesting how execution time of C matches that of ASM
@joey199412
@joey199412 3 жыл бұрын
C would actually be faster if he passed -O3 to the GCC compiler. The reason is that compilers are so intelligent in 2021 that they "know" what programmers tried to achieve with their code and so the compiler writes extremely efficient machine code compared to handwritten assembly which is almost always going to be slower as barely any human can match the 3 decades of tricks programmed into C compilers.
@kaseyboles30
@kaseyboles30 3 жыл бұрын
@@v0xl It's an abstraction on raw machine code. It's not much removed, but it is indeed a programing language.
@Artaxerxes.
@Artaxerxes. 3 жыл бұрын
@@joey199412 Very true. This comment needs more likes. Hundreds of the best programmers optimize the compilers for max performance. An ordinary dudes asm code can never match all that. In such cases it really makes more sense to use the more abstract c code
@ioneocla6577
@ioneocla6577 3 жыл бұрын
@@joey199412when i searched about O3 found that it's known for being unstable and weird But even without that, as you can see in the video he uses the gcc compiler to compile the .o file so he Can use O3 for asm
@user-dc9zo7ek5j
@user-dc9zo7ek5j 3 жыл бұрын
@@ioneocla6577 Not really unstable, neither weird. If your code is proper won't have problems. When building a c program look at all those warning, they mean something.
@igomaur4175
@igomaur4175 3 жыл бұрын
Its all about the application build approach. Python is using interpreter approach, wich is make Python very easy to code, but very slow when the application is launching. C/C++ and x86 ASM are using Compiler So its not easy than python to code, but they are very fast when the application is running
@mushbrain1753
@mushbrain1753 2 жыл бұрын
Thanks for nothing
@Syokool
@Syokool 2 жыл бұрын
As an electronics and IT engineer, I can tell you all them have different uses. You won't program server chips, networking devices or first layer devices with python. Assembly is the way to go with microchips, microprocessors, etc. C for integration between machine and software, os and the like, or critical use software. Python for non critical programs. Python is nice, but most performance-based apps run with c.
@davidwuhrer6704
@davidwuhrer6704 2 жыл бұрын
Microprocessors are usually programmed in C or C++, although Lisp seems to be making a comeback, and Rust is a strong contender. Assembly is only used when compilers are buggy or incomplete, from what I've seen. But you wouldn't use Python. You would use MicroPython.
@mrpanda7777
@mrpanda7777 3 жыл бұрын
after reading some of the comments - there is a reason why python is preferred by people. You can argue all day but more people than not prefer the simplicity of python. Is it slower yes, but that is why lots of python modules are written in C to gain the best of both worlds. Simplicity of python syntax plus the speed of C in case you need it
@Junky1425
@Junky1425 3 жыл бұрын
ok, at first I'm not in python, so how fast does you code this is you use python and C means you make the function isPrime in C and the rest in Python. But i think mostly its quicker to code all in C then.
@EvGamerBETA
@EvGamerBETA 3 жыл бұрын
Well, if I need to quickly write a script to do something, I'd go with python, because you don't have to have a lot of setup
@theroboman727
@theroboman727 3 жыл бұрын
Yeah, and many programs don't need extreme speed. Unless things are within like 5 nested loops or are called very frequently and have to be fast, python is just fine.
@walteralvarado9078
@walteralvarado9078 3 жыл бұрын
Most of the libraries for ML in Python are written in C, for example, NumPy, imagine doing all the logic in Python and speed-requiring work (as matrix operations ) in C.
@Junky1425
@Junky1425 3 жыл бұрын
@@JKLKJ Ok, I'm not in this topic. But I thought all big frameworks are mostly written in C or C++
@SkyyySi
@SkyyySi 3 жыл бұрын
Does the performance of C get better with -Ofast in this case?
@xmdi0
@xmdi0 3 жыл бұрын
in general, it probably does get slightly better (a commenter below mentioned that -O1 gave him the best result), but I wouldn't expect it to be noticeably faster than the ASM. this ASM is literally the barebones procedural implementation of the algorithm described in the C code. the compiler might change the jump conditions or something fancy, but I personally don't see how you can get much "faster" for this algorithm unless you cheat and mess with the algorithm (and we can always cheat in the same way for the ASM code). I think if you have much more complex code, the difference between what ASM the compiler can generate and what ASM a human will casually generate will become larger. However, I personally believe in the limit humans will always be able to generate code as fast if not faster than the compiler (because we can literally hand-write the compiler's best guess), and there may sometimes be shortcuts that humans can take, using our knowledge of the problem. Of course, the compiler runs in a fraction of a second, whereas it would take you and me much much longer.
@michaelzomsuv3631
@michaelzomsuv3631 3 жыл бұрын
Absolutely does. I tried it and it ran 30% faster with optimization enabled. No noticeable difference between the different optimization levels but a VERY noticeable difference from no optimization at all.
@Anticitizen666
@Anticitizen666 Ай бұрын
There are several optimisations that could make the ASM significantly faster here - usage of SIMD alone could reduce the execution time to less than half of that seen here. The code would be longer though. An obvious small optimisation would be to count DOWN from 250000 to 0, to remove the compare from the top, and just drop out in the not_prime section - could also remove the push and pop at the same time. So, yeah, well written x86 would be quite a bit faster, but depends on whether it matters really......
@SamMason0
@SamMason0 Ай бұрын
Yup, the ASM quality is pretty bad. They'd do a lot better with appropriate algorithm choice first (e.g. some prime sieve) then optimizing the resulting kernel in assembly and using things like simd that modern CPUs are all about.
@fausto123
@fausto123 3 жыл бұрын
Thank you KZbin algorithms you did it well.
@vinson2233
@vinson2233 3 жыл бұрын
I think this is way of comparison is not fair for python. C is a compiled language, mean the loop we write would be converted to somekind of vectorized machine code,and so that is the best practice for C. While Python as interpreted language, will literally execute a loop as an actual loop, not as a vectorized code. Good Python developer will avoid loop and try to use something vectorized like Numpy which utilize BLAS/MKL to do things faster.
@rafi0961
@rafi0961 Жыл бұрын
Pyton: programming time ~ running time
@yunfeichen
@yunfeichen 3 жыл бұрын
Choose the language to be written according to the appropriate project, this is not much to discuss...According to the needs, the fastest way to run is of course machine language, then assembly, c/c++, the disadvantage is that the development efficiency is not as fast as high-level languages. If you don't pursue high running speed, you want to use high-level languages such as python and java for rapid development.
@sphinxofblackquartzjudgemy4522
@sphinxofblackquartzjudgemy4522 2 жыл бұрын
Your semicolons as well as unnecessary parentheses and lack of spacing made my day. Anyway, I ran the exact same code, down to those semicolons, on my machine and it took less than 30 seconds. Also, when I ran the code on pypy, it took less than 4 seconds. And of course you get less than 0.1 second for both python and pypy if you use sieve.
@weatherman1504
@weatherman1504 2 жыл бұрын
First off, epic username. Way better than "The quick brown fox jumps over the lazy dog". Second off, I still have much to learn about python. This is ever more proof that the guy in the video is a dumbass.
@devsergo
@devsergo 2 жыл бұрын
It's interesting to see a similar review for languages Python, JavaScript, Delphi
@beebit_
@beebit_ 2 жыл бұрын
I'm curious as to what for you guys code the most. I code mostly to do some matrix computation, interpolting images, extrapolating the price of the beer, and for my hobbies :) Some of these are even faster, using Numpy for example (at least faster than my implementation in C). Are you all developing the next Far Cry? Have you all HUGE databases to handle? Or are you just competing to find the most amount of prime numbers? Tell me, I'm curious 😁
@XxxTheDawgPoundxxX
@XxxTheDawgPoundxxX 2 жыл бұрын
Potato vodka and a good assembler goes a long way
@coolxy2
@coolxy2 2 жыл бұрын
numpy is written in C
@beebit_
@beebit_ 2 жыл бұрын
@@coolxy2 that's the point
@dancingcactus5271
@dancingcactus5271 3 жыл бұрын
From sympy import isprime pcount = 0 for i in range(2,250001): pcount += isprime(i) print(pcount) running time .25 seconds; and if I really wanted to make it fast I would look for a library that will eliminate the loops remember, you use python for the libraries, if you are not using them, you are not really programming python also dead giveaway video maker doesn't program much python is the str conversion in the print statement
@petey5009
@petey5009 3 жыл бұрын
Pretty sure the whole point was to write basically the same code in all 3
@vinson2233
@vinson2233 3 жыл бұрын
i mean, there are a lot badmouthing about python because they compare exact same code to a compiled language which doesn't make any sense. so comparing python loop and c loop doesn't prove anything because loop is not the best approach to take with python.
@bhaskarm632
@bhaskarm632 3 жыл бұрын
C is way lot cooler than python. And python looks and is better than c. To be honest indentation really makes code look so good without need for verifying if you missed a curly brace.
@Henrix1998
@Henrix1998 3 жыл бұрын
Sympy doesn't do this bruteforce remainder check, it knows to discard even numbers and divisible by 3 immediately among other tricks. On my pc the video version takes 58 seconds. When I do range(3, sqrt(n), 2) and check for n%2 first instead, it takes just 0.35 seconds. Sympy takes 0.5 seconds. Proper primesieve where you only divide by other primes becomes faster somewhere between 10mil and 20mil.
@TheWolverine1984
@TheWolverine1984 2 жыл бұрын
I want to point out that this is a very narrow usecase. Sure Python is signigicantly slower with extreme computational tasks. But it's slowness becomes insigificant in other tasks. For example if you want to make something like a web crawler that makes a bunch of http requests parses the data and makes more http requests, Python is far better suited for this task than C/C++. No only from the aspect of development time which will be signifcinatly short on python, but also in the application running time where the relative slow speed of python will be almost nullified in comparision to c++.
@thedrunknmunky6571
@thedrunknmunky6571 3 жыл бұрын
Could you please compare C vs Rust next?
@xmdi0
@xmdi0 3 жыл бұрын
unfortunately I don't know anything about rust. from what I can tell, it should be the same as C, perhaps a little slower in some cases
@michawhite7613
@michawhite7613 3 жыл бұрын
@@xmdi0 In some cases, Rust is faster. The restrict keyword from C is automatically applied to every mutable reference in Rust. Overall though, they are incredibly similar in performance.
@ElPikacupacabra
@ElPikacupacabra 3 жыл бұрын
@@michawhite7613 Rust should be a tiny bit slower, as it does bounds checking everywhere for example. Rust puts memory safety above performance, unlike C. Well, you can code Rust in unsafe blocks everywhere, but then what's the point?
@michawhite7613
@michawhite7613 3 жыл бұрын
@@ElPikacupacabra In some cases, that slightly decreases performance. So the are some things that Rust does more slowly and some things that it does more quickly. Overall, performance is extremely similar But for the record, using a limited amount of unsafe is still useful. It means there's a limited amount of area where you have to check for undefined behavior, rather than the entire program. I personally wouldn't recommend it though, because it still brings in the possibility of mistakes, and the performance difference is unnoticeable
@berthold64
@berthold64 3 жыл бұрын
ywnbaw
@frodobaggins3974
@frodobaggins3974 2 жыл бұрын
Accept the fact that most decent C/C++ compilers (gcc, msvc, llvm) write much better assembly code than you do. Compiler engineering is a domain of art, there are optimisations there that you probably have never heard of. Writing in assembly in 2022 is a no go unless you program embedded systems or... you are a compiler engineer.
@manolooore
@manolooore Жыл бұрын
A year ago when this got recommended to me, I was still learning python. Now, i already know python and c++ and currently learning assembly :)
@richardfarrer5616
@richardfarrer5616 2 жыл бұрын
Why not test for i < sqrt(n), or i*i < n in isPrime? A more expensive comparison, but many fewer iterations even for the comparatively smaller numbers you use.
@rmnts
@rmnts 3 жыл бұрын
wrote the same code in JS and was suprised how fast node runs it.
@gonzalolog
@gonzalolog 3 жыл бұрын
@mohamed elsayed 43seg
@1Naif
@1Naif 3 жыл бұрын
@mohamed elsayed Just open the console in the browser and write this: function isPrime(n) { for (let i = 2; i
@DavisTibbz
@DavisTibbz 3 ай бұрын
NodeJS has a JIT compiler, converts your JS to ASM
@esemelekete1330
@esemelekete1330 2 жыл бұрын
Let's be honest. Python is the worst language in term of performance. Its popularity only come from how simple the syntax is, and no more. In real case scenario where performance is matter, it always paired with other language such as C, C++, etc. with tools like cython, numba, etc.
@gast128
@gast128 2 жыл бұрын
C / C++ development would even be faster if their std library would be on the .NET / JAVA level. Unfortunately they rather spend in inventing yet another obscure template trick then getting the std library up to par.
@dschledermann
@dschledermann 3 жыл бұрын
I've developed a bit of C too. Mostly for small corner case projects. Few companies wants to pay for the time C takes to write though. Python, C#, Javascript, PHP etc. may be slower than C, but the coding most definitely is quicker and it'll pay your mortgage and food.
@michaelatorn8380
@michaelatorn8380 2 жыл бұрын
That depends on the libraries, goals and person.
@mattreigada3745
@mattreigada3745 2 жыл бұрын
Really depends on your application space. I've used far more C than Python, C#, or PHP. Programming in C will definitely also pay your mortgage.
@dschledermann
@dschledermann 2 жыл бұрын
@@mattreigada3745 you are not wrong, but the amount of job postings requiring PHP or C# skills massively outnumber the amount of job postings requiring C.
@mattreigada3745
@mattreigada3745 2 жыл бұрын
@@dschledermann I'd be surprised if that still holds true, especially if we distinguish jobs and careers. JS and Java are considerably more popular than C, C#, or PHP but C# and PHP aren't really in their prime any more whereas C really only faces competition from C++ (and increasingly Rust). I generally find the comparison of job listings misleading since the industries these languages are used in have very different turnover rates.
@coipo123
@coipo123 3 жыл бұрын
use python and type slow if you're paid hourly
@memetech-
@memetech- 5 ай бұрын
C: tolerable write, fast run ASM: slow write, fast run Python: fast write, slow run That's a trade off I like, considering fast hardware and more patience for waiting than doing
@AvalancheGameArt
@AvalancheGameArt 2 жыл бұрын
Wow python so fast, can't wait to write my OS on it.
@dxfvgyhjh
@dxfvgyhjh 3 жыл бұрын
A good reson to learn assembly? everything becomes open source. Complete dominance.
@BrightBlueJim
@BrightBlueJim 3 жыл бұрын
Makes no difference. If you have source code for Python, every Python program becomes open source.
@voxelrifts
@voxelrifts 3 жыл бұрын
@@BrightBlueJim it's called a joke
@BrightBlueJim
@BrightBlueJim 3 жыл бұрын
@@voxelrifts And your point is?
@lordofduct
@lordofduct 3 жыл бұрын
​@@BrightBlueJim The difference is you need the source code. If you know ASM any code can be disassembled and read as long as you know the platform it was compiled for (which is likely since if you ran the program you're on that platform). ASM -> Machine Code is 1:1, therefore Machine Code -> ASM is also 1:1. Of course python is likely going to be handed to you in python or bytecode at best which can also be decompiled. But things like C/C++ program can't easily be decompiled into C/C++. And this ubiquitousness of ASM is the crux of the "everything" part of the joke.
@BrightBlueJim
@BrightBlueJim 3 жыл бұрын
@@lordofduct Yes, good point.
@schwalbe_t
@schwalbe_t 2 жыл бұрын
And that's why you would do this in python with a library implemented in C
@caffeinepizza
@caffeinepizza 2 жыл бұрын
I wrote a small program in C to long divide calculate primes like in the video. On my M1 MacBook Air, it took 1.6s to calculate the first 20,000 prime numbers. I tried writing the same thing in Python. It took just over 2 minutes to calculate the first 20,000 primes. Amazingly, my 10700k takes around 4 seconds for the C version. M1 single threading seems to be godlike.
@ericchou8615
@ericchou8615 2 жыл бұрын
Try using a built-in function isPrime() in the SymPy module to see how. It is a direct function and returns True if the number to be checked is prime and False if the number is not prime. Having many modules and built-in functions are the strength of Python.
@jd-foo
@jd-foo 3 жыл бұрын
The fact is python does a lot of things, but it doesn’t do anything really well. It's popular just because it's accessible to rookies.
@mig6789
@mig6789 3 жыл бұрын
It does things just well if you optimize code and don't put useless checks everywhere
@michal3141
@michal3141 Жыл бұрын
It's popular because it's powerful. You can accomplish a lot with powerful language features and libraries. It's much more high-level than C++. Of course Python is a not a language suited to write a library for numerical algorithms. In 99% real world apps performance of float or integer arithmetic does not matter because 99% of time will be spent doing IO, networking etc. In such cases Python is a great choice.
@t0ber589
@t0ber589 Жыл бұрын
When I was working on a big image dataset on my own computer, I try to uses PIL in python to load a group of 40GB images to numpy array. Then I realize "why don't I use tensorflow tensors to do the same thing". Loading these image through C is significantly faster than using the python multithreads. It would save you A LOT of time to use C
@AniobiStanley
@AniobiStanley 3 жыл бұрын
Please can you benchmark Python against Java and Kotlin as you did above; for both coding time and compile/runtime?
@colinmckay3175
@colinmckay3175 3 жыл бұрын
Java is a compiled language while python is an interpreted language. Java code is likely to be faster than C/C++ in this experiment because the C/C++ was not optimized, and Java compilers optimize automatically. If you are looking for a programming language to learn, and speed is a concern, just learn java. It isn't THAT much more complicated than python and you will get good speeds. Plus Java can be used to develop apps for just about anything.
@theshermantanker7043
@theshermantanker7043 3 жыл бұрын
Java will smoke Python in every single case; Although both compile down to intermediate Bytecode Python only has a run of the mill stack based interpreter, while Java has an advanced type of Interpreter called a Template Interpreter, AND not 1 but 2 Just-in Time Compilers to support the Templating Interpreter. It's not even a match at all
@empireempire3545
@empireempire3545 3 жыл бұрын
@@colinmckay3175 That is just a load of crap. We have both Java and C++ at work and even badly written C++ beats Java with its pants down and hands tied behind its back. Just the fact that Java FORCES you to use OOP and ALL objects you can make are inherited from the Java's root class, whatever its name was, is enough.
@KaptainUflg
@KaptainUflg 3 жыл бұрын
​@@colinmckay3175 >Java is a compiled language while python is an interpreted language. Java is VM based environment. It's something between interpreted and compiled approach. Python as a runtime environment also uses byte code, so it's not 100% interpreted in traditional meaning. >Java code is likely to be faster than C/C++ in this experiment because the C/C++ was not optimized, and Java compilers optimize automatically. It depends on compiler, CPU architecture and ISA. Good C/C++ compiler will give more performance. >If you are looking for a programming language to learn, and speed is a concern, just learn java. Java may give computational performance comparable to C/C++. However, high memory consumption and additional relatively large runtime won't let Java to be faster than C or C++. C is way more portable and universal solution than Java, especially when you need to use programming skills in a large variety of tasks (from primitive embedded applications to extremely large projects). C will also be around much longer than Java.
@colinmckay3175
@colinmckay3175 3 жыл бұрын
@@KaptainUflg oh yes, it definitely depends. Software optimization relies on MANY factors. I should have said Java might have been faster but whatever. I'm not saying Java is the end all be all of speed, but learning C/C++ would be too daunting for a first language (in my opinion). Java is fast enough, and it's a very versatile language.
@samsawesomeminecraft
@samsawesomeminecraft 3 жыл бұрын
If I code too slow then my product is less useful to the employer. My employer very likely expects me to pick a employee-timecost-effective language to code the project, or else it's a waste of company resources. And I can spend the saved time taking a break, because coding for too long can hurt my brain.
@sm64guy28
@sm64guy28 2 жыл бұрын
Python is not a good language to learn. Not because it’s a bad language, but because you’ll get all the C programmers telling you it’s slow. All the time.
@timspizza1026
@timspizza1026 2 жыл бұрын
But a lot of data science stuffs need python's libs to code quickly and neatly😂 Maybe we got technical better solution, but using python is usually considered to be convenient if you are not desperately needing efficiency
@sm64guy28
@sm64guy28 2 жыл бұрын
@@timspizza1026 ikr
@SoicBR
@SoicBR 3 жыл бұрын
"Use ASM if you are paid hourly" LOLL
@danielcarroll3358
@danielcarroll3358 3 жыл бұрын
Back in the days beyond recall, when I was taking my first programming course it was Fortran on an IBM 1130. We had a lab with a graduate student TA and we had to program the sieve of Eratosthenes using 16 bit signed variables to print out the primes that would fit. Pretty basic stuff. Well programs would start out printing five lines per second on that chain printer... and get slower and slower. Up steps the TA and his program ran much longer before slowing down. He had written an interrupt controlled printer driver in ASM of which he was rather proud. I then ran my little Fortran program and it was faster. I thought that everyone knew that all composite numbers had a divisor equal to or less than the square root. The algorithm counts. Well, so does the language. Horses for courses as the British say.
@drygordspellweaver8761
@drygordspellweaver8761 2 жыл бұрын
Please tell me everybody clapped and panties were soiled?
@-sanket-
@-sanket- Жыл бұрын
One word ( CHAD )
@soroushyaghoubi7709
@soroushyaghoubi7709 Жыл бұрын
this is one of the coolest videos ever. Hope you keep making more of these.
@amitraam1270
@amitraam1270 3 жыл бұрын
I wonder if there are no algorithmic techniques , in ASM, to use X64 CPUs ability to execute more than one instruction per core. Writing ASM, especially when C compilers already optimize for that, does appear to be an inefficient way to spend programming time.
@noop9k
@noop9k 3 жыл бұрын
Out of order CPUs always try to execute more than 1 instruction per tick, up to ~5, but it is quite hard woth this code. Division operation is very slow by the way.
@punishedsnake492
@punishedsnake492 3 жыл бұрын
How about using appropriate fast library like numpy for python case. Oh, you though that it defeats the whole purpose of comparing C and Python because numpy is written in C? Then what's the point comparing C to ASM, when C compiles to ASM? Basically you have Python vs generated asm code vs handwritten asm code. Would it be more fair to compare same things?
@BrightBlueJim
@BrightBlueJim 3 жыл бұрын
No, it just ruins the whole joke. You did know it was a joke, right?
@punishedsnake492
@punishedsnake492 3 жыл бұрын
@@BrightBlueJim Yes I did. I even tried to play along with this comment.
@Ceelbc
@Ceelbc Жыл бұрын
Please optimize your python code to use a dictionary to speed up calculations.
@joshix833
@joshix833 2 жыл бұрын
I ran the python code (without the semicolons and proper snake_case names of course) with PyPy 7.3.9 (Python 3.8.13) and CPython 3.10.5 For me pypy took ~6 seconds. Python took ~60 seconds. So code in python and run with pypy for good performance. Edit: By just changing `i//2+1` to `int(sqrt(i)) +1` and adding `from math import sqrt` to the top of the file. Even Cpython takes less than one second.
@ObaidahNaseer
@ObaidahNaseer 2 жыл бұрын
what pypy?
@joshix833
@joshix833 2 жыл бұрын
@@ObaidahNaseer pypy is python in python
@1234567qwerification
@1234567qwerification Жыл бұрын
Since Python 3.8 you can use from math import isqrt (Not much of improvement if done once, though.)
@abhijeetkrishnan
@abhijeetkrishnan Жыл бұрын
That changes the algorithm. You could do the same for the C/C++ and assembly versions and they would get faster as well
@joshix833
@joshix833 Жыл бұрын
Yes sqrt changes the algo. But just using pypy doesn't. And 6 seconds is almost the same as 5.3
@hgmdev
@hgmdev 3 жыл бұрын
Pascal/Delphi "2569ms 22044" 13 lines of code (on my machine, of course) function isPrime(n: integer): Byte; begin for var i := 2 to n div 2 do if n mod i = 0 then Exit(0); Result := 1; end; begin var numPrimes := 0; for var i := 2 to 250001 do Inc(numPrimes, isPrime(i)); writeln(numPrimes); end.
@YouRich92
@YouRich92 3 жыл бұрын
Replace the upper limit of your "for" loop with trunc(sqrt(n)) and you will divide that run time by 100 for 250000 integers tested. On my computer it goes from 10800ms to 94ms using FPC compiler. No point picking a "faster language" if you start with a bad algorithm ;-) Anyway the point is that with Python one can put together a program really quick. Even if I am proficient with Pascal for some Python is quite a bit more handy.
@bwc1976
@bwc1976 3 жыл бұрын
I wish Pascal was still popular today! All the speed of C++, but with the readability of Python.
@alexeynezhdanov2362
@alexeynezhdanov2362 3 жыл бұрын
@@YouRich92 now do the sqrt in ASM
@YouRich92
@YouRich92 3 жыл бұрын
@@alexeynezhdanov2362 If I was using x64 I would do : cvtsi2sdl %ecx,%xmm0 sqrtsd %xmm0,%xmm0 cvttsd2si %xmm0,%r8 Anyway a rapid square root estimator is easy to implement Newton-Raphson algorithm. One have to iterate over : sqrt_n = (sqrt_n+n/sqrt_n)/2. There is clever tricks to initialize sqrt_n, for instance if you have an asm instruction which return the highest bit set to 1. That allows you to get the estimate in 3 iterations only for 32b integers and thus to unroll the loop. But actually you can avoid by replacing the for loop by a "while (i*i
@YouRich92
@YouRich92 3 жыл бұрын
@@bwc1976 Yep. Pascal is lacking some modern language features and not trendy because of strong typing, but somehow it provides a kind of safeguard which enable you to program relatively fast without spraying your code with pitefall everywhere. At the same time, Python's interpreted nature enables you to debug your program interactively which is very comfortable.
@ofemuguru9393
@ofemuguru9393 2 жыл бұрын
Speed is just one of the many reasons I love C. Moreover, I get to SEE and UNDERSTAND what my code is doing.
@caleb-hess
@caleb-hess 3 жыл бұрын
What a person accomplishes in life is rarely based on the performance of the technology.
@LWmusik
@LWmusik 2 жыл бұрын
I don't know much about programming, but I'm considering getting into audio programming as music and audio is a great passion of mine. I always wondered though, "why do people say you have to use c++ for audio? Python seems much more user friendly". Now I get it lol. Wouldn't wanna press down a piano key only to have the music come out sometime later, when the music feels like coming out or whatever lol
@DarmaniLink
@DarmaniLink 2 жыл бұрын
i'm gonna give you the advice nobody else will Computers are so fast that for most purposes the performance overhead of python is negligible. The problem with starting with python is that it has tons of cute hacks and most python resources believe in a system that relies less on writing logical code like every other language and more of arbitrary memorization of the "correct" way to do something. I'd recommend starting with C++ or C - learn what's actually going on under the hood, how all these things work. If you move onto any other language rather than seeing the toys python has built into it as a cute hack you'll be sad that those languages don't have it
@LWmusik
@LWmusik 2 жыл бұрын
@@DarmaniLink see, music production doesn't fit into "most purposes" tho :) A performance difference of like 2 milliseconds is a huge deal in music software
@DarmaniLink
@DarmaniLink 2 жыл бұрын
​@@LWmusik ​The difference we're talking about is in microseconds and if you use something like cython the overhead goes down to the nanoseconds the problem with python for learners is the syntax
@LWmusik
@LWmusik 2 жыл бұрын
@@DarmaniLink the difference in the video is 49 whole seconds though, haha
@DarmaniLink
@DarmaniLink 2 жыл бұрын
@@LWmusik that's because he's using an unoptimized algorithm for python, haha
@СавелийИсаев-ъ8к
@СавелийИсаев-ъ8к 9 ай бұрын
And why we should use python for data science?
@MCRuCr
@MCRuCr 3 жыл бұрын
Python was made for learning and is useful to "glue" (existing) c/c++ frameworks together on a higher level - it is *_horrible_* for number crunching (like here). Also for prototyping it is good. Personally, I'm using Julia at the moment, it is dynamic like python, as fast as c and homoiconic like Lisp - really cool stuff
@Elrog3
@Elrog3 2 жыл бұрын
How is python good for prototyping if when you want to make the final product, you are going to have to port it to a non-sucky language anyways if you want a non-sucky product?
@MCRuCr
@MCRuCr 2 жыл бұрын
@@Elrog3 Because prototyping is not about making a final product, at least thats what I meant. Sure if you see prototyping just as a step in the overall process of creating a product, then it is obvious that python might not be the best choice. Also Talking about languages… I started using Julia and like it a lot
@bobpetersen6136
@bobpetersen6136 2 жыл бұрын
Would be interesting to see Fortran in this competition. Go with F90 and use the oldest compiler you can find, my bet is, it will outperform Python and C++ by far for this example
@vikinggeorge7007
@vikinggeorge7007 2 жыл бұрын
Treating new computers like old computers would ultimately slow the program down. Not sure where you're going with this. Again, there's TurboC if you want a minimal and fast codebase.
@Cretaelx
@Cretaelx Жыл бұрын
About the comparison between the code's speed of C/C++ and Python, for many applications, the performance difference between Python and lower-level languages might not be a critical factor. In situations where raw performance is crucial, C or C++ might indeed be preferred.
@_CazaBobos
@_CazaBobos 3 жыл бұрын
This video makes me think that coding in C can be actually faster to run than ASM. If you use good practices, maybe when C gets compiled, it does in a far more efficient ASM code that the handwritten one, thus becoming a better option both for development, and run time.
@PingoX
@PingoX 3 жыл бұрын
if you are a bad ASM coder, that statement is true
@ped7g
@ped7g 3 жыл бұрын
If you give asm expert enough time, they will often manage to improve the C/C++ compiler output further. Although unless you are seasoned performance coder, they will probably quickly return to you without writing any asm just pointing out what to change in original C source to get even better code already from compiler. And it may take some time to exhaust this part of process, but it may have serious ROI. Investment into further tuning the assembly itself makes sense only if your code is running for long time, like over one second (in one particular calculation), like optimising 3D engines which process millions of coordinates in second, etc. For fizzBuzz and isPrime examples it's not really worth it. :) (if you are summing price of your shopping list with 10 items and your app needs more than 10ms, you are doing it wrong... or in python...)
@_CazaBobos
@_CazaBobos 3 жыл бұрын
@@ped7g hahaha last part killed it
@ped7g
@ped7g 3 жыл бұрын
@@_CazaBobos hm? the "or python"? Python has just much bigger runtime cost, especially starting the code first time. And it gives you many advantages over C and ASM thanks to those upfront costs. But speed is not one of them. But that's ok. It's still excellent fit for many use cases, even for summing 10 item shopping list for your personal need, as having wait 100ms instead of 10ms will make hardly any major difference in your life. But if you would be creating "sum your shopping list online with us" online web service and you would be capable to resolve 10 or 100 queries per second on your server - may make difference. Although it will still very likely make more sense to first deliver python version of that service, and give yourself headache about porting to C/asm when you have enough visitors, which is the lot harder part of creating good service. If you have good service which is just slow and too much server heavy, you are very likely in position to hire some actual experts and let them rewrite your clunky prototype code with performance goals set. If you spend first a year to code performant service, which is not used at all, you are in much worse position.
@_CazaBobos
@_CazaBobos 3 жыл бұрын
@@ped7g yes. It was exactly about that. I know, python has a reason to exist, but I think using it to work with any database is a shitty idea. Wouldn't use C++ either as it's a pain in the ass to use for networking, though Java and C# are great choices for backend, and are vastly faster than Py.
@orionprime2543
@orionprime2543 3 жыл бұрын
Damn, assembly is really that complicated
@thedrunknmunky6571
@thedrunknmunky6571 3 жыл бұрын
It has a bit of a learning curve, but once you get used to it it follows some common patterns for things. It is really fun to see it work tho! In college we were taught how to program in MIPS assembly (emulated on some software I don’t recall, but it ran on JVM). However as you can “C” ( heheh), C runs plenty fast enough already.
@orionprime2543
@orionprime2543 3 жыл бұрын
@@thedrunknmunky6571 true, i agree my good man, C is fast!
@maxmuster7003
@maxmuster7003 3 жыл бұрын
No assembly is easy to learn. C is 100 times more complicated to learn.
@GabrielM01
@GabrielM01 3 жыл бұрын
binary is easier
@djouze00
@djouze00 3 жыл бұрын
@@thedrunknmunky6571 The software was probably MARS. It's an awesome software.
@Noobisnoob1234
@Noobisnoob1234 2 жыл бұрын
What will happen if you write in x86 ASM but later asked to run on ARM instead? Double the pay? Since paid hourly ?
@mgr1282
@mgr1282 3 жыл бұрын
Python can be fast. Scientific & deep learning packages in python are written in C and are fast. Even we can use Numba or PyPy to make our Python code fast. Speed isn't the main purpose of Python. Easy to learn, easy to code, less line of code, ...
@MechanicalMooCow
@MechanicalMooCow 3 жыл бұрын
MuH PAcKaGeS
@amagicmuffin1191
@amagicmuffin1191 3 жыл бұрын
@@MechanicalMooCow ?
@cgme9535
@cgme9535 3 жыл бұрын
Exactly. It's also arrogant to think that a programmer would write better C code than large, large bodies of other developers that have already created and refactored ML libraries -- similar efficient libraries as well. "I write better, more optimized code than thousands of other developers. I'll just rewrite these machine learning libraries myself! I'll let those plebs write in Python. They'll only ifnish 500x faster, but at least I'll have my pride."
@MechanicalMooCow
@MechanicalMooCow 3 жыл бұрын
@@cgme9535 "python is the only language that supports third party libraries"
@elchippe
@elchippe 3 жыл бұрын
@@MechanicalMooCow there a lot of third party libraries for c++, they are a pain to build and use but they exist anyway.
the TRUTH about C++ (is it worth your time?)
3:17
Low Level
Рет қаралды 834 М.
I made the same game in Assembly, C and C++
4:20
Nathan Baggs
Рет қаралды 843 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Why Majora's Mask's Blue Dog Took 25 Years to Win the Race
21:04
Vidya James
Рет қаралды 3 МЛН
It's not hard to make games in C++
6:23
Low Level Game Dev
Рет қаралды 129 М.
I made maps that show time instead of space
10:44
Václav Volhejn
Рет қаралды 1,3 МЛН
Learning C# In A Week... Otherwise I Fail University
9:04
Every Programming Language Explained in 5 minutes
5:18
Mr.PiwPiew
Рет қаралды 398 М.
how NASA writes space-proof code
6:03
Low Level
Рет қаралды 2,4 МЛН
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 330 М.
Python Vs C++ Vs Java!
4:41
ByteByteGo
Рет қаралды 596 М.
I Made The Ultimate Cheating Device
9:39
ChromaLock
Рет қаралды 1,9 МЛН