Why Type Safety
The Cost of Runtime Errors
# Ruby - Runtime errors
def show
user = User.find(params[:id])
render json: user.to_josn # Typo: discovered when user hits this endpoint
endCompile-Time Guarantees
# Crystal - Compile-time error
def call
user = User.find(params["id"])
user.to_josn # Error: undefined method 'to_josn' for User
endTypes as Documentation
Without Types
With Types
Refactoring Confidence
Scenario: Rename a Method
Request Validation
Response Type Enforcement
Nil Safety
IDE Support
Performance Benefits
Trade-offs
More Upfront Code
Learning Curve
Less Flexibility
The Azu Position
Comparison
Aspect
Dynamic (Ruby)
Static (Crystal)
See Also
Last updated
Was this helpful?
