Jesse Storimer's Blog Archives tagged Ruby

Industrial strength signal handling in Ruby - August 16, 2013

This is a video clip from the latest edition of my Unix fu workshop, an online course about Unix programming for Ruby folk. Give it a watch to see part of the fun where we do industrial-strength signal handling (deferred signal handlers and the self-pipe trick) for a pre-forking web server we built. If you like it, sign up for ...
Read more

[Interview] Daniel Huckstep on Ruby's stdlib and golang - July 02, 2013

I recorded a conversation with Daniel Huckstep about two topics that always arouse discussion: Ruby's stdlib and the Go programming language. Daniel is a Ruby developer, Go convert, and the author of Go: The Standard Library (ebook). Here are the highlights with links straight to the transcript: Daniel's "Ruby Batteries Included" talk from Mountain West Rubyconf # Core library vs. Standard library # ...
Read more

Nobody understands the GIL - Part 3: Thread Safety - June 21, 2013

There are some misconceptions in the Ruby community about this question surrounding MRI's GIL. If you only take one thing away from this article today, let it be this: The GIL does not make your Ruby code thread-safe. But you shouldn't take my word for it. This series started off just trying to understand what the GIL is at a technical ...
Read more

[Screencast] Faster Rails test runs...with Unix! - June 19, 2013

Anybody who works on a moderate size Rails app can probably tell you: it takes forever to run a single test. I've definitely experienced this with some of the big Rails projects I've worked on, and it sucks! Goodbye productivity. Some smart people have been advocating ways around this. But if you've got an existing app, seeing the full benefit of these techniques involves ...
Read more

Nobody understands the GIL - Part 2: Implementation - June 14, 2013

Last time, I began wanting to take you on a deep dive into MRI to see how the GIL is implemented. But first, I wanted to make sure I was asking the right question. Part 1 formulated the question, but today we'll look for answers inside MRI itself. We'll go looking for that elusive creature they call the GIL In the ...
Read more

Nobody understands the GIL - June 12, 2013

Throughout most of my time in the Ruby community, MRI's infamous GIL has been an elusive creature for me. This is a story about thread safety, and finally catching that elusive creature to get a good look at it. The first time I heard mention of the GIL, it had nothing to do with how it worked, what it did, ...
Read more

[Interview] Brian Shirai on Rubinius 2.0, the GIL, and thread-safe Ruby code - March 26, 2013

Brian Shirai and I recorded a conversation about multi-threaded programming in Ruby and his work on Rubinius. Listen (or read the transcript) to hear about: what's the global lock and its effect on concurrency? why the GIL is not a substitute for thread-safety why multi-threading is hard to reason about, and the best approach to doing so the three things ...
Read more

Threads, Not Just for Optimizations - January 24, 2013

The Ruby community seems to be abuzz with people talking about threads. But often, the conversation is geared towards the fact that our machines all have multiple cores, and we (c|sh)ould be running our code in parallel, blazing fast on ALL the cores. I absolutely think this is a good idea, but I want to talk about the other side ...
Read more

Grow Your Unix Beard Using Ruby - November 27, 2012

The video of my Rubyconf talk was posted this week by the fine folks over at Confreaks. The talk introduces basic concepts in Unix system programming, namely: fork+exec. It walks through examples that use these system calls in Ruby, at a high level, then how Unicorn uses them. If you don't time to watch the talk, just skip to 18:00 ...
Read more

Matz is not a threading guy - November 08, 2012

I attended my very first Rubyconf last week. There were certainly some common themes that I kept hearing over and over again throughout the course of the conference. Among other things, there was JRuby, threading, the GVL, and MRI 2.0. We got to see a few talks about the new features in MRI 2.0. One of the oft-discussed features was ...
Read more

Screencast: Ruby's Socket API From the Outside In - October 24, 2012

One of the reasons I love Ruby is the elegant DSLs and wrappers it provides around complex constructs. Socket programing is no exception. In fact, this becomes really apparent when you look at socket programming. The low-level details and intricacies of the Socket APIs can be complex, but Ruby provides nice high level wrappers on top of the hard stuff. ...
Read more

Screencast: Ruby's IO Buffering And You! - September 25, 2012

Where I show you the difference between write() and syswrite(), explain what happens when you set sync = true, and dive into the Rubinius source code to bring it all together. I've been delving into Ruby's IO system lately and finding out lots of neat things. So I decided to share a few. The whole thing is less than 10 ...
Read more

5 Reasons You Should Use ri To Read Ruby Documentation - September 13, 2012

ri is a tool that ships with Ruby. It's a companion to rdoc, allowing you to 'display information about Ruby classes, modules, and methods' from your console. Despite its usefulness it's often overlooked in favour of searching Google. $ ri File $ ri Fil $ ri File.directory? $ ri Socket#accept $ ri ActiveRecord::Base.touch Over the last few months I've started ...
Read more

Passing Open Files Between Processes with UNIX Sockets - May 07, 2012

I want to share with you today a neat little technique I learned involving UNIX sockets. In the land of Unix everything is a file. This is faithfully mirrored in Ruby with the IO class. The IO class models any so-called files on a Unix system. This includes stuff like File, TCPSocket, UDPSocket, all of which are subclasses of IO. ...
Read more

Daemon Processes in Ruby - April 19, 2012

This is a sample chapter from my book Working With Unix Processes. Learning how stuff works under the hood is one of the most important things you can do as a developer. If this article pushes you in that direction then I encourage you to learn more about the book. Daemon processes are processes that run in the background, rather ...
Read more