# Noteworthy differences from Fortran

**URL:** <https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502>\
**Category:** General Usage\
**Tags:** documentation, fortran\
**Created:** [August 7, 2020, 2:14pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502 "2020-08-07T14:14:55Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![lungben](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lungben/32/12314_2.png) [@lungben](https://discourse.julialang.org/u/lungben)\
**Post date:** [August 8, 2020, 6:31am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/21 "2020-08-08T06:31:31Z")

</div>

While the Noteworthy Differences page is very helpful imho, I think it would be good to add a more general introduction to compare the core Julia design principles to other languages, especially:

- Julia JIT vs. ahead-of-time compilation and interpretation
- Duck Typing vs. static typing
- Multiple Dispatch vs. OOP

---

<div class="post-metadata">

**Author:** ![zyth0s](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zyth0s/32/19042_2.png) [@zyth0s](https://discourse.julialang.org/u/zyth0s)\
**Post date:** [August 8, 2020, 7:09am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/22 "2020-08-08T07:09:24Z")

</div>

I think that the purpose of the list is to provide a short alert to users: “Hey, realize this is different”. Since types require a lengthy explanation, I provide a link to the documentation.

My intention was to use the simplest example of type declaration. One that Fortran users could  
recognize, that is why I used a double float. If the example is going to be interpreted as a suggestion for future usage, then I put an own declared type because types in Julia have no performance penalty.

I must admit that my knowdledge of types is very limited because I use them scarcely.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 8, 2020, 7:44am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/23 "2020-08-08T07:44:23Z")

</div>

Despite having contributed to the “noteworthy differences” section in the manual myself, I have come to question its usefulness.

Even for languages quite close to Julia, there is no substitute to reading and understanding the manual. Without the manual, these lists don’t really help users write Julia code (differences in surface syntax are usually the most insignificant anyway); but once one reads the manual they are somewhat superfluous.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [August 8, 2020, 3:09pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/24 "2020-08-08T15:09:14Z")

</div>

On the topic of type annotations, often people make the mistake that type annotations makes things faster. Perhaps stating "Type declarations do not generally affect performance. Functions are automatically compiled to use the strictest types possible using a process called “type inference” " can discourage this assumption?

---

<div class="post-metadata">

**Author:** ![yutaka](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@yutaka](https://discourse.julialang.org/u/yutaka)\
**Post date:** [August 8, 2020, 3:23pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/25 "2020-08-08T15:23:44Z")

</div>

There is a diversity in the Fortran community. Some people know FORTRAN/Fortran only; To them, the difference is something common to popular dynamic languages (Python, Ruby, R, Matlab, etc) i.e., dynamic typing, interactive usage, packages, etc. If they know some dynamic languages, their interest is how easy numerical coding is possible in Julia. Also, they would be interested in parallel computing performance.

The OP lists more technical details than mental model/way of programming. There are some more examples:

- Mutable and immutable. Some types are immutable, and it is not intuitive for Fortran programmers. You can’t do `str="Fortran"; str[1]='X'`. Also, you can’t change the scalar argument of a function because a scalar is immutable.
- Reference and copy. A variable pointing to another variable is a reference. In Fortran, pointers are not often used. You will be very confused with `a=[1,2,3]; b=a; a[1]=100; b[1]`.
- Bounds checks and some foolproof options. Julia checks bounds by default. To turn it off, you have to put a macro `@inbounds` into the code explicitly. Julia has more macros to remove checks or to improve the performance instead of compiler options.
- Compile at runtime. Very roughly, you can’t save a compiled binary in Julia. The binary is managed by Julia, and the user can’t touch it. The compiled binary is kept in a Julia session, but once Julia exists, the binary will be removed. To avoid the recompilation, make a package to host your programs (and maybe you need `PackageCompiler.jl` for your purpose).

Besides the details, I think, the difference between Julia and Fortran is in a development model, coding style, and tests. This post is already too long, so I may post these aspects in another post.

EDIT: I added some more details.

- Macros. Julia can manipulate the code as a data structure before the compilation. A macro provides such a functionality (meta-programming). A macro name starts with a character `@`.
- Breaking multiple loops. In Fortran, you can break multiple loops with a labeled-do statement like `label: do ... exit label`. There is no such built-in in Julia; Instead, you can use `@goto` and `@label` macros.
- Slice or subarray. When you refer to a subarray `a[:]`, Julia always makes a copy of it (even though just look at it). To avoid this, make a view using `@view` or `view()`.

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [August 11, 2020, 2:00am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/26 "2020-08-11T02:00:30Z")

</div>

I found the notable differences page to be a very useful introduction grounded in what I was already familiar with. Before committing to switching to Julia and reading through the manual, I read the notable differences section and decided they were all changes I could get used to. Julia had enough of the Matlab things I liked and did away with enough of the Python things I hated to keep me interested in going further.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 11, 2020, 6:43am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/27 "2020-08-11T06:43:18Z")

</div>

> [@Nathan\_Boyer](#):
>
> Before committing to switching to Julia and reading through the manual, I read the notable differences section and decided they were all changes I could get used to.

Now that you are experienced with Julia, do you think that the notable diffs section did a reasonable job in listing the things you have to get used to?

I am asking because a lot of the novelty in Julia is conceptual, difficult to summarize as a difference in surface syntax etc.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 11, 2020, 10:03am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/28 "2020-08-11T10:03:46Z")

</div>

I think there’s also a risk of excacerbating a sort of X-Y problem here by encouraging users to look for “how do I replace idiom Y in my old language that I use to solve problem X”, when the better thing to ask would be “how do I solve problem X in Julia, which (potentially) offers very different ways of expressing things”.

So while definitely useful to alert new users to possible traps when switching to Julia, overreliance on them can keep them from making best use of Julia.

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [August 11, 2020, 11:05am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/29 "2020-08-11T11:05:26Z")

</div>

Many old and experienced Fortran programmers can write Fortran in any language. Julia is no exception. Fortran in Juila (Foolia?) is, unlike Fortran in C or Matlab, pretty slow.

One major similarity between Julia and F66/77 is that preallocating memory and doing operations in-place is really important. I was delighted to see this.

My first language, and I am not making this up, was Fortran 66. I’m still looking for Hollerith constants in Julia. 🙂

---

<div class="post-metadata">

**Author:** ![zyth0s](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zyth0s/32/19042_2.png) [@zyth0s](https://discourse.julialang.org/u/zyth0s)\
**Post date:** [August 11, 2020, 11:11am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/30 "2020-08-11T11:11:20Z")

</div>

It is certainly true that those items do not encompass all the conceptual differences. I think, however, that many experienced programmers interested in Julia will not read the entire manual.  
They will just go directly to control flow syntax, how to install it and how to look up the documentation at the REPL. In a few hours they can be productive. Later, and progressively, they will go through the documentation. In my case it is like that because I knew already Fortran, Python, Octave, and “some” C++.

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [August 11, 2020, 11:31am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/31 "2020-08-11T11:31:27Z")

</div>

@Tamas_Papp Notable Differences is the fastest way to start coding in Julia. New users do not want to wait until halfway through the manual to learn that square brackets index and parentheses call functions. It allows people to get in and start playing with the language. The next thing to learn would be style convention, again to be able to keep writing, and then conceptual methodology. Learning Julia is a process learned by experimenting and then referring back to the manual (or forums). I read through most of the manual when I was getting started, but have since forgotten all the parts I haven’t actually used in my code yet.

@nilshg I think replacing code in another language verbatim is the obvious place to start for most people. Direct translation is of course not the best coding practice, but it is the easiest for beginners to grasp. Thinking like a Julian is the goal, but can’t be expected upfront. That is why my favorite answers to these types of questions are “This is the most direct translation, but here is a better way in Julia for this reason.” It is comforting to know that Julia can do everything their old language could but also adds new functionality not possible before.  
 ![IMG_0002](https://global.discourse-cdn.com/julialang/original/3X/5/7/5795b9130d461a18a30859e51bd50f168a6d85c2.jpeg)

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 11, 2020, 11:47am UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/32 "2020-08-11T11:47:30Z")

</div>

> [@Nathan\_Boyer](#):
>
> Notable Differences is the fastest way to start coding in Julia.

I am somewhat skeptical that reading _only_ this section would allow someone to use Julia in any meaningful sense (ie beyond “Julia as a calculator”). Eg function definitions and `using` are not even mentioned here. Furthermore, most of the information in this section of the manual is pretty unstructured.

This part of the manual is possibly useful if someone read some other chapters, and wants to translate some idiom to Julia and is looking for an equivalent construct or replacement.

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [August 11, 2020, 12:50pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/33 "2020-08-11T12:50:08Z")

</div>

True, maybe the section could be included as part of a Quick Start Guide. In Matlab, I didn’t really use functions or external packages, but both are pretty much required in Julia. I think I started using Julia as a calculator, then had to learn packages when I wanted to plot my results. Then reading about style somewhere realized I should make as many small functions as possible instead of long scripts with global variables, naturally leading into learning about functions and scope. Then continued to progress from there.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 11, 2020, 2:21pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/34 "2020-08-11T14:21:42Z")

</div>

> [@ctkelley](#):
>
> Fortran in Juila (Foolia?) is, unlike Fortran in C or Matlab, pretty slow.

Huh? Isn’t that lots of loops, and somewhat primitively explicit programs (as opposed to generic programming with higher level functions and such)? I would have thought ‘Fortran in Julia’ would be very fast, but quite restrictive.

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [August 11, 2020, 2:43pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/35 "2020-08-11T14:43:24Z")

</div>

Gee, maybe my computed goto’s had something to do with my problems. The experiment was porting a Matlab program with many array slices. Very like F90, and I got allocated to death. Perhaps 1.5 is better, but I’ve already fixed the code (with naked BLAS calls, also right from the F77 playbook).

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [August 11, 2020, 2:59pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/36 "2020-08-11T14:59:58Z")

</div>

> [@ctkelley](#):
>
> The experiment was porting a Matlab program with many array slices. Very like F90, and I got allocated to death.

`@view` is probably what you are looking for, see [Could you explain what are views? - #2 by heliosdrm](https://discourse.julialang.org/t/could-you-explain-what-are-views/17535/2)

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [August 11, 2020, 3:16pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/37 "2020-08-11T15:16:10Z")

</div>

Yup. I use @view(s) routinely now for most such things. I found that the naked BLAS calls were noticeably faster when I did the experiment with Julia 1.1 for the application I had (classical Gram-Schmit orthogonaliztion twice for an Arnoldi factorization. BLAS.gemv! is still what I use, but I plan to give mp! a shot when I find the time.

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [August 11, 2020, 3:59pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/38 "2020-08-11T15:59:46Z")

</div>

Another noteworthy difference:

Julia permits aliasing of procedure arguments. In this respect,Jjulia is closer to C than Fortran. Some code transformations that depend on alias analysis need to be done manually by the programmer, instead of relying on the compiler. The loved/hated `restrict` keyword from C has no analogue in julia.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [August 12, 2020, 3:01pm UTC](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502/39 "2020-08-12T15:01:45Z")

</div>

I found it really useful the first time I sat down to understand the language, coming from Python and C# and MATLAB.

Afterwards I read the rest of the docs.

[Previous page](https://discourse.julialang.org/t/noteworthy-differences-from-fortran/44502.md?page=1)
