FreeBasic and QB64 speed

Found this by accident

Without the dim
The below code is fast with the 1st FOR loop (16.5M iterations) in both in FreeBasic and QB64.
It’s excruciatingly slow for both with the 2nd FOR loop (17M iterations). I’m talking go brush my teeth, come back…still not finished!

With the dim
FreeBasic is fast (for Basic) using either For, with either dim
QB64 fast using either For with 2nd dim, 1st dim gives an overflow

dim i as integer  'FreeBasic only
dim i as long  'FreeBasic or QB64
print "Start"
' For i = 1 To 16500000: Next i
For i = 1 To 17000000: Next i
print "End"

It’s not surprising that defining the variables with their types, made it faster. It was surprising how slow it was by not.