Playing with Crystal Lang

crystal-lang-logoToday I spent a few hours playing around with the Crystal language.  For a project that’s considered “new” the docs are pretty great.  Coming from the world of Ruby writing basic Crystal code is straightforward and most of everything works as expected.

For fun and science I decided to try and throw together a simple program that would allow me to try the following:

  • Flesh out some basic classes
  • Raise exceptions
  • Use public/private methods
  • Import code

What I came up with is a pointless ~30 line program that takes a word, looks up the Wikipedia page for that word and finally prints the page’s title.  The code is extremely easy to read and while putting it together I found that most things just “worked” as they would in Ruby.

The only gotcha I found was that when extracting text from the page body’s title a MatchData object is returned and the matches are accessed via a block.  Ruby also has MatchData . Unlike Crystal, Ruby’s implementation provides MatchData#captures for a super easy way to access an array of the actual matches… which is what you probably care about.

Here’s the code:




  • Jennifer

    Hi there,

    I know this seems out of place… I am not spamming you. My name is Jennifer, I live in Seattle, and have 3 dogs (whose names are Ziggy, Zora, and Zeek just thought I’d put that in for good measure). I am starting a business and would REALLY like to use the domain zigzo.com. I see the domain is up for renewal next month, so I thought I would reach out to see if you’d be interested in selling. I don’t have much money allocated for domains, but I thought I would ask. I have some other zigzo domains that I could transfer to you to replace zigzo.com. If this is something that you might be interested in please email me at zora@zigzomarketing.com. Thanks for your time!

    • me

      Hey Jennifer,

      Thanks for contacting me and for the offer but I’d prefer to hold on to the zigzo.com domain.