Python vs Fortran vs Octave (Matlab) side-by-side performance comparison

  Рет қаралды 125,471

xmdi

xmdi

2 жыл бұрын

Which free scientific computing language is the fastest to program and execute? The answer probably won't surprise you because it's obvious.

Пікірлер: 263
@taragnor
@taragnor 2 жыл бұрын
You need to do Fortran vs C vs Rust. That'd be an interesting battle to see which comes out on top.
@xmdi0
@xmdi0 2 жыл бұрын
agreed. if anyone has some ideas for fair benchmarks, let me know. something that can be implemented relatively quickly without non-standard libraries
@evertonsantosdeandradejuni3787
@evertonsantosdeandradejuni3787 2 жыл бұрын
My thoughts exactly
@evertonsantosdeandradejuni3787
@evertonsantosdeandradejuni3787 2 жыл бұрын
@@xmdi0 No Ideias, but please do. Alredy clicked on the Bell Icon
@dmitriidemenev5258
@dmitriidemenev5258 2 жыл бұрын
@@xmdi0 Rust is meant to be used with non-standard libraries (=crates). My personal favorite for benchmarking is criterion.
@dilgarda
@dilgarda 2 жыл бұрын
@@xmdi0 Also include a simple I/O operation. I really wonder the capability of reading and writing capabilities.
@coleshores
@coleshores 2 жыл бұрын
It’s not cheating to use C binded libraries. Languages like python are designed to be used like that as glue languages. If you’re doing high performance computing in pure python you’re the one using it wrong.
@JalenThompson0
@JalenThompson0 2 жыл бұрын
I’d like to think he’s being sarcastic
@deidyomega
@deidyomega 2 жыл бұрын
Yeah, I write python, and I hit a math problem, I drop to C, write a lib, the expose the .so file in python and keep working. Simple, effective, and get to keep my high productivity in python.
@Luxalpa
@Luxalpa 2 жыл бұрын
You just confirmed that it would be cheating. If you're using it wrong for high performance computing (which I agree with) then it would also be wrong to measure it's performance to begin with.
@deidyomega
@deidyomega 2 жыл бұрын
@@Luxalpa I do agree measuring its preformace for algros is wrong. I dont know any devs who spend their time in python writing algros like that. We are building large applications with 100's of dependances and 100k+ loc. When you hit that size, what matters is developer read speed, not compile time, and honestly.. not even run time. I mean, we gotta keep the hot path fast, but again 99% of the time for me at least, its the network thats the bottleneck, not the application.
@Jack-hd3ov
@Jack-hd3ov 2 жыл бұрын
It's cheating if you're comparing Python as a language to another language like C or Fortran, which is what's happening in this video. Sure you might be able to get better performance using Python with libs written in a faster language than you could with straight Python but that doesn't make Python fast, you get good performance because the language used to write the library is faster than Python.
@FR33Willi
@FR33Willi 2 жыл бұрын
"Time to write code" is a really weird benchmark considering you keep erasing mistakes and probably already memorised certain lines in some languages but not others. The fortran code even has more lines than the python code but took less time to write? Also the python and octave code isn't vectorised, which is the main way to write linear algebra code in these languages and basically solves your 'verbosity' problem. I mean, one advantage python and octave have over fortran is that you don't have to use for loops for everything.
@pedromiguelareias
@pedromiguelareias 2 жыл бұрын
Not even a chance. Fortran and C++, that's it. All the rest is a passing fashion.
@FirstLast-kv1iq
@FirstLast-kv1iq 2 жыл бұрын
@@pedromiguelareias lol do you have brain damage?
@DoctorMandible
@DoctorMandible 5 ай бұрын
@@pedromiguelareias That's hilarious. Nvidia is building a multi-billion AI business that runs entirely on Python.
@pedromiguelareias
@pedromiguelareias 5 ай бұрын
@@DoctorMandible Python just makes use of C, C++ and Fortran libraries. It's a wrapper and inefficient at that.
@bartl9798
@bartl9798 2 жыл бұрын
Never have I come across a professional programmer that considered any technique that worked cheating.
@niconeuman
@niconeuman 2 жыл бұрын
Just FYI in Octave you can write C++ files and compile them to oct-files which can be called as built-in functions. They will increase the speed of code with many loops. Of course there's no competing with Fortran or C++ but ease of use for scientists/engineers also has its merits.
@danielthirtle666
@danielthirtle666 2 жыл бұрын
So Octave is the fastest language if you write all of your code in C++?
@paperclips1306
@paperclips1306 Жыл бұрын
​@@danielthirtle666 hahaha
@ZackDia-Ptr
@ZackDia-Ptr Жыл бұрын
Thought Octave is just a library... xD
@goose_clues
@goose_clues Жыл бұрын
Is "using C++ is easy for scientists" some kind of joke, or this person is.
@niconeuman
@niconeuman Жыл бұрын
@@goose_clues you are talking about my comment? Because it says the opposite of what you are implying
@julianmahler2388
@julianmahler2388 2 жыл бұрын
I have no clue about Octave, but in regard to Fortran vs. Python you're comparing a highly optimized (-O3 flag) onetime compiled Fortran code to a Python script that keeps loading the NumPy module each time you run it. Probably 80 % of your Python code's execution time is due to the NumPy module being loaded over and over again. I've made similar speed comparisons between C, badly written Python, "pythonic" Python, Python + NumPy, Cython etc. If you load NumPy once and measure the net execution time (=the time the actual execution takes without loading the module), your code will be marginally slower than C, if at all. Obviously, if you repeat a vacuous comparison of gross execution time (loading module + executing the code) vs. net execution time of a precompiled optimized code ten times in a row, the gap between Python and Fortran grows bigger and bigger.
@dimi5862
@dimi5862 Жыл бұрын
So, your point is python is slower?
@saitaro
@saitaro 2 жыл бұрын
You use numpy and then for-loop over the matrix, this is misusing of the library.
@Rau379
@Rau379 10 ай бұрын
Hi Sataro, why for-loop over the matrix is misusing of the library? Is there another way to reach each component of the matrix with numpy?
@SmPro1337
@SmPro1337 2 жыл бұрын
Cool content. Found you through my recommended videos. Earned my sub.
@7th_CAV_Trooper
@7th_CAV_Trooper 2 жыл бұрын
FORTRAN was the second language I learned. Glad it's still a thing.
@manuelsuazo1125
@manuelsuazo1125 2 жыл бұрын
x2
@shayhan6227
@shayhan6227 2 жыл бұрын
You should include the Version of python and python libraries you used to allow for watchers far in the future to compare and benchmark against it so they can understand the progress made over the years.
@spiderjerusalem
@spiderjerusalem 2 жыл бұрын
I respect FORTRAN and you have amazing Vim skills but that is not the way to compare it. This is ok for 30 lines of code but what happens when you are working on a 300000 lines of code project where dozens of scientists need to collaborate? No one picks python due to its speed, but due to its easiness-to-code and readability, the very same reason that made FORTRAN popular back in the day.
@taoliu3949
@taoliu3949 2 жыл бұрын
Speed is still important. What could take days on FORTRAN may take weeks to compile and run. That's why it's still king in certain industries like Physics where you need to crunch high amounts of data.
@matela6635
@matela6635 2 жыл бұрын
The loop should've been inside the program after imports. I think it's unfair how you benchmarked octave and python in the second test. Both languages have the overhead of loading the interpreter and Python has also to import the modules which takes a comparatively huge amount of time compared to time it takes to get the actual task done. That would be more representative of real world use as in real applications the time it takes to finish the task dwarfs that of loading.
@m0zzar353
@m0zzar353 10 ай бұрын
time to import libraries is still time that the code takes to run. part of the beauty of a language like fortran is that it needs no libraries for mathematical computation no?
@ondraodehnal1250
@ondraodehnal1250 2 жыл бұрын
It would be nice to include Python with Numba, which is not really hard to use. Then you might get faster code with Python than Octave and maybe even Matlab.
@saitaro
@saitaro 2 жыл бұрын
Man, the author thinks using numpy (or even importing it as np) is cheating, for Numba you go to jail lol
@klittlet
@klittlet 2 жыл бұрын
@@saitaro the test involves using the languages by themselves
@saitaro
@saitaro 2 жыл бұрын
@@klittlet I got it, but if he decides to use numpy (which is not a part of the Python stdlib), then it should be done properly, not for-looping over the np.array. It's just wrong to write Python code in the style of Fortran, and vise-versa. IMHO, in the end, comparative tests should be about using tools from whole ecosystem of the language. It is especially important for scripting languages like Python.
@VladimirTheAesthete
@VladimirTheAesthete 2 жыл бұрын
Nice comparison but isn't the whole point of vectorized data handling packages like numpy, scipy and pandas is to avoid for loops? I'm not sure how this particular example can be implemented otherwise but iterating over arrays or dataframes is basically going against the spirit of these libraries, something that you do as a last resort.
@GenTheSnail
@GenTheSnail 2 жыл бұрын
It's like the cfop roux zz debate except there's objective benchmarks that you can hit (zz is Fortran in this example)
@ruffleduck2909
@ruffleduck2909 2 жыл бұрын
yes gen
@Fritzinat0r
@Fritzinat0r 2 жыл бұрын
You sir have done the needful
@ianbridges6040
@ianbridges6040 2 жыл бұрын
I wrote a super scuffed “paper” comparing 2 ways of solving systems of linear equations for school and I used Python to solve all of the 15,000+ systems… thanks to this video I realize I should’ve just used Fortran.
@theairaccumulator7144
@theairaccumulator7144 2 жыл бұрын
Should've used c++
@deidyomega
@deidyomega 2 жыл бұрын
Fortran is a very challenging language. C/C++ would give you about equal results, with way less screaming into the void. There's a reason basically no one uses fortran anymore.
@theairaccumulator7144
@theairaccumulator7144 2 жыл бұрын
@@deidyomega C++ would probably give you much better results if you used multithreading and a sane linear algebra library which implements SIMD. It would probably solve all those equations within a second.
@klittlet
@klittlet 2 жыл бұрын
@@deidyomega yeah no
@deidyomega
@deidyomega 2 жыл бұрын
@@klittlet Are you disagreeing with the fact people dont use fortran anymore? Or that its challenging? Or that C/C++ have comparable results? All of those can be backed up pretty easily.
@niyaziugur
@niyaziugur 2 жыл бұрын
as an embedded engineer, i'm curious for Rust vs C/C++ nowadays.
@LoL-ox8li
@LoL-ox8li 2 жыл бұрын
12 like almısın nıyazi
@adreto2978
@adreto2978 5 күн бұрын
Fortran wins
@sydelcid
@sydelcid 2 жыл бұрын
I got 3.54ms per loop for the scipy code. Also numpy code can be made to avoid for loops as much as possible, it gives 154ms per loop Scipy code: %%timeit import numpy as np import scipy.linalg as la n = 200 A=np.random.rand(n,n) P,L,U=la.lu(A) print(np.max(np.abs(np.matmul(L,U)))) 100 loops, best of 5: 3.54 ms per loop
@SuperSulc
@SuperSulc 2 жыл бұрын
Your results are meaningless without the other two solutions or at least the specs of the system.
@arsgorrussia477
@arsgorrussia477 2 жыл бұрын
Great channel! I think you have a good potential in growing the auditory. Greetings from Russia)
@lonterel4704
@lonterel4704 2 жыл бұрын
С чего бы?
@flaguser4196
@flaguser4196 2 жыл бұрын
curious whether fortran libraries have caught up with current scientific computing... the speeds look compelling
@julienpepin6
@julienpepin6 2 жыл бұрын
wouldn't it be cooler to add compiling time into the trace ? like, a potential language which is written like python/octave but compiles to the same bytes as fortran would blow up this comparison..
@trafalgarla
@trafalgarla 2 жыл бұрын
There's Julia too, but it's JIT compilation takes a few seconds the first time you run a program.
@benjlung
@benjlung 2 жыл бұрын
Pretty sure Julia would win in programming time (assuming the author is similarly experienced in all languages). In run-time, Julia would be a close battle with Fortran if you include compilation time in both languages or none. Even if including compilation time, Julia should be faster than Python and Octave here.
@unknown3158
@unknown3158 2 жыл бұрын
AFAIK Matlab is faster than Octave. Also, I have a simple rule when it comes to Python, if I need to use many for loops to do it (and there is no other way, or it is too complex to implement), then I am better off just using a different language (like C or C++).
@xmdi0
@xmdi0 2 жыл бұрын
this 100%. in my experience matlab is usually 2-10x faster than octave, but there are ways to compile octave yourself to build in some of these (intel?) accelerations. something i have never needed to do, but i read about once
@dickpiano1802
@dickpiano1802 2 жыл бұрын
There is a technical term for that. Implementations in MATLAB/Python/Octave need to be "vectorized". If you are writing C in MATLAB/Python/Octave then you shouldn't be using MATLAB/Python/Octave.
@swan4959
@swan4959 2 жыл бұрын
Java vs C# vs python
@shimadabr
@shimadabr Жыл бұрын
I would LOVE to see a comparison of Julia, Python, Fortran and C++ for this kind of application. Julia is the new kid on the block that people seems pretty excited about
@zweiwing4435
@zweiwing4435 Жыл бұрын
Can you do for Rust, Carbon Google, Bun, and Zig?
@michaelmonkenbusch5591
@michaelmonkenbusch5591 2 жыл бұрын
Interesing comparison clip. Fortran is also my favourite language to solve scientific and engineering problems. Partly becuase this was my first and continuously used computer language. In particular the modern enhancements make it an up to date high performanc e computation tool. Motivated your comparison I tried to check what in practice (also using the python import libraries and having own code or slatec libraries in fortran) could be achieved by python (3.6) vs gfortran: Problem 1: a nasty integration (using scipy.quad vs. adaptive integration in f90) of sin(1/sqrt(x)) from 0 to X with an accuracy level of 1e-9, X was varied form 1 to 100 in 0.01 steps to accumulate enough time: result python 44sec vs Fortran 0.8sec (corroborating your result). However, employing numpy to solve a large linear equation problem (rand om coefficients, 100 realisations) compared to the old dgefs (slatec) routines yileds a mixed result: for a 500x500 matrix fortran wins by a factor of about 2 (2.5sec vs 5sec), for a 1000x1000 matrix pyzhon is slightly faster 21sec vs 25sec and for a 2000x2000 Python (numpy) is faster 90sec vs 3.5 min. Obviously the numpy library uses some parallel processing as can be seen by the CPU usage which yields an advantge compared to the single threaded old dgefs routine. Using modern routines with parallelisation would probably restore the initial factor. Howver, with the compiled numpy code the disadvantage of the interpreted language is largely mitigated for problems where the heavy computing is absorbed by these function. Still I favour Fortran also because of other reasons as strict backward compatibility (can icorporate code from 50 years ago without problems), clarity (if written properly) . The latter comparison code fragmets if fortran and python are: FORTRAN program testsolve implicit none integer, parameter :: n = 2000 double precision :: A(n,n), B(n), X(n) integer :: i ! for linalg solving: A * X = B do i=1,100 call random_number(A) call random_number(B) call lesolve(A,n,B,n,n,X) ! wrapper for slatec dgefs B = B - matmul(A,X) ! Check the solution write(*,*)"Mean deviation(",i,") = ", norm2(B)/n enddo end program testsolve PYTHON: import numpy as np import numpy.matlib as ml import numpy.linalg as la import random import time t1=time.perf_counter() n=2000 A=ml.zeros([n,n]) B=np.zeros(n) nr=range(n) repeat=range(100) for l in repeat: A=np.random.rand(n,n) B=np.random.rand(n) X=la.solve(A,B) BX=ml.matmul(A,X)-B u=np.sqrt(ml.vdot(BX,BX))/n print(f'try no {l} yields residual error = {u}') t2=time.perf_counter() print(' ') print(f'Python(numpy): timer={t2-t1} sec with problem size={n}')
@hasanhanzalah9799
@hasanhanzalah9799 2 жыл бұрын
Very informative. Can you do similar video on C/C++ vs dart vs golang?
@user-vs6kc9xu4r
@user-vs6kc9xu4r 2 жыл бұрын
You code use elementwise function. Why you use for loops in python and fortran?
@gordonfreeman4357
@gordonfreeman4357 2 жыл бұрын
What language is vim interface in?
@heretixseven7732
@heretixseven7732 2 жыл бұрын
Can you do that in C too? Compare?
@marcusunivers
@marcusunivers 2 жыл бұрын
This Keyboard ASMR is so satisfying xD
@richdelgado3405
@richdelgado3405 2 жыл бұрын
I used to program in Fortran and Cobol. Eventually, the SQL app tools started coming out and people would just laugh at the "old school" languages like Cobol. Then they tried to use their fancy new db tools to process a few hundred thousand records. I could go through them in a few minutes. Their SQL just slowly chugged along.
@sycration
@sycration 2 жыл бұрын
There are some pretty fast ORMs out there (I have some experience with Diesel) but I usually return to using SQL 😁
@manuelpena3988
@manuelpena3988 2 жыл бұрын
why do you use A.__sub__(...) instead of A - ... ?
@lennutrajektoor
@lennutrajektoor 2 жыл бұрын
Octave is re-branded Basic?
@topec1263
@topec1263 2 жыл бұрын
Octave is like that kid when he walks in "I CAN RUN FASTER" and ends up being in last place every year for track & field.
@agustinpizarro
@agustinpizarro 2 жыл бұрын
You are missing an important metric, how much time you spent learning those languages to do useful work.
@misterbalise
@misterbalise 2 жыл бұрын
it is not the purpose of this video ;)
@abrahammiranda2329
@abrahammiranda2329 5 ай бұрын
Is there someone who knows here how to start programming in Fortran, I need it please. I mean, which compiler could you suggest me, thanks in advance.
@thaddaeusmarkle1665
@thaddaeusmarkle1665 2 жыл бұрын
At 1:54 what with python how do you get those parens to add themselves. You're obviously using vim, is that a plugin or a custom config thing?
@trianglesupreme
@trianglesupreme 2 жыл бұрын
lol
@FunOrange42
@FunOrange42 2 жыл бұрын
i'm pretty sure he's typing them manually, just looking at the parens highlight to know when to stop typing
@luistorres5805
@luistorres5805 2 жыл бұрын
what is the name of the application
@snarbywrx
@snarbywrx Жыл бұрын
Why not use both? I use Python in a Jupyter notebook and F2Py in Fortran code for CPU intensive calculations.
@_Mr.9-5
@_Mr.9-5 2 жыл бұрын
Are you coding on phone or something? Is cool if you coding in phone. what app you use
@xmdi0
@xmdi0 2 жыл бұрын
Just a vertical window on my desktop. Would be cool to have a phone app for that - especially for traveling. If you find a good one, let me know.
@_Mr.9-5
@_Mr.9-5 2 жыл бұрын
@@xmdi0 java n ide I want learning java but i don't have PC so i learn in this app idk this is good? I think your knowledge more than mine
@whamer100
@whamer100 2 жыл бұрын
one thing to add as well, is correct me if im wrong, but i believe writing to stdout can slow a program a decent bit if it's running in a single thread
@xmdi0
@xmdi0 2 жыл бұрын
Definitely true.
@olgierd245
@olgierd245 2 жыл бұрын
I LOVE THESE
@jff4131
@jff4131 2 жыл бұрын
numpy+for?
@necroorcen
@necroorcen Жыл бұрын
That looping over numpy array made my eyes 🩸
@dedebenui
@dedebenui 2 жыл бұрын
for both octave and python, you could do away without for loops and the code would run much faster. I'm not sure if you're trolling or if you just don't know how to use these languages
@anarchistalhazen7084
@anarchistalhazen7084 2 жыл бұрын
If I want to learn an auxiliary lang to python for scientific computing, should I go with C or Fortran?
@xmdi0
@xmdi0 2 жыл бұрын
C will be easier to learn for you because there are more resources, and it's more similar to Python. The main advantage to Fortran is that all this matrix algebra stuff is baked in, whereas you need a library or your own data structures to do that stuff in C.
@anarchistalhazen7084
@anarchistalhazen7084 2 жыл бұрын
@@xmdi0 Ty, indeed I did not find as good and many resources for FORTRAN, but I thought it had an inheritant advantage over C or something. But is reading files really that slow in FORTRAN? (which could be a different comparison vid)
@Labicraft
@Labicraft 2 жыл бұрын
I'd say Fortran, although the language is quite awful everybody in science (at least physics) uses it if they are not going for python (I never used it but I guess it must have tons of libraries?).
@idiosinkrazijske.rutine
@idiosinkrazijske.rutine 2 жыл бұрын
Both
@Alche_mist
@Alche_mist 2 жыл бұрын
@@Labicraft It really has a ton of well optimized libraries and is quite possible to understand if you come from other scientific background than computer science (which can't be said in all honesty about C or C++ when you need the amount of control typically needed in physics for huge calculations). Basically, it takes away some of the most notorious footguns from the coder. That said, I'd also like to draw attention to Julia, which is a language specifically made to make the number crunching typically done in physics and statistics easier to both write and execute (similar to Fortran, but with a more modern look and options).
@vanlee6643
@vanlee6643 9 ай бұрын
Hey I know its been a long time since you posted this. But i want to ask everyone here, is fortran a dying language right now? I am an engineering student, will learning fortran be a waste of time?
@xmdi0
@xmdi0 9 ай бұрын
I can confirm for you that Fortran is still used in academia, particularly in aerospace engineering, but long gone are the days that engineers actually seem to care about writing fast programs themselves. I see more people either using scripting languages or specialized software to solve their problems, instead of writing the code themselves.
@yanceq2690
@yanceq2690 2 жыл бұрын
Im subbing, do more things like this please
@mustafa-gokce
@mustafa-gokce 2 жыл бұрын
Well, Python results like that because you did it wrong :)
@superJerrySong
@superJerrySong 2 жыл бұрын
please make a epic fight beetween javascript and python or java vs C++*_*
@LouisChiaki
@LouisChiaki 2 жыл бұрын
The person clearly type much slower in python even for the same code and same amount of characters...
@PiroKUSS
@PiroKUSS 2 жыл бұрын
It was nice hearing the keystrokes.
@severgun
@severgun 2 жыл бұрын
Python is good for prototyping, utils scripting, launch automatization and data pre/post manipulation. Specific tasks in between must be done using specific tools.
@stevy2
@stevy2 2 жыл бұрын
Actually makes me happy I use NodeJS. It trades blows with Java when it comes to speed.
@Techiesse
@Techiesse 2 жыл бұрын
You shouldn't print anything in the middle of the benchmark. IO is very slow and doesn't make sense during the calculation
@pocztowka2
@pocztowka2 2 жыл бұрын
you should also measure a time of other co-worker sit watching the code and thinking "what the heck it does?"
@cow_tools_
@cow_tools_ Жыл бұрын
Love the attitude.
@manuelsuazo1125
@manuelsuazo1125 2 жыл бұрын
U need try compiler optimizations for fortran. -O3 and -Ofast. gfortran -Ofast nn.f94
@manuelsuazo1125
@manuelsuazo1125 2 жыл бұрын
and C, C++.
@marcomoretti9768
@marcomoretti9768 2 жыл бұрын
Sei italiano? Are you italian?
@TheZethera
@TheZethera 2 жыл бұрын
Would be interesting to see R in there
@TheUser357
@TheUser357 2 жыл бұрын
I don’t know, maybe there are beginners to whom such videos are somehow useful, but in fact a normal developer knows very well that each programming language has its own advantages, purposes of application and best coding practices. What's the point of comparing airplane, lorry and tractor on what is the faster to go for grocery shopping to a nearby store? Dislike from me.
@miguel-oi5uz
@miguel-oi5uz 2 жыл бұрын
recommend learning fortran in 2022?
@justasydefix6251
@justasydefix6251 2 жыл бұрын
are you an engineer? are you a mathematician? If not fortran might be of little use for you. If Yes, Then you probably needs to buy Matlab after all...
@miguel-oi5uz
@miguel-oi5uz 2 жыл бұрын
@@justasydefix6251 I am studying computer engineering
@shayhan6227
@shayhan6227 2 жыл бұрын
Can you do a Rust vs C or Rust vs C++ or C++ vs NodeJS vs Python?
@Luxalpa
@Luxalpa 2 жыл бұрын
C++ vs NodeJS vs Python? Why even make this comparison? We already know C++ is fastest, then NodeJS and slowest will be Python.
@shayhan6227
@shayhan6227 2 жыл бұрын
@@Luxalpa Unfortunately while I agree with you, I've had to debate with people on which was faster and I would like to set a hard benchmark to settle all debates.
@nishanth6403
@nishanth6403 2 жыл бұрын
@@shayhan6227 lmao
@MarkWernsdorfer
@MarkWernsdorfer 2 жыл бұрын
isn't using numpy cheating according to your definition as well?
@rupen42
@rupen42 Жыл бұрын
Not if you use it wrong and iterate through the values with a for loop, apparently.
@michaelgolub2019
@michaelgolub2019 2 жыл бұрын
The results are quite predictable. Interpreters work slower, but in general require less time for coding. Python unlike Octave/MATLAB or Fortran is a multipurpose language, so it may be slower in all aspects. The more interesting could be comparison of outputting a graph (Fortran has no intrinsic graph tools). I use Fortran for many decades, used MATLAB for some time and sometimes use Octave and gnuplot. I have some basic info about Python and responses from those how use it.
@aaaaa-yv1zr
@aaaaa-yv1zr 2 жыл бұрын
Demo 2 on Matlab 2021b, run time is 0.026 s. tic for i=1:10 n=200; A=rand(n,n); [L,U]=lu(A); norm(L*U-A,Inf); end toc
@alio263
@alio263 2 жыл бұрын
Which language should I learn as an absolute beginner?
@FR33Willi
@FR33Willi 2 жыл бұрын
My opinion: pick Python if you want programming to be complimentary to your job, pick Java if you want your job to be a full-time software engineer. The most important thing is to just get started though, it doesnt really matter what you pick.
@alio263
@alio263 2 жыл бұрын
@@FR33Willi I have started with HTML and CSS for doing simple websites, once i end those i think im going with java or javascript
@m_a_s6069
@m_a_s6069 4 ай бұрын
Why not look at Julia?
@stevenwilson5556
@stevenwilson5556 2 жыл бұрын
So Fortran smokes modern languages for things that Fortran is good at doing. What about things that Fortran isn't good at doing? It seems like the speed and efficiency of Fortran wins where Fortran is able to do things, but I'm sure there are a myriad of use-cases where Fortran can't even do certain types of things. Python isn't the most popular programming language due to efficiency and speed, but because it is easy and approachable to learn how to code in it, and it can do a whole lot of different things reasonably well. And with modern computer hardware, the differences in speed shown in these tests won't show up in many day-to-day tasks. Just my 2c.
@pedromiguelareias
@pedromiguelareias 2 жыл бұрын
Fortran is very simple. Implementation times are unbeatable and compile times are way faster than those of C++.
@donharrold1375
@donharrold1375 10 ай бұрын
This is really quite interesting. As an engineer what do I want? Something that is easy to program first and foremost. That’s why I use MatLab and Octave. I don’t want to fight the programming language - I want to develop a reliable solution with the least amount of time and effort possible! If standard libraries improve performance and speed up the development of code who cares. I’m not creating code for commercial applications. I use programming to solve problems the way an accountant might use a spreadsheet.
@mechconsultingmechconsulti4284
@mechconsultingmechconsulti4284 Жыл бұрын
Try Fortran against C, C++ or even Pascal...
@shivakumarnatrajan
@shivakumarnatrajan 2 жыл бұрын
I like that last comment Don't mess with Fortran....🤩
@georgerogers1166
@georgerogers1166 Ай бұрын
Julia would be interesting especially with more computationally intensive work.
@ZackDia-Ptr
@ZackDia-Ptr Жыл бұрын
How about Julia vs Fortran vs C++?? And of course we should agree upon which c++ version b/c there are a lot of them ... xD
@eclair1616
@eclair1616 17 күн бұрын
No. Assembly was the first programming language. In fact assembly is the human readable alternative of machine code. It is machine code. Fortran is the first language to have a compiler that then converts to assembly.
@bobsimpson9228
@bobsimpson9228 Жыл бұрын
Fortran vs c vs rust pls
@JDahl-sj5lk
@JDahl-sj5lk 2 жыл бұрын
Python is by design just objects. Well, objects is a nice way of saying it is pointers to everything. (pointers to pointers to data or even more pointers) Then on top of that it isn't compiled and it's very rich in built in features. Python is a nice scripting language; but i think it should have optional curly brackets by default. Why? Cause the argument that you wouldn't use python in a situation where you cant easily control whitespace indent is only true because you can't use curly brackets. It is precisely in small scripts i just want to send to an interpreter i could use something like python. I know and have used semicolons to mark newline, f.ex if you ever need to use eval() , and it's possible but way to difficult. But python does have some uses where speed isn't any major concern, altough i might change that statement if/when i get well into JavaScript. Still, python is a nice language to start with, it's sort of the modern basic. I didn't know Fortran was much used anymore though, remember it was one of the first languages i dabbled with.
@wangzhang2686
@wangzhang2686 2 жыл бұрын
most biased video against python I've ever seen. especially when I saw A.__sub__. Not to mention np.eye and np.abs v.s. np.identity and np.absolute.
@MauGame
@MauGame Жыл бұрын
python vs c/c++ vs golang plz
@felenov
@felenov 2 жыл бұрын
We need to see Haskell and Lisp, the father of all evil languages,
@shis10
@shis10 2 жыл бұрын
Python vs R vs Ruby
@elchippe
@elchippe 2 жыл бұрын
That is no cheating, using scipy library is not cheating. Using cython, numba or pypy is. And numba is not C, but an LLVM compiler for python.
@nikolageorgiev2341
@nikolageorgiev2341 2 жыл бұрын
It technically is cheating because most of the heavy calculation functions in SciPy are written in C/C++/Fortran. And when you compare how fast a language can crunch numbers, making that language run a program written in another language to do the hard work is def cheating. But Python isn't made to be a fast number crunching programming language so the comparison is pretty pointless anyway.
@L1Q
@L1Q 2 жыл бұрын
got recommended py/c/asm, watching this, pressing bell, off you go
@Orincaby
@Orincaby 2 жыл бұрын
"free knockoff matlib thing" -xmdi 2021
@meinkea
@meinkea 2 жыл бұрын
First of, did like the video However, 1:20 rubs me the wrong way. In the real world, the ecosystem of libraries at your disposal is likely more important the the language itself. Any comparison where you are not taking that into account might be entertaining but is not really informative to make a conclusive decision of which is faster. In the end languages are standards and what you are comparing are implementations of that standard, not the language. If there is a specialized Linear Algebra library that shreds through your task, you use it (regardless it be Python or Fortran) If using Python lowers the bar for a user to use said library, its fair game and should be concidered. If fortran has a exotic but useful Lin Alg library with hand assembly optimization, its fair game and should be considered. Maybe try making a video comparing these implementations where your leveraging these libraries?
@idk____idk6530
@idk____idk6530 2 жыл бұрын
Use Cython bro then see the speed ☣️
@playbyan1453
@playbyan1453 2 жыл бұрын
Great code and when to start a Fortran, generally numpy array slow sadly no other reason using. Fortran is faster.
@georgerogers1166
@georgerogers1166 9 ай бұрын
Julia is another good one for comparison.
@mithrillis
@mithrillis 2 жыл бұрын
I think the performance comparison is not meaningful unless you run a task that will at least take the fastest language a few minutes. Otherwise we are just comparing some constant overhead.
@kantocoder5046
@kantocoder5046 2 жыл бұрын
Try to code in FORTRAN IV rather than FORTRAN 95, that would be an experience!
@geovanniportilla7159
@geovanniportilla7159 2 жыл бұрын
May be you are using Cpython as interpreter. It's much better use pypy for fast speed. It's can posible that with pypy this results were similiar to fortran. Peace ;).
@mpotane
@mpotane 2 жыл бұрын
Python is slow when used incorrectly. It's quite rare to see nested loop in python even coding challenges / interview. Python coding is searching a module/ package, use its methods then solve the problem. You do not use numpy directly in Python.
@eltravos
@eltravos 2 жыл бұрын
1:40
@TheDEFCHER
@TheDEFCHER 2 жыл бұрын
Интересно как избавиться от вложенного цикла в этой задаче и какой будет от этого смысл?
@unknown3158
@unknown3158 2 жыл бұрын
Wait, what do you mean by "You do not use numpy directly in Python."? Pretty sure I've had to use Numpy in my projects many times, and there was no alternative. Also, Python is good and preferred because you can write the code very quickly and you don't really need to spend much time typing or thinking about what to type. If you actually need to make the code much more complex just to make sure it runs faster, you're better off using a compiled language. In other words, it's not always about being used "incorrectly", sometimes using it "correctly" makes the code too complex and takes too much time.
@TheDEFCHER
@TheDEFCHER 2 жыл бұрын
​@@unknown3158 поддерживаю. Нет смысла доказывать, что Pyton может быть таким же как и С/C++ (почти таким же) потому, что он *не* должен быть как C/C++
@TrueAlexCv
@TrueAlexCv 2 жыл бұрын
Python is slow always
@OM222O
@OM222O 2 жыл бұрын
The fact that you absolutely suck at writing python code probably doesn't help your case. Each language has it's benefits. Python is the fastest for prototyping and rapid development because of dynamic typing and a huge base of scientific libraries. If you really care about runtime, you can create custom C extensions to "cheat". Gives you best of both worlds.
@simonbode7356
@simonbode7356 2 жыл бұрын
Fortran does produce the fatsest executable.
@daravaf3
@daravaf3 2 жыл бұрын
C vs Fortran vs Julia
@givdb5513
@givdb5513 2 жыл бұрын
I can't believe you just wrote "sped"👈 not "speed"👈
@gustavderkits8433
@gustavderkits8433 Жыл бұрын
Matlab is not Octave. They are code compatible, but the engines will run differently on different tasks
@sr_meia_noite
@sr_meia_noite 2 жыл бұрын
That moment when .__sub__()
Programming Language Tier List
0:55
Conner Ardman
Рет қаралды 2,7 МЛН
Best programming language for science in 2024
36:07
Jonathon Riddell
Рет қаралды 2,5 М.
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 50 МЛН
Why Fortran?
4:09
Everything Functional
Рет қаралды 16 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 327 М.
I Made an AI with just Redstone!
17:23
mattbatwings
Рет қаралды 727 М.
Язык опередивший своё время
9:35
ExtremeCode
Рет қаралды 129 М.
Object-Oriented Programming is Embarrassing: 4 Short Examples
28:03
Fortran is dead - Long live Fortran!
21:28
Scalable Parallel Computing Lab, SPCL @ ETH Zurich
Рет қаралды 1 М.
What's the FASTEST Computer Language? C++ vs Fortran vs Cobol: E04
15:22
Compilers, How They Work, And Writing Them From Scratch
23:53
Adam McDaniel
Рет қаралды 100 М.
Compiled Python is FAST
12:57
Doug Mercer
Рет қаралды 101 М.
Easy Art with AR Drawing App - Step by step for Beginners
0:27
Melli Art School
Рет қаралды 9 МЛН
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 3,1 МЛН
В России ускорили интернет в 1000 раз
0:18
Короче, новости
Рет қаралды 1,8 МЛН