Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Crystal 0.27.0 released

Save for later
  • 4 min read
  • 05 Nov 2018

article-image

Crystal is a general-purpose, object-oriented programming language with support from over 300 contributors. Last Friday, Crystal 0.27.0 was released.

Language changes in Crystal 0.27.0


From Crystal 0.27.0, if the arguments of a method call need to be splitted across multiple lines, the comma must be put at the end of the line just before the line break. This is more in line with other conventional languages.

Better handling of stack overflows


A program entering an infinite recursion or running out of space in the stack memory is known as a stack overflow. Crystal 0.27.0 ships with a boundary check that allows a better error message on stack overflow.

Concurrency and parallelism changes


The next releases should start showing parallelism. There are some steps in preparation for that.

The Boehm GC has API that enables support for multithreading environment in v7.6.x. From this version of Crystal, GC 7.6.8 or greater is used. As Crystal 0.26.1 was shipped with v7.4.10, the dependency needed to be updated first so that the CI can compile the compiler with the new GC API. Also, refactoring was done to separate the responsibilities of Fiber, Event, Scheduler, and EventLoop.

Arithmetic symbols added


In Crystal 0.27.0, arithmetic operators like &+, &-, &* were added. They are for additions, subtraction and multiplication with wrapping. In one of the next versions, the regular operators will raise on overflow. This will allow users to trust the result of the operations when reaching the limits of the representable range.

Collection names changed


In Indexable module and Hash, there are some breaking changes. The Indexable#at was replaced in favor of Indexable#fetch. The API between Indexable and Hash is now more aligned in the latest version. This includes ways to deal with default values in case of a missing key. If no default value is needed, the #[] method must be used. This is true even for Hash, since Hash#fetch(key) was dropped.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at ₹800/month. Cancel anytime

Time changes


There are breaking changes to support cleaner and more portable names. All references to “epoch” should now be replaced to “unix”. Also effectively, Time#epoch was renamed to Time#to_unix, #epoch_ms to #unix_ms, and #epoch_f to #to_unix_f. ISO calendar week numbers are now supported. Changing the time zone while maintaining the wall clock is also easy.

File changes


Working with temporal files and directories needed the Tempfile class. Now the creation of such files are handled by File.tempfile or File.tempname. This change also tidies up the usage of prefix, suffix and default temp path.

Platform support


There was an issue detected in Boehm GC regarding while running in Google Cloud because. The fix for this will be released in the next version of GC. Meanwhile, a patch is included in Crystal 0.27.0.

There is some preparation for Windows support related to processes, forking, file handlers and arguments. Other fixes include fixing signals between forked processes, and dealing how IO on a TTY behaves in different environments.

Networking changes


HTTP::Server#bind_ssl was dropped since #bind_tls was introduced. It wasn’t removed to avoid a breaking change. The bindings for OpenSSL were updated to support v1.1.1.

Compiler changes


Support for annotations inside enums is added. Calling super will by default forward all the method arguments. Even if the call was expanded by macros in this version.

When using splats argument the type of values can be restricted. This also goes for the whole Tuple or NamedTuple that is expected as splatted arguments. A bug was present when these restrictions were used, now fixed.

For a complete list of changes, visit the Crystal changelog.

WebAssembly – Trick or Treat?

Mozilla shares plans to bring desktop applications, games to WebAssembly and make deeper inroads for the future web

The D language front-end support finally merged into GCC 9