DEV Community

Discussion on: My favorite things in Crystal Lang

Collapse
 
shayneoneill profile image
shayneoneill • Edited

For me the Jewel in Crystals crown is the type system. I've recently found myself working with some fairly large Swift codebases, and gotten a good chance to compare and contrast Swifts solution to Nulls and Crystals. Swift goes with boxing/unboxing , Crystal goes with Union typing. To me its much easier to reason about Crystals type system than having to constantly wrestle with boxing/unboxing semantics in Swift, and then even after that , you still dont get the nearly-but-not-quite dynamism of Crystals union types.

I genuinely feel every time Crystal trips me over and forces me to rethink something that could potentially suffer NULL harm, its making me into a better, more defensive, programmer.

I do wish Crystal had typed Nulls. Like there IS an issue where sometimes you want nulls, say as a field coming out of a database, but you'd like to distinguish between "Im a dummy and created null harm by not initializing properly" and "This field returned a nill", because the solutions to both are very different.