nimcr's 66 lines long: <https://github.com/PMunch/nimcr/blob/master/nimcr.nim>
    
    
    if not exeName.fileExists or filename.fileNewer exeName:
      # compile it
    ...
      let p = startProcess(exeName,  args=args[args.low+1 .. ^1],
                           options={poStdErrToStdOut, poParentStreams, 
poUsePath})
      let res = p.waitForExit()
      p.close()
    
    
    Run

It builds an executable if the source has been edited since, or if the file 
doesn't exist, and then it runs the executable. Just from your timing you can 
see that `nim r` does a lot more than this. For one thing `nim r` likely tries 
a lot harder to make sure it misses cache when it should. nimcr's much more 
appropriate for a script that's mostly going to be run as a script and rarely 
rebuilt.

Reply via email to