5 ms·
Second one in Go: func IsPrime(n int64) bool { return big.NewInt(n).ProbablyPrime(0) } Each language has its own pros and cons. Go wants to be
by musabg 4y ago
Second one in Go:
func IsPrime(n int64) bool {
return big.NewInt(n).ProbablyPrime(0)
}
Each language has its own pros and cons. Go wants to be explicit and simple to be understood. Java is fully-featured.
This is just anectodal evidence anyways. And these are tools in the and, and no point for a "tool fight".
- vips7L 4y agoThe point of that example wasn't to show if there was a standard library function for it. It was to show the verbosity of writing code that contains if conditions, loops, and generic programming. I obviously could have written: new BigInteger(n).isProbablyPrime(0);
- bin_bash 4y agoMy general point is that if you put Ruby up against a nonspecific compiled language it's hard to argue Ruby is better. When you analyze something like Go vs Ruby or Go vs Java then the warts of particular languages come out.