Nimに触れてみる
id:shinji611が「Nimが良いぞ。コンパイルに時間は掛かるけど、Cぐらい早いしPythonっぽく書けるし」とか、めちゃくちゃ推してくるので、とりあえず触ってみようと思う。
まずはインストールから。
nim-lang.org
公式サイトからWindows/Unixを選択して、記載している通りに進めば良い。
Ubuntuなので、Unixを選択してインストールした。curlのやつ。
大体3分ぐらい。
インストールが終わった時に
choosenim-init: ChooseNim installed in /home/hogehoge/.nimble/bin choosenim-init: You must now ensure that the Nimble bin dir is in your PATH. choosenim-init: Place the following line in the ~/.profile or ~/.bashrc file. choosenin-init: export PATH=/home/hogehoge/.nimble/bin:$PATH
と書かれているので最後の行だけコピーしてPATH="/home/......../$PATH"と、ダブルクオーテーションで括ってbashrcに書き込みましょう。
export PATH="/home/hogehoge/.nimble/bin:$PATH"
書き込んだ後は、
source ~/.bashrc
で適用させればOKです。
とりあえずHello worldをしてみる。
echo "Hello world!"
と、これだけで良い。
実行は
nim c -r hello_world.nim
で良い。するとそのまま実行結果が出てくれる。
Hint: と多く出てくるが、特に無視して構わないっぽい。