Feeds

Making sense of Ruby

An IntelliSense Cure for Method Madness?

Top 5 reasons to deploy VMware with Tegile

Hands on We were six months into the project before we even realised we had a problem. Until that point, we had assumed IntelliSense was a trivial matter that could doubtless be wrapped up in an afternoon’s coding. After all, how hard can it be to program some lists of names that drop down when someone types a dot?

The answer, as we were soon to discover was: very, very hard…

The project in question is called Ruby In Steel and it’s a Visual Studio development environment for the Ruby language. Ruby is a so-called "dynamic" language, which is a polite way of saying that it's hugely unpredictable.

A Ruby program is so dynamic that you can never be sure what it is up to from one moment to the next. To take a simple example, when you write some stand-alone functions into the editor, those functions get bound into the base class of the entire Ruby class hierarchy. That means that every single Ruby class automatically "inherits" them - and the IntelliSense system is expected to know about it!

If we'd been developing an IDE for a more traditional language – C# or Java, say – life would have been so much easier. Those languages go to great lengths to tell you what they are up to. Each variable declares its data-type in advance and when a variable starts life as an integer it’s pretty safe to assume that it’s going to stay an integer until the great garbage collector in the sky finally pops it out of existence.

With Ruby, you can't make any such assumptions. The types of variables are not declared and they are infinitely changeable. A variable called x might be start out as "Hello world", suddenly change into 76.23 and, just for the heck of it, end its days as a small fluffy Teddy bear object called Eric.

Some code-completion systems solve this problem in a cunning way - they cheat. Instead of working out what type of object x is at any given moment, taking into account all the difficult stuff such as its scope, inheritance and context, they work alphabetically. If someone enters a dot followed by the letters ‘my’, they drop down a list of names such as ‘my_method’, ‘my_othermethod’ and ‘my_random_guess’ whether or not those methods have anything to do with the object in question.

Illustrates Ruby in Steel Intellisense.

Creating real IntelliSense (as in Figure 1) is much harder. The only way to do it properly is to analyse the code much as the Ruby interpreter itself does. The big difference is that the interpreter only goes into operation when a program is complete whereas an IntelliSense system has to deal with code that is constantly changing due to editing. After each change, it has to reanalyse the code all the way back up to the root of the entire class hierarchy. This sheer complexity of this analysis explains why IntelliSense systems for dynamic languages are not that thick on the ground.

Programmers often say that one of the defining characteristics of Ruby is that it's so much fun. All I can say is, they obviously haven’t tried programming IntelliSense for it! ®

Secure remote control for conventional and virtual desktops

More from The Register

next story
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
SLURP! Flick your TONGUE around our LOLLIPOP – Google
Android 5 is coming – IF you're lucky enough to have the right gadget
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Facebook, working on Facebook at Work, works on Facebook. At Work
You don't want your cat or drunk pics at the office
Soz, web devs: Google snatches its Wallet off the table
Killing off web service in 3 months... but app-happy bonkers are fine
prev story

Whitepapers

Choosing cloud Backup services
Demystify how you can address your data protection needs in your small- to medium-sized business and select the best online backup service to meet your needs.
Getting started with customer-focused identity management
Learn why identity is a fundamental requirement to digital growth, and how without it there is no way to identify and engage customers in a meaningful way.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
How to simplify SSL certificate management
Simple steps to take control of SSL certificates across the enterprise, and recommendations centralizing certificate management throughout their lifecycle.
New hybrid storage solutions
Tackling data challenges through emerging hybrid storage solutions that enable optimum database performance whilst managing costs and increasingly large data stores.