In Julia, the display function is aware of the context in which it is called. This means that depending on what context is passed to this function, you may obtain a different result. For instance, an image passed to the display in the Julia console usually opens a new window with a plot, but in Jupyter Notebook it might embed it in a notebook. Similarly, many objects in the Julia console are displayed as plain text but in Jupyter Notebook they are converted to a nicely formatted HTML. In short, display(x) typically uses the richest supported multimedia output for x in a given context, with plain text stdout output as a fallback.
In particular, the display function is used by default in the Julia console when a command is executed, for example:
julia> transpose(1:100)
1×100 LinearAlgebra.Transpose{Int64,UnitRange{Int64}}:
1 2 3 4 5 6 7 8 9 10 11 … 93 94 95 96 97 98 99 100
In this case, the output is adjusted to the size of the Terminal. However, as we saw in the previous example if display is run in a script in non-interactive mode, no adjustment of the output to the size of the device is performed.
An additional issue that is commonly required in practice is suppressing the display of an expression value in the Julia console. This is easily achieved by adding ; at the end of the command, for example:
julia> rand(100, 100);
julia>
And nothing is printed (otherwise, the screen would be flooded by a large matrix).
Finally, in the script in this recipe, we were able to examine the use of the @show macro, which is useful for debugging, as it prints the expression along with its value.
At the end of this recipe, we observed that the PyPlot package can alter its behavior based on whether it is run in interactive mode or not. Each custom package might have similar specific conditions for handling output to a variety of devices. Being aware of this, it is best to consult the documentation relating to a given package to understand the defaults.
If you are developing your own code that needs to be sensitive to the Julia mode (REPL or script) in which it is invoked, there is a handy isinteractive function. This function allows you to dynamically check the Julia interpreter mode at runtime.