Excellent cheat-sheet

Hi All,

Wanted to flag a Julia cheat-sheet I recently stumbled across that seems phenomenally concise and comprehensive!

Open for PRs if anyone wants to contribute more!

EDIT: This was rolled into JuliaDocs org, so updated url in link above to https://juliadocs.github.io/Julia-Cheat-Sheet/


That is a really nice cheat sheet!



Is there somewhere else to post this to improve visibility? Maybe on julialang.org under resources? (If so, is there a place to PR such a submission?)

Yes, that seems like a good place. This is the repo for the website: https://github.com/JuliaLang/julialang.github.com, just make a PR like you normally would on a project!

I wonder what @brakmic thinks about transferring https://github.com/brakmic/Julia-Cheat-Sheet into the JuliaDocs org :slight_smile:


@waldyrious @brakmic says he’s up for it! Are you an admin on JuliaDocs?


Yes, of course. It’d make more sense to have the cheat sheet there :slight_smile:


forio returns 404 and https://github.com/forio/julia-studio seems abandoned too…

1 Like

Nope :slight_smile: only 3 people are publicly visible as members of the org (not sure if there are more): @mortenpi, Michael Heatherly (no discourse account?) and @ararslan. I’m not sure what the process of migrating a repo to an org is, but IIRC one of them should invite @brakmic and he can then initiate the transfer.

I’ll update the links. Thanks :slight_smile:

The info on types seems out of date. Ie, types -> structs, immutables -> mutable structs, typealias x y -> const x = y.

Very thorough. Some comments / suggestions after a read through. Just personal opinions.

Immutable types are passed around by value (i.e. copying), whereas mutable types are passed by reference.

I’m not sure this is really true. Since you can’t modify an immutable struct it doesn’t matter if you copy it or not to pass it as an argument, and the compiler can chose what to do. Also, I don’t think there is anything called “pass by reference” in Julia. What I think it is typically called is “pass by value” and this is true both for mutables and immutables.

Free up memory for large arrays with arr = nothing

I feel like this is rarely needed. If you have no use for arr anymore then it typically would have dropped out of scope and be cleaned up by the gc anyway.

Use named instead of anonymous functions.

Don’t think this is true anymore.

Use type annotation rather than tests for function arguments.

I don’t think this has a performance impact.

Split functions into smaller components to aid the compiler.

Not sure if this is true, or helps performance. (Note that the link in this text leads to a suspended account).

Type alias typealias Nerd Programmer

typealias is deprecated in 0.6.

Moreover, using only loads exported names by default while import loads all names defined in the module.

I’m not sure what this means. What does loading a name mean?

Statically sized arrays ImmutableArrays

Should probably change this recommendation to StaticArrays.

Test framework Test

I’m not sure what package this references but Base own Test is pretty good now.

type Hacker <: Programmer

Perhaps put String instead of the abstract type AbstractString as the fields. Also, I think just using an Int for birth_year might be preferable.

Dictionaries are mutable; when symbols are used as keys, the keys are immutable.

Not sure what this means. How are symbols as keys special?

Julia has many built-in mathematical functions, including special functions (e.g. Airy, Bessel, Gamma), and supports complex numbers right out of the box.

Airy and Bessel are no longer built in (in 0.6).


@kristoffer.carlsson @Elrod Some of those errors are mine – I tried to update for 0.6, but sounds like there were a lot of things I apparently know about. Wanna PR some of those?

This could probably start another topic. If someone has to agree with you then some harmony in wider context is necessary. For example: what is value of Vector with thousand and one element? So although I could understand what you mean, this paradigm could not be described by one sentence. In some other paradigm your sequence is false! I think we have to describe what we understand with variable binding and then we could say that parameters pass by bind value. Or something similar (sorry my English is very poor).

Passing by value is a fairly standard term. See for example: https://stackoverflow.com/a/430958.


When a parameter is passed by reference, the caller and the callee use the same variable for the parameter.

This is clearly not the case in Julia.

would be nice with a print-friendly version


Two points:

  1. We could continue reading SO answer: “However, if the value in question is a mutable reference-type object or otherwise indirectly references other values, then you can emulate call-by-reference in a call-by-value environment: if the callee modifies the object (or other values pointed to by the object), those modifications are visible to the caller.” (emphasis is mine) <- it is what probably cheat-sheet wants to say.

  2. I don’t like to start philosophic and linguistic argue about terms (and I rather agree with your POV). But you could look for example at wiki (“In some cases, the term “call by value” is problematic, as the value which is passed is not the value of the variable as understood by the ordinary meaning of value, but an implementation-specific reference to the value. The effect is that what syntactically looks like call by value may end up rather behaving like call by reference or call by sharing, often depending on very subtle aspects of the language semantics.”) that it is indeed problematic in some cases so it has not so well established meaning… I loosely remember that Julia has this aspect described well in documentation! But IMHO it is difficult to describe this in cheat-sheet… (maybe some links to doc/wiki/so could help)

Edit: I agree with you that it has to be fixed in cheat-sheet! :slight_smile:

My point is that there is no difference how arguments are passed to functions. It just happens that some object are mutable and some are not. Hence, I don’t think the statement about argument passing need to be there at all.

I agree with this, nevertheless it is apparent that some newcomers to Julia struggle with the semantics of shared structure, so an opportunity to point it out should not be wasted. Possibly a “cheat sheet” is not the right place to expand on this, but it could contain a link to tutorials.


Regarding pass by value, the question is: is passing an argument x to a function parameter p equivalent to assignment p=x? The answer, in Julia, is yes, so it is pass by value.

(If x is a mutable object, the of course its contents can still be altered via p.)

If you’ve never used a true pass-by-reference language, like Fortran 77, then it may be hard to imagine anything other than pass by value semantics…

1 Like