Cosmology Data Science Fellow
UC-Berkeley, LBNL
Twitter: @kylebarbary
GitHub: @kbarbary
Thanks to David P. Sanders for title, inspiration and much content.
See his Julia tutorial at SciPy 2014 here: https://github.com/dpsanders/scipy_2014_julia
In [1]:
function calculate_pi(n)
tot = 0
for i = 1:n
x = rand()
y = rand()
if x^2 + y^2 < 1.0
tot += 1
end
end
return 4.0 * (tot / n)
end
Out[1]:
In [6]:
calculate_pi(1000000.0)
Out[6]:
In [4]:
@time calculate_pi(1000000)
Out[4]:
In [5]:
code_native(calculate_pi, (Int,))
has a sophisticated type system (but it is not necessary to talk about types)
has multiple dispatch: functions specialised on the types of their arguments
has sophisticated metaprogramming (macros) for generating code programatically
call compiled C or Fortran code directly. No wrappers needed. Same function overhead as in C.
Julia manual: http://docs.julialang.org
julia-users mailing list: https://groups.google.com/forum/#!forum/julia-users
Learning resources on the web: http://julialang.org/learning/
Quick syntax overview: http://learnxinyminutes.com/docs/julia/