Ruby 2.1.0-rc1 is out!

While we live in a rich-clientside world these days, a new release-candidate of Ruby MRI is still interesting stuff for me. The Ruby project is going for a shorter release cycle, and since version 2.0 the following features has been introduced:

  • VM (method cache)
  • RGenGC
  • Refinements
  • syntax changes
    • Decimal/Complex Literal
    • def’s return value
  • Bignum
    • use GMP
  • String#scrub
  • Socket.getifaddrs
  • RDoc 4.1.0 and RubyGems 2.2.0
  • “literal”.freeze is now optimized
  • add Exception#cause
  • update libraries like BigDecimal, JSON, NKF, Rake, RubyGems, and RDoc
  • remove curses

While I'm no expert, I'll try my best to explain the changes I find most interesting for my everyday use.

New garbage collector: RGenGC

The Ruby MRI Garbage Collector (GC) is a "mark and sweep" collector, which in short means it maintains a reference tree of all objects living in the memory with a flag whether the object is still being used (aka unreachable), or can be wiped. This "bloats" the objects a bit (pun intended), but works like a charm.

The Ruby GC wipe has been implemented as a "stop-the-world" wipe. As the name suggests, this freezes the process, traverses the tree of marked objects, and takes out the trash, while the unreachable objects remain in the tree. The bigger the tree, the longer it takes.

With the new RGenGC, they have added a twist to the traditional mark and sweep, called "generational GC" or "ephemeral GC" if you like fancy words. What it does, is in practice a really logical way of approaching the tree of objects in memory. It expects that new objects are more likely to be unreachable, and takes that into consideration when traversing the reference tree, reducing the average time spent taking out trash by 39%. While the time spent in GC is not huge in 2.0, this might prove to be a good performance increase for some applications that depends on a quick GC.

Method definitions now return a symbol

Prior to 2.1, this code in Ruby MRI would return nil:

def foo; end

With the changes to method definitions in version 2.1, the same code will return a symbol of the method name: :foo. At a first glance, it doesn't look like much of a useful change, but it enables you to write private methods like this:

class Foo
  private def super_private_method

  def some_public_method

Which is a syntax i prefer over the old syntax.

Required keyword arguments

With this change, you now have a nice way of being explicit when requiring arugments to your public methods, without too much hassle. Given this example method:

def do_something_to_a_word( word: )

Calling it just by do_something_to_a_word would return ArgumentError: missing keyword: word.


Get the Ruby MRI 2.1 and test while it's hot, and if you're into more tech about the changelog or GC theory, check out these links:

Any thoughts? Check out the comments for this post.

I'm back!

I've finally revitalized my old domain after the last hosting provider unplugged some time ago. This time around I'm actually trying out a pre-made blog engine for the first time, called Ghost.


What makes Ghost so special?

About a year ago, John O'Nolan wrote a post about what was wrong with current blog platforms like Wordpress, and introduced his ideas for a new blog engine that was easy to use, beautiful to look at, and fully customizable. October 2013, they released the first public version of Ghost after receiving nearly £200,000 crowd funding on kickstarter.

Since the release, many new features have come along, and there's a growing community of theme-makers, hackers and just plain bloggers (now including myself).

For me, the code itself is what triggered me to give it a shot. For the last 6 months, I've been trying to get a grip of making apps with JavaScript, or CoffeScript to be precise. Including rich client-side apps with Ember.js, and backend with Node.js instead of the traditional Ruby on Rails app that I love to make. Ghost is written using Node.js, and does it real good.


So far, I've only stumbled upon a couple. I wanted to host Ghost on Heroku, as we do with all the other apps we have, but Ghost is not compatible with the Heroku architecture yet because it's relying on putting images uploaded directly to the local filesystem, instead of a cloud store like Amazon's S3. Hopefully someone have time to integrate Filepicker or some other service soon. I ended up hosting my Ghost on Ghostify for a small monthly fee.

Also, not quite a caveat, but adding your tracking code for analytics requires you to edit your theme. When using Ghostify, that requires you to use FTP to transfer your changes. Hopefully they'll get some Git service soon.


For more information, check out these resources:

Any thoughts? Check out the comments for this post.