3 ms·
> If you recall Crystal is a statically typed language but you can omit explicit type restriction and the compiler will try to infer the type of variable. In ou
by pansa2 6y ago
> If you recall Crystal is a statically typed language but you can omit explicit type restriction and the compiler will try to infer the type of variable. In our code Crystal uses the Int32 type for the n variable which has the maximum value of 2,147,483,647 but the 47th number is higher. In this case we need to specify the type of n. We can use Unsigned Int 64.
Both Ruby and Python use arbitrary-precision integers throughout. I thought Crystal would do the same, given the frequent comparisons to Ruby. I assume the reason it doesn't is to enable AOT compilation (i.e. not only because Crystal is statically-typed)?
Is there a statically-typed language that does use arbitrary-precision integers throughout?
More generally, what other features are common in dynamic languages and rare in static ones, that aren't directly related to type-safety?
- phamilton 6y agoHaskell has arbitrary precision. JavaScript has fixed precision.
- mumblemumble 6y agoWell, they both have both. More or less. Haskell has Integer for arbitrary and int for fixed precision integers, for example. JavaScript has arbitrary precision integers (via BigInt), and fixed precision floats.