Julia Intro
Julia Intro
1
What language for teaching
scientific computing?
For the most part, these are not hard-core programming courses,
and we only need little “throw-away” scripts and toy numerical experiments.
2
Lots of choices for interactive math…
3
Image courtesy of Viral Shah. Used with permission.
Just pick the most popular?
Matlab or Python or R?
julialang.org
Viral Shah
Stefan Karpinski
[ 30+ developers with 100+ commits,
1000+ external packages, 6th JuliaCon in 2019 ]
Many of Julia’s special functions come from the usual C/Fortran libraries,
but some are written in pure Julia code.
12000
(FFTW, MKL: fftw3 out-of-place
fftw3 in-place
“unfair” factor of ~2 fftw3-no-simd out-of-place
11000
from manual SIMD) fftw3-no-simd in-place
dfftpack
10000
emayer
9000 julia
bloodworth
speed (mflops)
8000 cross
cwplib
7000 esrfft
6000
5000 K FFTW already comparable to FFTPACK
TPAC w/o SIMD
FF
4000 Ju lia
3000
[ probably some tweaks to
inlining will make it better ]
2000
1000
0
FFTW 1.0-like code generation
+ recursion in Julia
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
65536
131072
262144
Writing fast code “in” Python or Matlab = mining the standard library
for pre-written functions (implemented in C or Fortran).
9
Generating Vandermonde matrices
given x = [α1, α2, …], generate: NumPy (numpy.vander): [follow links]
11
But I don’t “need” performance!
For lots of problems, especially “toy” problems in courses,
Matlab/Python performance is good enough.
12
Just vectorize your code?
= rely on mature external libraries,
operating on large blocks of data,
for performance-critical code
13
But everyone else is using
Matlab/Python/R/…
14
But I lose access to all the libraries
available for other languages?
15
Julia leverages Python…
Directly call Python libraries (PyCall package),
e.g. to plot with Matplotlib (PyPlot package), and also…
via IPython/Jupyter:
Modern multimedia
interactive notebooks
mixing code, results,
graphics, rich text,
equations, interaction
“IJulia”
© Project Jupyter. All rights reserved. This content is excluded from our Creative 16
Commons license. For more information, see https://ocw.mit.edu/help/faq-fair-use.
goto live IJulia notebook demo…
17
MIT OpenCourseWare
https://ocw.mit.edu
For information about citing these materials or our Terms of Use, visit: https://ocw.mit.edu/terms.