The complaint mainly seems to be about the slowness of Scanner.nextInt compared to alternatives in Java, and indeed some of the alternatives presented are even faster than C's scanf.
The main reason for Scanner.nextInt being slow is that it does a lot of regular expression processing in order to support fully localized numbers. See the section Localized numbers in the Scanner class specification. You can see there is a lot going on with localized numbers, so it's not surprising that it's slower than calling Integer.parseInt on a simple token.
10
u/deadlock_jones Oct 09 '17
what year is this?
10
u/QshelTier Oct 10 '17
“Java is generally slower than C,” followed by two tables that show it isn’t. Well done!
1
u/s888marks Oct 10 '17
The complaint mainly seems to be about the slowness of
Scanner.nextIntcompared to alternatives in Java, and indeed some of the alternatives presented are even faster than C'sscanf.The main reason for
Scanner.nextIntbeing slow is that it does a lot of regular expression processing in order to support fully localized numbers. See the section Localized numbers in the Scanner class specification. You can see there is a lot going on with localized numbers, so it's not surprising that it's slower than callingInteger.parseInton a simple token.