Name: Anonymous 2011-09-07 9:18
discuss
main.public static final strictfp zing
% cat echo.go
package main
import (
"fmt"
"os"
)
func main() {
//for i := 1; i < len(os.Args); i++ {
for i, arg := range os.Args[1:] {
if i != 0 {
//os.Stdout.WriteString(" ")
fmt.Print(" ")
}
//os.Stdout.WriteString(os.Args[i])
fmt.Print(arg)
}
//os.Stdout.WriteString("\n")
fmt.Println()
}
% time go build echo.go
go build echo.go 0.77s user 0.08s system 99% cpu 0.860 total
% for i in {1..3}; do time ./echo qwe asd; done
qwe asd
./echo qwe asd 0.01s user 0.00s system 90% cpu 0.011 total
qwe asd
./echo qwe asd 0.01s user 0.00s system 93% cpu 0.012 total
qwe asd
./echo qwe asd 0.00s user 0.00s system 88% cpu 0.011 total% cat Echo.java
public class Echo {
public static void main(String []args) {
for (int i = 0; i < args.length; i++) {
if (i != 0) {
System.out.print(" ");
}
System.out.print(args[i]);
}
System.out.print("\n");
}
}
% time javac Echo.java
javac Echo.java 1.87s user 0.18s system 112% cpu 1.834 total
% for i in {1..3}; do time java Echo qwe asd; done
qwe asd
java Echo qwe asd 0.23s user 0.05s system 100% cpu 0.282 total
qwe asd
java Echo qwe asd 0.24s user 0.05s system 101% cpu 0.280 total
qwe asd
java Echo qwe asd 0.23s user 0.05s system 101% cpu 0.279 total% for i in {1..3}; do time go run echo.go qwe asd; done
qwe asd
go run echo.go qwe asd 0.79s user 0.09s system 99% cpu 0.880 total
qwe asd
go run echo.go qwe asd 0.79s user 0.08s system 99% cpu 0.870 total
qwe asd
go run echo.go qwe asd 0.79s user 0.08s system 99% cpu 0.873 totalerrno or returning a value?panic/recover mechanism, which is basically what your exceptions are. However, you shouldn't use it for standard errors, only for truly catastrophic failures that make the continuation of this program (at least this piece of it) impossible.