One fine cold day in fall of 2019, I was looking over the annual combinatorial algorithm challenge on Kaggle. I had some ideas about what to try. Using what language? No way did I want to use C or C++, which are death to any at-home personal projects. Death for at-work projects too, usually.
No way did I want to use any dynamic typing, as in Python or Ruby, just because my mind doesn’t work that way, and I’ve been using statically typed languages since eons ago. High execution performance is usually important to most work I do, which often involves 3D graphics, heavy physics number crunching, interfacing real-time with electronics, and an occasional data science project. Despite that, I do use Python often for quick and simple things, using PySide if it needs a GUI.
Beside this Kaggle thing, I had several fuzzy ideas for projects in mind for the coming months, for which I wanted to use a language I wouldn’t be cussing at while trying to get things done.
A bit of Googling turned up Crystal. I liked Ruby, having learned the basics of that back around 2004 or so. Nice syntax, but slow! Matz did a great job of language design, in any case. So now I could compile a language I liked, direct to machine code for speed. I’ll buy it!
Soon after discovering Crystal, I found the book Programming Crystal by Balbaert and St. Laurent. I was impressed by all the little design decisions along the way, all in harmony with what I like in a language. Also enjoyed the from-the-trenches stories of companies benefitting from using Crystal. Now I’m a fan, and when Crystal reached 1.0, a fan for life!
Some other languages I like and use for personal projects are D, Julia and Odin. I’m fluent in D, but sometimes get annoyed at losing time trying to figure out certain simple things, like how to pass a pointer to a struct to a function taking an void array (or something like that). I don’t know, maybe all languages make that hard. As a low-level bit-twiddling, electronics interfacing, binary protocol speaking kind of guy, I like C’s void pointers and complete freedom of casting pointer types.
I might like Rust and Zig, but Rust’s syntax for certain common situations is a groaner, and the borrow checker is indeed a pain as others say. Zig gives up if you declare a variable but don’t actually use it, as if all source code is at all times production and deployment worthy and thus needs to meet high standards always. Not for me! I spend most of my time scaffolding and experimenting, sketching in parts of what will be but not fully used. In contrast, Crystal, and most other languages, are tolerant of messy work in progress.
I tend to have a dim opinion of garbage collection, but use languages with it anyway. GC does let me concentrate more on the math and algorithms and bit-fiddling at a higher level, and it’s fine as long as maximum performance is not important. When performance does matter, I’m pretty good about creating and destroying objects outside of any inner loops. Still, I’m always more comfortable with manually dealing with memory.
It’s interesting to compare Crystal with Julia. Crystal says: C performance with Ruby Syntax. Julia claims to solve the two-language problem, which is writing small-scale working code in Python or other high level language then rewriting in C or other optimizing machine-targetting compiled language. Seems like Crystal could claim that, but for the last few years has been living mostly in the world of web back ends and business-world use cases.
Crystal is an excellent language. It’s not just for Rubyists. I’d like to see more Crystal in the world of theoretical physics, creativity tools and high performance 2D and 3D graphics.