# Julia: Fast as Fortran, Beautiful as Python

**URL:** <https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405>\
**Category:** Uncategorized\
**Created:** [June 20, 2021, 6:21pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405 "2021-06-20T18:21:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [June 20, 2021, 6:21pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/1 "2021-06-20T18:21:13Z")

</div>

Here is an article and the associated Hacker News discussion where they compare Fortran and Julia and concluded that Fortran was slower:

- [Julia: Faster than Fortran, cleaner than Numpy | Hacker News](https://news.ycombinator.com/item?id=27571019)

Here is the Fortran benchmark:

- [julia-numpy-fortran-test/test-f2py.f90 at main · mdmaas/julia-numpy-fortran-test · GitHub](https://github.com/mdmaas/julia-numpy-fortran-test/blob/main/test-f2py.f90)
- [julia-numpy-fortran-test/test\_f2py.py at main · mdmaas/julia-numpy-fortran-test · GitHub](https://github.com/mdmaas/julia-numpy-fortran-test/blob/main/test_f2py.py)

Here is the Julia benchmark:

- [julia-numpy-fortran-test/test.jl at main · mdmaas/julia-numpy-fortran-test · GitHub](https://github.com/mdmaas/julia-numpy-fortran-test/blob/main/test.jl)

If somebody has time to investigate what is going on, that would be great. For simple benchmarks like this, Fortran should not be slower.

Update 6/27/2021: the blog post title was updated from _Julia: Faster than Fortran, cleaner than Numpy_ to _Julia: Fast as Fortran, Beautiful as Python_, so I updated the name of this thread also.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [June 20, 2021, 6:54pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/2 "2021-06-20T18:54:55Z")

</div>

Here is a preliminary analysis (`i_` is an imaginary unit `(0,1)`):

```auto
!$OMP PARALLEL DO PRIVATE(J)
do j=1,n
do i=1,n
    M(i,j) = exp(i_*k*sqrt(a(i)**2 + a(j)**2))
end do
end do
!$OMP END PARALLEL DO

```

It’s parallelized over `j`, so for a given `j`, the work to investigate is:

```auto
do i=1,n
    M(i,j) = exp(i_*k*sqrt(a(i)**2 + a(j)**2))
end do

```

Let’s rewrite the loop to only use real operations:

```auto
do i=1,n
    M(i,j) = cos(k*sqrt(a(i)**2 + a(j)**2)) + i_*sin(k*sqrt(a(i)**2 + a(j)**2))
end do

```

Perhaps let’s write it like this:

```auto
X = a(j)**2
do i=1,n
    Y = k*sqrt(a(i)*a(i) + X)
    M(i,j) = (cos(Y), sin(Y))
end do

```

Now let’s count the (real, i.e. not complex) operations:

```auto
+: 1
*: 2
sqrt: 1
sin/cos: 1 (one sin, one cos of the same argument)
R (memory read): 1 (only `a(i)` has to be read from memory in each iteration)
W (memory write): 2 (one complex write into `M(i,j)`, which is two real writes)

```

Assuming everything is vectorized and the memory reads/writes are from L1 cache, the number of clock cycles per operation, say, on Haswell will be:

```auto
+: 0.250
*: 0.125
R: 0.125
W: 0.250
sqrt: 4-7 (?)
sin/cos: ? 

```

It seems the most expensive operation will be the sqrt and sin/cos, so this will be computation bound.

To obtain the exact theoretical performance peak, we should lookup the costs exactly on more modern hardware, and then try to achieve the peak.

---

<div class="post-metadata">

**Author:** ![shahmoradi](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahmoradi/32/3151_2.png) [@shahmoradi](https://fortran-lang.discourse.group/u/shahmoradi)\
**Post date:** [June 20, 2021, 7:26pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/3 "2021-06-20T19:26:16Z")

</div>

There are already some responses to weaknesses in the Fortran implementation of this benchmark in the Hacker news post like:

> This example is not really testing Fortran vs. Julia, but rather testing the speed of the math library you linked to.

Forgive me for mixing subjective opinion with this objective discussion. But from my perspective, I do not find such benchmarks informative at all. I feel like these benchmarks are mostly done by graduate students with a strong passion for Julia and to prove to others that Julia is fast (perhaps it is). But in the end, I see Julia programmers in the Julia forum expressing their struggles with making Julia scripts performant in practice. To be fair, I have never struggled to make any Fortran code performant, it is fast and efficient, by default. In my experience, algorithmic efficiency tends to dominate other sources of runtime efficiency bottlenecks in compiled languages, for most real-world applications. Whether Fortran is 10% faster or slower than C or Julia in particular tasks becomes irrelevant in most cases.

---

<div class="post-metadata">

**Author:** ![awvwgk](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/awvwgk/32/154_2.png) [@awvwgk](https://fortran-lang.discourse.group/u/awvwgk)\
**Post date:** [June 20, 2021, 7:40pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/4 "2021-06-20T19:40:38Z")

</div>

This is an interesting one, actually there is nothing wrong with the Fortran code, but maybe the way it is used. Check the repository and you will notice it is used from Python. Now the question which interested me more than why Julia is faster, is how bad can it be to call Fortran from Python.

I took the original code from [here](https://github.com/mdmaas/julia-numpy-fortran-test) made a trial run on my machine (nothing fancy, Intel Sky Lake i7-6500U CPU @ 2.50GHz):

```auto
❯ python test_f2py.py
1000 0.02498769760131836
2000 0.10134744644165039
3000 0.2162013053894043
4000 0.3785884380340576
5000 0.5802724361419678
6000 0.828559398651123
7000 1.1193299293518066
8000 1.4555211067199707
9000 1.8339998722076416
10000 2.9962995052337646

```

Maybe the implementation was not optimal, taking Ondřej’s suggestions to check if we can improve with this one here:

```auto
! test-f2py.f90
module mymodule
  use omp_lib
  implicit none
contains
  function eikR(a,k,n) result(M)
    integer, intent(in) :: n
    real(kind=8), intent(in) :: a(n)
    complex(kind=8), intent(in) :: k
    complex(kind=8) :: M(n,n)
    real(8) :: Y
    integer :: i, j
    !$omp parallel do simd private(J, Y) collapse(2)
    do j=1,n
      do i=1,n
        Y = k*sqrt(a(i)*a(i) + a(j)*a(j))
        M(i,j) = cmplx(cos(Y), sin(Y))
      end do
    end do
  end function eikR
end module

```

Indeed with a hand optimized implementation we get faster, but unfortunately not by much

```auto
❯ python test_f2py.py
1000 0.026028871536254883
2000 0.10151910781860352
3000 0.21696782112121582
4000 0.3690149784088135
5000 0.5648448467254639
6000 0.8063969612121582
7000 1.1044635772705078
8000 1.7926850318908691
9000 2.2729897499084473
10000 2.574355125427246

```

The actual question is how bad can the f2py wrapping and the usage in Python actually be, here is an equivalent Fortran main

```auto
! main.f90
use mymodule
use omp_lib
implicit none
integer, parameter :: dp = selected_real_kind(15)
real(dp), parameter :: pi = 4*atan(1.0_dp)
integer :: i, j, n
real(dp), allocatable :: a(:)
complex(dp) :: k
complex(dp), allocatable :: m(:, :)
real(dp) :: t1, t2
do i = 1, 10
   n = 1000*i
   a = [(2*j*pi, j = 0, n-1)]
   k = cmplx(100.0_dp, 1.0_dp)
   t1 = omp_get_wtime()
   m = eikr(a, k, n)
   t2 = omp_get_wtime()
   print *, n, t2 - t1
end do
end

```

Using the same compile flags as for the f2py module we get a surprising outcome:

```auto
❯ gfortran -O3 -march=native -funroll-loops -fopenmp -ffast-math -floop-nest-optimize test-f2py.f90 main.f90
❯ ./a.out
        1000 2.1003986003051978E-002
        2000 6.6137752000940964E-002
        3000 0.13244638699688949     
        4000 0.24651855599950068     
        5000 0.35877340099978028     
        6000 0.51193849599803798     
        7000 0.69200517200079048     
        8000 0.89750151500629727     
        9000 1.1269864560017595     
       10000 1.3638167019962566

```

It’s interesting to see that the f2py wrapper costs almost as much as the actual calculation we are performing.

---

<div class="post-metadata">

**Author:** ![shahmoradi](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahmoradi/32/3151_2.png) [@shahmoradi](https://fortran-lang.discourse.group/u/shahmoradi)\
**Post date:** [June 20, 2021, 7:46pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/5 "2021-06-20T19:46:08Z")

</div>

Calling Fortran from Python can be really slow. I have seen it slow down the code by an order of magnitude or more, depending on the frequency and complexity of Fortran-Python interactions.

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [June 20, 2021, 7:57pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/6 "2021-06-20T19:57:18Z")

</div>

> [@certik](#):
>
> … For simple benchmarks like this, Fortran should not be slower.

@certik,

As was shown in your other [**thread**](https://fortran-lang.discourse.group/t/simple-summation-8x-slower-than-in-julia/1171/44), there is much that can be questioned about such comparisons.

Ok so the previous thread established Julia implementation has somewhat faster **trig** functions compared to readily-accessible Fortran implementations such as gfortran currently and there are some macros with Julia developed by highly zealous enthusiasts that enable convenient **non-sequential** calculations (vectorized/threaded/parallel, etc.) but these are hardly aspects of the language itself, especially Fortran.

Thus, not only do the comparisons posted at GitHub by “mdmaas” appear entirely amateurish technically (who in their right mind posts benchmarks of Fortran function evaluation using a NumPy driver!) they have all the subtle elements of **bias** that can lead to pointless “language wars”.

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [June 20, 2021, 7:59pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/7 "2021-06-20T19:59:27Z")

</div>

> [@awvwgk](#):
>
> … It’s interesting to see that the f2py wrapper costs almost as much as the actual calculation we are performing.

Excellent illustration, I had the very same concern when I saw the benchmark site for the Fortran test but your post nails down the issue.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [June 20, 2021, 9:10pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/8 "2021-06-20T21:10:56Z")

</div>

Indeed, using `f2py` is a mistake when it comes to performance of such kernels. I noticed such an overhead also for some benchmarks in the past. One has to benchmark from Fortran itself and be careful to obtain accurate timings.

---

<div class="post-metadata">

**Author:** ![lmiq](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/lmiq/32/555_2.png) [@lmiq](https://fortran-lang.discourse.group/u/lmiq)\
**Post date:** [June 20, 2021, 11:36pm UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/9 "2021-06-20T23:36:07Z")

</div>

Disclaimer: Fortran programmer and Julia enthusiast here.

That micro benchmark, as many others, are really not very important for Fortran (or C, or C++). People are absolutely convinced that these languages can generate fast code, and except for beginners, it is clear that all of them can be tweaked to have close-to-optimal performance. And algorithmic differences, sometimes some compiler flag, is what differentiate one from the other.

Therefore, I have no doubt that with some small effort we can get a Fortran code to run as fast as the Julia code there.

On the other side, these benchmarks have some importance for Julia. Because not everybody is (yet) convinced that Julia can produce fast-as-possible code. Therefore, in the Julia community, every time a beginner appears with some odd performance issue, the community is rapid in trying to solve and provide the hints on what is going on.

It is also true that to write code in Julia as fast as Fortran code one must know how Julia works, and it is possible to get _very slow_ code (interpreted-language slow) code if one commits some mistakes. Fortran is fast more out of the box, and less open to these mistakes.

Properly written code in any of these languages should be similar in performance. And one or the other can have a lead because of some micro-optimization, which might be easier or necessary in one language or in the other.

Again, reinforcing that for the Julia side showing that this is the case is important and because of that you will find many people putting time to teach others how to do that. On the Fortran side there is no need to do that. Nobody can sanely doubt that Fortran code can be fast.

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [June 21, 2021, 12:44am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/10 "2021-06-21T00:44:58Z")

</div>

> [@lmiq](#):
>
> … these benchmarks have some importance for Julia. Because not everybody is (yet) convinced that Julia can produce fast-as-possible code. …  
> …reinforcing that for the Julia side showing that this is the case is important and because of that you will find many people putting time to teach others how to do that. …

The [**post**](https://www.matecdev.com/posts/numpy-julia-fortran.html) in question at Hacker News does not convey any such relatable notions, rather it comes across as primal in intent and tribal in its pursuit starting with, “I’m switching to Julia …”

---

<div class="post-metadata">

**Author:** ![lmiq](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/lmiq/32/555_2.png) [@lmiq](https://fortran-lang.discourse.group/u/lmiq)\
**Post date:** [June 21, 2021, 12:49am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/11 "2021-06-21T00:49:35Z")

</div>

Well, I cannot speak for the poster (which declares he is a beginner), but what I see, from the Julia community perspective, which read that with joy, is: Someone tried Julia and obtained a performant code, and decided to seriously give Julia a try.

That is important publicity from the Julia side because it is more common to hear “I tried Julia and got a lousy performance, all those Julia fans are lying.”

Getting a good performance or a lousy performance in Julia without knowing the basics of how Julia works is basically a matter of chance. And that is bad for Julia first impressions.

I can even illustrate that. Get the original code of that post, in Julia:

```auto
julia> function eval_exp(N)
           a = range(0, stop=2*pi, length=N)
           A = Matrix{ComplexF64}(undef, N, N)
           @inbounds Threads.@threads for j in 1:N
           for i in 1:N
               A[i,j] = exp((100+im)*im*sqrt(a[i]^2 + a[j]^2))
           end
           end
           return A
       end
eval_exp (generic function with 1 method)

julia> N = 100;

julia> @btime eval_exp($N);
  304.139 μs (8 allocations: 156.92 KiB)

```

Ok, it takes ~300 microseconds.

Now lets only change one thing: don’t pass `N` as a parameter to the function:

```auto
julia> function eval_exp()
           a = range(0, stop=2*pi, length=N)
           A = Matrix{ComplexF64}(undef, N, N)
           @inbounds Threads.@threads for j in 1:N
           for i in 1:N
               A[i,j] = exp((100+im)*im*sqrt(a[i]^2 + a[j]^2))
           end
           end
           return A
       end
eval_exp (generic function with 2 methods)

julia> @btime eval_exp();
  1.875 ms (100112 allocations: 2.75 MiB)

```

The code just got 6x slower. (and that is because `N` is type-unstable).

This is more common as a first impression in Julia, and is very bad for its publicity.

---

<div class="post-metadata">

**Author:** ![shahmoradi](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahmoradi/32/3151_2.png) [@shahmoradi](https://fortran-lang.discourse.group/u/shahmoradi)\
**Post date:** [June 21, 2021, 4:15am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/12 "2021-06-21T04:15:55Z")

</div>

The problem is that such Julia publicity are often accompanied with unfair comparisons with other languages, in particular, Fortran, simply because there are not so many people proficient in Fortran who could question the validity of the claims. I even remember watching a presentation by one of Julia’s founders explaining how a Julia translation of an old Fortran code was 3X faster. I was surprised by the fact that no one in the audience asked whether the authors ever tried to put the same amount of effort into the Fortran code to make it more performant or not. This would be essential for a fair ethical comparison.

---

<div class="post-metadata">

**Author:** ![implicitall](https://avatars.discourse-cdn.com/v4/letter/i/9fc29f/32.png) [@implicitall](https://fortran-lang.discourse.group/u/implicitall)\
**Post date:** [June 21, 2021, 4:19am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/13 "2021-06-21T04:19:43Z")

</div>

As someone just getting into HPC and giving Fortran and Julia a try, I can confirm that I have had the experience of “I tried Julia and got lousy performance”. All I did in my test was use the dot\_product/dot intrinsic. I find that a dot product of 1000000 random numbers performs 9x faster in Fortran. I will be continuing down the path of trying to use Fortran for more work.

Julia:

```auto
using LinearAlgebra

N = 1000000
a = rand(Float32, N)
b = rand(Float32, N)
@time c = dot(a, b)
println(c)

```

And Fortran:

```auto
real(real32) :: c
integer, parameter :: N = 1000000
real(real32), allocatable :: a(:), b(:)
real(real32) :: tarray(2), time
integer :: i

allocate(a(N), b(N))

call random_number(a)
call random_number(b)

call dtime(tarray, time)
c = dot_product(a, b)
call dtime(tarray, time)
print '(f18.11)', c
print '("Time: ",f19.17," s")', time

```

---

<div class="post-metadata">

**Author:** ![shahmoradi](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/shahmoradi/32/3151_2.png) [@shahmoradi](https://fortran-lang.discourse.group/u/shahmoradi)\
**Post date:** [June 21, 2021, 4:22am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/14 "2021-06-21T04:22:10Z")

</div>

Welcome to the Fortran forum 🙌

---

<div class="post-metadata">

**Author:** ![implicitall](https://avatars.discourse-cdn.com/v4/letter/i/9fc29f/32.png) [@implicitall](https://fortran-lang.discourse.group/u/implicitall)\
**Post date:** [June 21, 2021, 5:43am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/15 "2021-06-21T05:43:48Z")

</div>

The funny thing is, I wrote a program that has 50x better performance in Fortran without trying to do any sort of trickery or pathological cases. It is just basic code. Is that perhaps the point?

```auto
program dot
use, intrinsic :: iso_fortran_env, only: real32
implicit none

real(real32) :: c
integer, parameter :: N = 1000000
real(real32), allocatable :: a(:), b(:)
real(real32) :: time1, time2

allocate(a(N), b(N))

call random_number(a)
call random_number(b)

call cpu_time(time1)
c = mydot(a, b, N)
call cpu_time(time2)
print '(f18.11)', c
print '("Time: ",f19.17," s")', time2 - time1

contains

function mydot(a, b, N) result(c)
   real(real32), intent(in) :: a(:)
   real(real32), intent(in) :: b(:)
   integer, intent(in) :: N
   real(real32) :: c
   integer :: i
   c = 0.
   do i = 1, N
      c = c + a(i)*b(i)
   enddo
endfunction
endprogram

```

```auto
function mydot(a, b, N)
    c = 0.
    for i = 1:N
        c += a[i]*b[i]
    end
    c
end

N = 1000000
a = rand(Float32, N)
b = rand(Float32, N)
@time c = mydot(a, b, N)
println(c)

```

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [June 21, 2021, 5:59am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/16 "2021-06-21T05:59:21Z")

</div>

@implicitall yes, that is the point why I like Fortran also. Others too. Welcome to the Forum!

That being said, I still want Fortran compilers to do a better job on the original benchmark.

---

<div class="post-metadata">

**Author:** ![implicitall](https://avatars.discourse-cdn.com/v4/letter/i/9fc29f/32.png) [@implicitall](https://fortran-lang.discourse.group/u/implicitall)\
**Post date:** [June 21, 2021, 7:47am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/17 "2021-06-21T07:47:40Z")

</div>

My equivalent program runs about 1.2x-1.4x faster (depending on N) in Fortran using gfortran -fopenmp with the best Julia performance with 24 threads.

```auto
module omp
interface
   double precision function omp_get_wtime()
   endfunction
endinterface
endmodule

program test
use omp
complex(kind=8), allocatable :: A(:, :)
integer :: N
real(kind=8) :: time1, time2

do N = 1000, 10000, 1000
   time1 = omp_get_wtime()
   A = eval_exp(N)
   time2 = omp_get_wtime()
   print *, time2 - time1
enddo

contains

function eval_exp(n) result(M)
   implicit none

   integer, intent(in) :: n
   complex(kind=8) :: M(n, n)

   ! Local
   real(kind=8) :: a(n)
   complex(kind=8) :: k
   integer :: i, j

   k = (100., 1.)

   do i = 1, n
      a(i) = (i - 1)*2*3.14159/(n - 1)
   enddo

   !$omp PARALLEL DO PRIVATE(J)
   do j = 1, n
      do i = 1, n

         ! A[i,j] = exp((100+im)*im*sqrt(a[i]^2 + a[j]^2))
         M(i, j) = exp(k*(0., 1.)*sqrt(a(i)**2 + a(j)**2))

      enddo
   enddo
   !$omp END PARALLEL DO

endfunction eval_exp

endprogram

```

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [June 21, 2021, 10:50am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/18 "2021-06-21T10:50:44Z")

</div>

The Fortran Wiki has a section [Fortran Advocacy and Language Comparisons](http://fortranwiki.org/fortran/show/Articles) with several speed comparisons of Fortran, Julia, Pytthon, and Matlab. It was [discussed](https://news.ycombinator.com/item?id=27570891) in a recent Hacker News thread [Is Julia Really Fast?](https://news.ycombinator.com/item?id=27570591), with the initial comment

> [P]eople do find Julia to be faster than Python/Numpy, but it is not uniformly faster than Fortran. And Julia’s start-up time should not be ignored. Quoting the last link, “In fact the whole Fortran benchmark (300 integrations) finishes roughly in the time it takes to startup a Julia session and import all required libraries (Julia 1.5.1).”

A meta-analysis of when Fortran is faster and slower than Julia would be interesting.

---

<div class="post-metadata">

**Author:** ![lkedward](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/lkedward/32/72_2.png) [@lkedward](https://fortran-lang.discourse.group/u/lkedward)\
**Post date:** [June 21, 2021, 11:20am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/19 "2021-06-21T11:20:59Z")

</div>

Not sure if this has already been posted, but here’s another speed comparison:

> **[Testing Julia for Speed – 2021 update](https://craftofcoding.wordpress.com/2021/04/29/testing-julia-for-speed-2021-update/)**
>
> A few years ago I tested Julia for speed using a series of algorithms. Since Julia has evolved, I figure I would revisit the scores to see how things have changed. The first was Ackermann’s f…

Unfortunately I can’t find all the code for the results. The author has a number of other [blog posts](https://craftofcoding.wordpress.com/archives) about Julia and Fortran which are interesting reads.

* * *

Benchmarks aside, I think @implicitall has made an excellent point in that Fortran does not require much specialist knowledge or ‘trickery’ to get performant code. (For me, this frees up mental energy to spend on the actual problem I’m solving.)

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [June 21, 2021, 11:46am UTC](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405/20 "2021-06-21T11:46:42Z")

</div>

Thanks for this @implicitall. Can others replicate this result? If so, we should submit this to the author, as that is quite unfair to be using Python overhead to conclude that Fortran is slower than Julia, if it would be faster than Julia without calling it via Python.

[Next page](https://fortran-lang.discourse.group/t/julia-fast-as-fortran-beautiful-as-python/1405.md?page=2)
