• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

最近、こういう理由で(?)Scalaがアツイと僕の周りの人が騒いでいたので僕もその流れに乗ってみました。

周りがMacばっかりなので、Gentooにインストールしてみたいと思います。

Scalaをインストール

まず、このような操作をしてみました。

   1  # emerge scala -pv
   2  
   3  These are the packages that would be merged, in order:
   4  
   5  Calculating dependencies... done!
   6  
   7  !!! All ebuilds that could satisfy "dev-lang/scala" have been masked.
   8  !!! One of the following masked packages is required to complete your request:
   9  - dev-lang/scala-2.7.5 (masked by: ~x86 keyword)
  10  - dev-lang/scala-2.7.4-r1 (masked by: ~x86 keyword)
  11  - dev-lang/scala-2.7.4 (masked by: ~x86 keyword)
  12  - dev-lang/scala-2.7.3-r1 (masked by: ~x86 keyword)
  13  - dev-lang/scala-2.7.3 (masked by: ~x86 keyword)
  14  - dev-lang/scala-2.7.2 (masked by: ~x86 keyword)

maskedパッケージでした。

なので、ACCEPT_KEYWORDS="~x86"とします。

   1  # ACCEPT_KEYWORDS="~x86" emerge scala

これでOKかと思いきや、scalaのコンパイルでエラーという悲しい状況になりました。

Gentooではソースからコンパイルする以外にバイナリをインストールすることが可能なので、そちらで試してみます。

   1  # USE="binary" ACCEPT_KEYWORDS="~x86" emerge scala 

これでscalaのバイナリがインストールされます。

ScalaでHello, World!

インストールが済んだら、早速使ってみましょう。まず、インタラクティブシェルを立ち上げます。

   1  $ scala
   2  Welcome to Scala version 2.7.5.r0-b20090605191508 (Java HotSpot(TM) Client VM, Java 1.6.0_13).
   3  Type in expressions to have them evaluated.
   4  Type :help for more information.
   5  
   6  scala> 

よくわからず、書いてみました

   1  scala> object HelloWorld {
   2       |     def main( arg : Array[String] ) = {
   3       |         println("Hello, World!")
   4       |     }
   5       | }                               
   6  defined module HelloWorld
   7  
   8  scala> HelloWorld.main(null)
   9  Hello, World!

真面目に勉強するなら、Scala By Example(英語/PDF)とかを読むと良いのかも知れません。

とりあえず、今回はこれだけで。

面白そうなのは、ScalaのコードをAndroidで動かすとかですかね。

Android携帯ほしい><

posted by Png y_tsuda on Mon 6 Jul 2009 at 07:10
Contents
GentooにScalaをインストールしてみた
Comments
Aleksey: The uname check is only due to a somewhat slopp... '11-2
Yu Tsuda: あぁ、そうですね、、syncすると戻ってしまいますね・・・。 ご指摘ありがとうございます!! '09-7
ursm: /usr/portage 以下のファイルは更新のたび元に戻ってしまうので、/etc/porta... '09-7
Yu Tsuda: 見た目だけでも、わざわざGentooをこういうリストに入れてるのがすごいなぁと思ったりしたので... '09-3
Leonard Chin (レオ): ただし、VirtualBoxで「Gentoo」などを選択しても、別にどのOSを入れても大丈夫だ... '09-3
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ