title: Should Clojure arrays be as fast as Java arrays
body: <p>I guess they're the same thing but Clojure uses the Array class to manipulate.</p>
  
  <p>Anyway, I've been told that in Clojure if you really need speed then you can use arrays but between the following programs the Java version is much faster</p>
  
  <pre><code>(time
   (let [data (int-array 100000000)]
     (dotimes [q 100000000]
       (aset-int data q q))))
  </code></pre>
  
  <p>_</p>
  
  <pre><code>public class Array{
      public static void main(String[] args){
      long start = System.currentTimeMillis();
      int[] data = new int[100000000];
      for(int q = 0;q &lt; data.length;q++){
          data[q] = q;
      }
      System.out.println(System.currentTimeMillis() - start);
      }
  }
  </code></pre>
  
  <p>In contrast, this Clojure program that uses the IntBuffer class is almost as fast as the Java code</p>
  
  <pre><code>(time
   (let [data (IntBuffer/allocate 100000000)]
     (dotimes [q 100000000]
       (.put data q q))))
  </code></pre>