Crystal clear programming

Crystal programming language 0.32.0: Ruby syntax plus C efficiency

Sarah Schlothauer
© Shutterstock / Sebastian Janicki

Do you love Ruby’s syntax but also desire the efficiency and speed of C? The Crystal programming language aims for the best of both worlds. It compiles to native code and uses object-oriented programming concepts under the hood. It received an update with version 0.32.0, which added a few improvements to the standard library and some code cleanup.

Have you been looking to test out a new programming language? Crystal plucks a feather from many programming languages, taking inspiration from their best features. It invokes the efficiency of coding in C and the syntax structure of Ruby.

The newest version, Crystal 0.32.0 releases with the help of 44 contributors and 197 commits.

While this language is under active development, it may undergo some heavy changes. See what its design goals are and what features were recently added as it works on becoming production-ready.

SEE ALSO: Usurping Java: Why aren’t new languages dethroning the old?

Language features & goals

From the language’s README on GitHub, its design goals are ambitious:

  • Have a syntax similar to Ruby (but compatibility with it is not a goal)
  • Statically type-checked but without having to specify the type of variables or method arguments.
  • Be able to call C code by writing bindings to it in Crystal.
  • Have compile-time evaluation and generation of code, to avoid boilerplate code.
  • Compile to efficient native code.

Developers already familiar with Ruby will have an easier time learning the basics since it shares many similarities. Just like Ruby, in Crystal, everything is an object.

In 2018, Mark Siemers wrote an article explaining why Ruby programmers should use Crystal. According to Siemers, Crystal is much faster than Ruby thanks to its compiler optimizations and powerful built-in HTTP server.

It is statically type checked, with a built-in interface. The language also recently introduced support for parallelism, which you can read about here.

Sample code

Here’s a sample of what an HTTP Server looks like in Crystal:

require "http/server"

server = do |context|
  context.response.content_type = "text/plain"
  context.response.print "Hello world! The time is #{Time.local}"

address = server.bind_tcp 8080
puts "Listening on http://#{address}"

The Hello World program does not require defining a “main” function.

It looks like:

puts "Hello world!"

Newest updates in Crystal 0.32.0

The latest version of Crystal is version 0.32.0. It introduces a few changes and language improvements.

Now, the boolean negation method  ! can be called as a regular method call as  expr.!.

The standard library received some code cleanup, and one breaking change with the removal of Readline .

Updates to the compiler include improved error messages when a filename is misspelled and the addition of the --mcmodel option. Version 0.32.0 fixes a few previous issues in the compiler and adds support for LLVM 9.

Users can also now specify code to either run before, after, and/or around the  it blocks of a spec or the hole suite. View the pull request to learn more about spec hooks.

Refer to the full changelog for a full rundown of what’s new.

SEE ALSO: Top programming languages in 2019: Python sweeps the board

Try it out

If you are interested in testing out this workhorse of a language, view the source code on GitHub and follow the installation instructions for your preferred platform. Reading Crystal’s source code is easy, as 98.2% of the language is directly written in, you guessed it, Crystal.

Test it out. Compile and run code with the in-browser playground.

Will learning Crystal be your newest New Years’ Resolution?

Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is the editor for She received her Bachelor's degree from Monmouth University, West Long Branch, New Jersey. She currently lives in Frankfurt, Germany with her husband and cat where she enjoys reading, writing, and medieval reenactment. She is also the editor for Conditio Humana, an online magazine about ethics, AI, and technology.

Inline Feedbacks
View all comments