title: How come my IO runs so slowly in Erlang?
body: <p>I'm reading 512^2 whitespace delimited doubles written in a text file to my Erlang program by piping them to stdin.</p>
  
  <p>In Erlang this takes 2m25s, in an equivalent Haskell program it takes 3s, so I must be going against the Erlang way of doing it in some way.</p>
  
  <p>Am I using Erlang's IO primitives in a stupid way, or is there something else wrong with my program?</p>
  
  <p>Note that I don't care about the order of the values in the resulting list, so no reverse operation.</p>
  
  <p>Erlang:</p>
  
  <pre><code>-module(iotest).
  
  -import(io).
  
  -export([main/0]).
  
  main() -&gt;
      Values = read(),
      io:write(Values).
  
  read() -&gt; read([]).
  
  read(Acc) -&gt;
      case io:fread("", "~f") of
          {ok, Value} -&gt; read([Value | Acc]);
          eof -&gt; Acc
      end.
  </code></pre>
  
  <p>Haskell:</p>
  
  <pre><code>module IOTest (
      main
  ) where
  
  main :: IO ()
  
  main = do
      text &lt;- getContents
      let values = map read (words text) :: [Double]
      putStrLn $ show values
      return ()
  </code></pre>
  
  <p>Thanks very much for any help.</p>