Java がこの世に出てからだいぶ経つようですが、出た当時に比べればだいぶはやっているようです。最近はJSPなどサーバで動くものも 作られています。apache.org では様々なフレームワークなどが開発されており、Javaを使うのが以前に比べて楽になりました。
ただ、Javaを使っていて少し気になる事が一つだけあります。javac JavaSource.javaと打ってからコンパイルが終わるまでの時間が かなりあるのです。コンパイラ自体もJavaで実装されているようなので、仕方がないことなのかもしれませんが、もう少し速くならないのか とよく思います。比べるのも変な話ですがせめてg++ -O0くらいにならないものでしょうか。
今回紹介したいのは、IBMのjikesという高速なJavaコンパイラです。 これはC++で実装されており、javacより5倍 ほど速いようです。半年ほど使ってみましたが、今のところバグには出会っていません。 ただ、ライブラリのパスを通さないといけなかったり、日本語など多言語環境で使う場合に文字コードを指定しなければならなかったり するので、注意点をまとめておきます。
標準的なUNIXのプログラムと同じように入れられるはずです。最近は様々なdistributionにパッケージがあるようです。 詳しいことは本家のdistributionのページを参照してください。
javacと違って、jikesはjavaの標準ライブラリの場所を知りません。そのため、ライブラリのパスを指定しないでjikesを実行すると、おそらく以下のような エラーが出ます。(MacOSX,finkの場合)
teru@server ~/src/java $ jikes lcs.java
Found 1 system error:
*** Semantic Error: You need to modify your classpath, sourcepath, bootclasspath, and/or extdirs setup.
Package "java/lang" could not be found in:
/sw/share/java/jde/bsh.jar
/sw/share/java/jde/checkstyle-all.jar
/sw/share/java/jde/jde.jar
.
.
.
.
.
.
teru@server ~/src/java $
見ての通り、ライブラリのパスが見つからないのです。そこで、環境変数で教えてあげます。MacOSXならclasses.jarの位置を、
teru@server ~/src/java $ export BOOTCLASSPATH=/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar
のように、また、それ以外、例えばLinuxなどはrt.jarの位置を
teru@server ~/src/java $ export BOOTCLASSPATH=/usr/java/j2sdk1.4.1/jre/lib/rt.jar
のようにすればよいでしょう。BOOTCLASSPATHは、CLASSPATHでも構いません。 前の環境変数を上書きしないように
teru@server ~/src/java $ export CLASSPATH=$CLASSPATH:/usr/java/j2sdk1.4.1/jre/lib/rt.jar
のようにするのもいいかもしれません。これらの内容は、気に入ったら.bashrcなどに追加することをおすすめします。
jikesはDefaultでは日本語などのEncodingを処理しません。そのため、ファイルに日本語などが含まれる場合は明示的にコードを 渡す必要があります。例えば、コンパイル対象のファイルがeuc-jpなら、
teru@server ~/src/java $ jikes -encoding euc-jp Somefile.java
とします。
<Zuu> Hai all
<rindolf> Zuu: hai hai.
<rindolf> Zuu: what's up , kit?
<rindolf> Zuu: or what are you , I forgot?
<Zuu> Hai rindolf :D
<rindolf> I am a reindeer.
<rindolf> But also a Llama.
<rindolf> And a cat.
<Zuu> I'm a Zuu
<rindolf> And a fish naturally.
<rindolf> Zuu: ah , OK.
<Zuu> :D
* rindolf creates a Zoo of Zuus
<Zuu> ^^
<rindolf> Are you the master Zuu?
<rindolf> Like Q is the master of the Q's in Star Trek?
<Zuu> i think im the only Zuu
<rindolf> Oh, one of a kind.
<Zuu> Which is kinda sad really :(
<Zuu> Who am i supposed to mate with?
<rindolf> Reminds me of
http://www.shlomifish.org/humour/Blue-Rabbit-Log/ideas.xhtml
<rindolf> Though I need to add that part.
<rindolf> Let me do it now.
<Zuu> whatever webserver you use, it doesnt provide the right
mimetype... At least IE 8 dont attempt to render the document
<rindolf> Zuu: you cannot using IE 8
<rindolf> Zuu: you need Firefox.
<rindolf> Zuu: it's application/xml+xhtml
<rindolf> Or Opera.
<Zuu> well, it indeed is the right mimetype... stupid IE
<Zuu> well, my FF crashed, so i just use IE when that happens
<rindolf> Zuu: ah.
<rindolf> FF crashed?
<rindolf> How strange.
<rindolf> Maybe you have a bad plugin.
<Zuu> It does that around 6 times a day
<rindolf> Not an extension - a plugin.
<rindolf> Ah, really.
<rindolf> Something is wrong in the Zuuniverse.
<rindolf> Or Zuumputer.
<Zuu> nah, i suspect one of the tabs are just doing some strange
stuff
<Zuu> memory leaking javascript ro something like that
<Zuu> it is kinda starting to annoy me
<Zuu> but with 90 - 120 tabs, it would take quite a while to find
out what tab it is
<Zuu> you might consider starting your articles, or whatever this
is, with an introduction telling what it's about
<rindolf> Zuu:
http://www.shlomifish.org/humour/Blue-Rabbit-Log/ideas.xhtml#the-angry-demon
<rindolf> Zuu: it's not an article - these are random ideas for a
screenplay.
<rindolf> Zuu: but I'll write an intro.
<Zuu> start the page with "Here are some of my random ideas for a
screen play im writing:"
<Zuu> at LEAST!
<Zuu> you cant just jump right into something without giving _any_
indication ow what the reader can expect
<Zuu> it simply doesnt make any sense as it is now
<Zuu> you could just as well have posted a log of ljuwidah talking
:P
<rindolf> Zuu: thanks.
<Zuu> :)
<rindolf> Zuu:
http://www.shlomifish.org/humour/Blue-Rabbit-Log/ideas.xhtml#intro
<rindolf> Interactive Web!
<Zuu> i think you have forgottoen to define the #intro anchor
<rindolf> Zuu: reload.
<rindolf> Zuu: it's there.
<Zuu> hah, caches... :P
<Zuu> :D
<rindolf> Pesky things.
<rindolf> Evil reindeers don't like caches.
<rindolf> Neither do cats.
<rindolf> I'm an evil reindeer but a good cat.
<Zuu> Hehe
<rindolf> Don't know how it works.
<rindolf> I guess good and evil are relative.
<rindolf> Or actually I wore a helmet of alignment change.
-- What kind of animal is a Zuu?
-- ##programming, Freenode
Phoebe: Today we're gonna start with some songs about barnyard animals.
singing
Oh, the cow in the meadow goes moo,
Oh, the cow in the meadow goes moo.
Then the farmer hits him on the head and grinds him up,
And that's how we get hamburgers.
+++: Nooowww, chickens!
-- David Crane & Marta Kauffman
-- "Friends" (T.V. Show) ( http://en.wikipedia.org/wiki/Friends )