"Int 1"
Numerical Analysis
NYU Paris
Python | Matlab | Julia | C | |
---|---|---|---|---|
Libre? | ✔️ | ❌ | ✔️ | ✔️ |
Fast? | ❔ | ❔ | ✔️ | ✔️ |
Easy? | ✔️ | ✔️ | ✔️ | ❌ |
Math-friendly? | ❔ | ✔️ | ✔️ | ❌ |
Ecosystem? | ✔️ | ❔ | ❔ | ✔️ |
Julia
is easy to learn, read and maintain
Julia
is fast: “As simple as Python with the speed of C++”
Julia
is well-suited for numerical mathematics
Julia
is libre software
Created in 2009 by J. Bezanson, S. Karpinski, V. B. Shah, and A. Edelman
Excerpt from the Julia Manifesto:
We want a language that’s open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that’s homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.
for
loops allowed!):In comparison, Python takes about 10 seconds…
1 is a Int64
π is a Irrational{:π}
1//2 is a Rational{Int64}
4.641592653589793 is a Float64
for
within array)3-element Vector{Float64}:
1.2000000000000222
3.3999999999999084
5.600000000000077
Wikipedia definition: paradigm in which a function or method can be dynamically dispatched based on the run-time type.
import Base.-
function -(s1::String, s2::String)
return s1[1:length(s1)-length(s2)]
end
"julia" - "ia"
"jul"
To access the REPL,
either type julia
in a terminal window;
or launch it from VSCode
by typing Shift+Ctrl+P
then Julia: Start REPL
Useful shortcuts in the REPL:
]
to access package mode
;
to access shell mode
?
to access help mode
⟵
to return to normal mode
Tab
for automatic completion
up and down arrows to navigate history
To write a julia
program
either write a .jl
file, which can be run using Shift+Enter
Or write a Jupyter notebook with .ipynb
extension.
To install a new package
Enter package mode with ;
Type add
followed by the package name, e.g.
You only need to do this once
Official documentation → https://docs.julialang.org/en/v1/
Learn X in Y minutes → https://learnxinyminutes.com/docs/julia
Intro to Julia tutorial (version 1.0) by Jane Herriman → https://youtu.be/8h8rQyEpiZA
The Unreasonable Effectiveness of Multiple Dispatch → https://www.youtube.com/watch?v=kc9HwsxE1OY