巨人の肩の上に登る

先人の積み重ねた発見に基づいて、なにかを発見しようとすることを指す。

Julia

Julia とはどんな言語か

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.(原文和訳

2012年2月にリリースされ,2013年3月に Stable の v0.1.2 がでた新しい言語だ.(公式サイト)

最近新しいことを始める余力がなかったので,少しだけ触ってみた.
最近人気のある言語の Elixir と悩んだけど,こっちをやってみる.

インストール

公式サイトからdmgで取ってくる.
アプリケーションを起動すると,REPLが立ち上がる.

println("Hello World")
# Hello World

基本文法

# index は1から始まる
"Hello World"[1] #=> H
"Hello World"[end] #=> d

# 配列生成
a = [1:10] #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# 副作用のある操作は!がつく
push!(a,11) #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
pop!(a) #=> 11
 
# 行列
mat = [1 2 3; 4 5 6; 7 8 9]
# 1  2  3
# 4  5  6
# 7  8  9

# かけ算記号の省略
x = 4
3x #=> 12


# 関数
function double(x)
  x*x
end
double(3) #=> 9

# 無名関数
 (x -> 2x)(2)

正規表現とか,マクロとか,色々あるみたいです.