Featured in AI, ML & Data Engineering

In this article, author shows how to use big data query and processing language U-SQL on Azure Data Lake Analytics platform. U-SQL combines the concepts and constructs both of SQL and C#. It combines the simplicity and declarative nature of SQL with the programmatic power of C# including rich types and expressions.

Featured in Culture & Methods

The book Agile Leadership in Practice - Applying Management 3.0 by Dominik Maximini is an experience report of the agile transformation journey of NovaTec. Maximini shares his experiences from applying principles and practices from Management 3.0, success stories, failure stories, and learnings from experiments.

Featured in DevOps

Yuri Shkuro presents a methodology that uses data mining to learn the typical behavior of the system from massive amounts of distributed traces, compares it with pathological behavior during outages, and uses complexity reduction and intuitive visualizations to guide the user towards actionable insights about the root cause of the outages.

Yu Kobayashi's HotRuby is a little different from other Ruby implementations, though. First off, it doesn't come with a Ruby parser - instead it executes opcodes of the Ruby 1.9 VM. Ruby 1.9, like Rubinius, compiles Ruby source code to opcodes which are then executed by it's opcode interpreter. These opcodes can also be stored on disk. HotRuby is also remarkable simply because it's written in JavaScript. In fact the opcode interpreter, runtime, and implementations of a few miscellaneous classes fit inside a ~40 KB JavaScript file: HotRuby.js (or look at HotRuby's Google Code repository.

HotRuby is written in JavaScript which also works in Flash, which is used for a few nice demos, eg. the Pinball Demo. The logic for these demos is written in Ruby, albeit it's important to mention that a lot of the functionality of the demos comes from libraries in Flash. However, this shows the close integration of the Ruby code with the underlying JavaScript platform. Using JavaScript classes and functions is very simple, both from an implementation and usage point of view. Eg. importing JavaScript classes in Ruby (from the PinBall Demo source):

In this case, $native is a global variable of type NativeEnvironment - as a matter of fact, it doesn't contain anything. In HotRuby, accessing members of objects of this type provides functionality. Eg. $n.import "Box2D.Dynamics.*" loads the given JavaScript classes. These can then be accessed the same way, ie. via the NativeEnvironment (in these samples, also from the PinBall Demo, it's stored in the variable $n):

Another way to see HotRuby in action is the Do It Yourself page. This allows to type in Ruby code and run it with HotRuby. The way this works is that the Ruby source is sent to a server side service that compiles the source to opcodes which are then returned and executed by HotRuby in the browser.

One issue with HotRuby, at the moment, becomes obvious after trying to run a few bits of Ruby code, or simply by looking at the list of implemented classes/methods: the library support of HotRuby is minimal (actually, only a handful of methods of crucial classes are implemented). As a matter of fact, it's easy to see the implemented base classes, as their implementation can also be seen at the bottom of the HotRuby.js source file.

This is, however, a problem that might not be that hard to solve anymore - at least when it comes to functionality (performance is a different question). The Rubinius project is hard at work reimplementing a lot of basic Ruby classes in Ruby, even basic Ruby library functionality which is usually implemented in C (for CRuby), Java (JRuby) or C# (IronRuby). The idea to implement as much of a language in the language is often referred to as "Turtles All The Way Down" (after a popular blog post by Avi Bryant, although the expression is older). Obviously, any parts interfacing with the outside (I/O, Operating System integration) would have to be ported and are specific to the underlying system. Also, unless the underlying runtime can optimize it, some base classes might need to be adapted to the underlying platform to allow for acceptable performance.

Ruby libraries in pure Ruby also open the possibility of a standalone HotRuby in the future. One of the missing pieces is a full Ruby parser - but this is being created by Ryan Davis' in the form of 'ruby_parser', a project to write a Ruby parser in Ruby. Together with a Ruby based compiler that takes a Ruby AST (ruby_parser produces them in ParseTree notation) and returns Ruby 1.9 opcodes, HotRuby could then work stand alone and run Ruby sources directly. (Both parser and compiler would have to be pre-compiled into opcodes, which HotRuby would then load - as soon as this happens the first time, it would be self hosting).

While HotRuby might not be able to run Rails yet - it allows to script objects accessible to JavaScript runtimes, such the ones found in browsers or Flash. It also makes it easy (it's only a 40 KB file) to take a look at the internals of a VM capable of running Ruby 1.9 opcodes.