Welcome!

Ruby-On-Rails Authors: Liz McMillan, Pat Romanski, Elizabeth White, Hovhannes Avoyan, Yeshim Deniz

Related Topics: Ruby-On-Rails, Java IoT, Open Source Cloud, Machine Learning

Ruby-On-Rails: Article

Can Ruby Live Without Rails?

A blitz interview with Bruce Tate

I do not know, use, or have an opinion on the Ruby language yet. But since this language climbed up to the 13th place in the Tiobe index, it deserves to be taken seriously. Bruce Tate is a well know proponent of Ruby. While some people are quick to blame any Java developer who is looking into other  languages,in my opinion it's an attitude of  weak people. If we want Java keep evolving, we need to look around.  I’ve asked Bruce several questions  about this programming language, and this is our blitz-interview.

Why this 13-year old language was not known in the programming community until the Ruby on Rails came about?

I looked into this extensively for my Beyond Java book. Three important points in time are

1) The emergence of a language. This does not always coincide with the emergence of the catalyst.

2) The emergence of the catalyst. With Oak/Java, you could argue that this catalyst was applets in Netscape.

3) Point of no return. We've never seen a language emerge, wait twenty years, and then explode. At some point, we decide that we know all there is to know about a language, and then nothing can really help it. I'd put Smalltalk and Lisp into the camp of good languages that will never dominate commercially.

Ruby is a little strange for two reasons: it has no major commercial support (outside of Japan), and it stayed below the radar in Japan for such a long period of time. But the real point that you've got to measure is the emergence of the catalyst. Right now, the whole Ruby community--book sales, education, components--everything is wrapped up in Ruby on Rails.

I'm interested in Ruby, and a whole lot of other people are in this camp too, because it's a dynamic language with a catalyst. Other languages have better web development experiences--Seaside on Smalltalk, for example. But Rails has traction, and the combination of productivity in a clean language with good market share is tough to beat.

Is creation of Web applications the main/only area where this language shines (I'm talking about the real-world business applications)?

Specifically, Ruby is a great language for metaprogramming. Think domain specific languages, open classes, templates, etc. Ruby is a higher level language than Java, with some functional programming tendencies, and powerful idioms that Java doesn't yet share. A few things that I notice about Ruby are:

- Dependency injection happens, but not through a framework. You can redefine an object or class to do method injection trivially. (The concept is called open classes in Ruby.) This capability makes testing much easier than it is in Java.

- Ruby has a JSP-like model for substitution, and you can use it as a template for HTML/XML documents, but also for code. For example, you can have a template with variable substitution, and append that text as code to a class. This capability makes application generators almost trivial. You've probably seen Rails scaffolding if you've seen a Rails demo. But you can extend this scaffolding to build a surprisingly complete application, given a powerful enough metamodel. The streamlined project does exactly this. (streamlinedframework.org).

- You don't see much emphasis at all on AOP. Ruby uses the language itself to handle crosscutting concerns. Ruby 2.0 will hook before and after, and then you really won't need AOP. Just open up the class and add interceptors in the places you need them with a handful of code.

So Ruby is a fantastic applications language. I'm doing projects now with around 150 tables, a very sophisticated web interface with tree views and AJAX on 20% of the views, and very complex business logic around rebalancing trees and optimal distribution algorithms. Ruby's symbolic programming model makes this logic easier to reason through, and Ruby's superior testing help me tremendously. I'd do this project with 3 times the Java programmers, and it would take a little less than twice as long. (It won't be as fast as I'd make it with Java, but I don't need it to be. The latency, as always, is in the database.)

But all of this flexibility comes at a cost. I can't see Ruby as a platform for building middleware or operating systems. Enterprise programming (distributed 2pc, hard core orm) will take some time, and more investment than you see at this point. Right now, Ruby is a great applications language. I'd expect to see Ruby grow as a rich client framework. But it's not a one-size-fits-all tool.

I'd love to see better Java/Ruby integration. I think it's going to be important over time.

Imagine, that you have the right to add five Ruby language elements  to the next version of Java. What would they be? Can you include quick code samples as well?

1. Closures.

Closures give you the ability to pass a code block as a parameter. At times, I'm simply looking for convenience. I can use a closure to print something 10 times:

10.times {puts "Hello"}

call do_something on each item in an array (this code example uses do and end in place of {}):

array.each do |item|
item.do_something
end

build a collection containing the squares of all items in an array:

array.collect {|number| number * number}


Other times, I want to customize the inside of a block of code. For example, when you deal with a file, you must make sure you handle exceptions, and clean up resources, leading to a repetitive ugly block of code. But with closures, you can do something like this:

File.open(filename) {|f| doSomethingWithFile(f)}

The open method can take care of all of the repetitive details for you. Closures help whenever you want to deal with blocks of something. Closures are a huge win for Ruby, and the design pattern is actually used frequently in Java within frameworks like Spring.

2. Continuations

The second feature is the continuation. Using a continuation, you can capture the state of execution within one instance variable. Think of a continuation as a save_game in an adventure game. You can pick up the game, in progress, when you restore the game. This is a code example of a continuation:

def loop
for i in 1..10
puts i
callcc {|c| return c} if i == 5
end
end

This code captures the state of the loop method at the point where i is 5. If you called the method with the command:

continuation = loop

Ruby would produce

1
2
3
4
5


Then, you could type

continuation.call  

and get the result

6
7
8
9
10

This type of processing is extremely important for the next-generation web server, and for implementing things like virtual machines (if you use a continuation-passing style, you can easily implement virtual machines with more stack depth, lightweight threads with cooperative multiprocessing, and many other interesting algorithms. RIFE builds their own version of continuations, so some Java frameworks already need this capability.

3. Mix-ins

Within Ruby, you don't need AOP as frequently. You can implement something like a Java interface, but a module can give you both the implementation plus a specification. Java uses whole frameworks to give you the same capability. In the age of pojo programming, it would be incredibly useful to say I want this POJO, and mix in security, persistence, and transactions. Ruby modules, which provide mix ins, can do just that.


4.Open classes

Open classes let you open up and redefine a class in any context. You don't have to rewrite the Integer class, for example, to add in the processing for units that an ingeger, or fixnum in Ruby, might need. You just implement methods that handle the math and the syntax you need.

For example, you could say

class Fixnum

// A fixnum represents a time in miliseconds.

def days
// convert to miliseconds
self.hours * 24
end

def hours
// convert to miliseconds
self.minutes * 60
end

def minutes
// convert to miliseconds
self.seconds * 60
end

def seconds
// convert to miliseconds
self * 1000
end


def from_now
Time.now + self
end

def ago
Time.now - self
end

end


Now, I can say things like 10.days.ago, and 6.hours.from_now, adding a certain richness to my domain specific languages. This capability is extremely powerful for testing also.


5. Full object orientation


In Ruby, everything is an object. When that's true, frameworks become much easier to consume and write, because you don't have to deal with so many mind-numbing special cases. Autoboxing gets you closer, but not all the way. Look at the API for an array. With a similar number of methods, the Ruby array is much, much more powerful. The reason is that the Ruby array doesn't have to deal with every special case for primitive types.

Those are a good place to start, but there are many others as well.

I make my living working as a Java architect/developer.  Can you give me a good pragmatic reason to learn Ruby? Is there a job market demand for Ruby skills?

Whenever you learn a new language, it changes the way you think. The Java programmers that I know that also know Ruby don't use as much configuration, and take better advantage of their collections than Java counterparts do. They also look for more opportunities to do metaprogramming.

But there's certainly a demand for Ruby developers, too. My latest book, From Java to Ruby, helps managers who need to do Ruby for technical reasons, understand the political implications of such a move. I wrote the book because of an increasing demand for literature for people seeking to use the right tool for the job, rather than blindly using the most popular choice of tools. I found that Ruby development efforts are out there.

I think we're also constantly underestimating the possibilities for integration across languages. The ReST-based web services in Rails are very rich, and the integration options for JRuby, a Ruby virtual machine implemented in Java, can blow your mind. Think of Ruby scripting in a JSP, or Ruby rules in a Java rules engine, or Ruby tests for Java code. Minimally, Ruby is a fantastic scripting language, and Java developers can take advantage of this exploding frontier.

Whether or not it is Ruby, I teach all of my students to learn another language. The effort will make you a better programmer.

Today, my second language is ActionScript 3,  and maybe Ruby will be the next one. I'll  keep learning other languages  to be a better Java programmer! Thank you, Bruce!

More Stories By Yakov Fain

Yakov Fain is a Java Champion and a co-founder of the IT consultancy Farata Systems and the product company SuranceBay. He wrote a thousand blogs (http://yakovfain.com) and several books about software development. Yakov authored and co-authored such books as "Angular 2 Development with TypeScript", "Java 24-Hour Trainer", and "Enterprise Web Development". His Twitter tag is @yfain

Comments (5) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Steve Conover 07/26/06 11:55:07 PM EDT

"Imagine, that you have the right to add five Ruby language elements to the next version of Java. What would they be? Can you include quick code samples as well?"

This really gets at the core problem with Java: Sun. Sun has stated that java is a "blue collar language", and actively wants to protect developers from themselves (e.g. forget about macros, they won't even expose parameter names to reflection because of people might do horrible things). Between the bureaucratic mindset, and overarching goals like bytecode compatability, Java is effectively frozen.

AJAXWorld News Desk 07/26/06 04:44:39 PM EDT

The Ruby programming language climbed up to the 13th place in the Tiobe index, it deserves to be taken seriously. Bruce Tate is a well know proponent of Ruby. While some people are quick to blame any Java developer who is looking into other languages,in my opinion it's an attitude of weak people. If we want Java keep evolving, we need to look around. I've asked Bruce several questions about this programming language.

AJAXWorld News Desk 07/26/06 04:07:03 PM EDT

The Ruby programming language climbed up to the 13th place in the Tiobe index, it deserves to be taken seriously. Bruce Tate is a well know proponent of Ruby. While some people are quick to blame any Java developer who is looking into other languages,in my opinion it's an attitude of weak people. If we want Java keep evolving, we need to look around. I've asked Bruce several questions about this programming language.

AJAXWorld News Desk 07/26/06 03:08:52 PM EDT

The Ruby programming language climbed up to the 13th place in the Tiobe index, it deserves to be taken seriously. Bruce Tate is a well know proponent of Ruby. While some people are quick to blame any Java developer who is looking into other languages,in my opinion it's an attitude of weak people. If we want Java keep evolving, we need to look around. I've asked Bruce several questions about this programming language.

AJAXWorld News Desk 07/26/06 02:54:34 PM EDT

The Ruby programming language climbed up to the 13th place in the Tiobe index, it deserves to be taken seriously. Bruce Tate is a well know proponent of Ruby. While some people are quick to blame any Java developer who is looking into other languages,in my opinion it's an attitude of weak people. If we want Java keep evolving, we need to look around. I've asked Bruce several questions about this programming language.

@ThingsExpo Stories
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...
@DevOpsSummit at Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, is co-located with 22nd Cloud Expo | 1st DXWorld Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
SYS-CON Events announced today that T-Mobile exhibited at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on qua...
SYS-CON Events announced today that Cedexis will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Cedexis is the leader in data-driven enterprise global traffic management. Whether optimizing traffic through datacenters, clouds, CDNs, or any combination, Cedexis solutions drive quality and cost-effectiveness. For more information, please visit https://www.cedexis.com.
SYS-CON Events announced today that Google Cloud has been named “Keynote Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Companies come to Google Cloud to transform their businesses. Google Cloud’s comprehensive portfolio – from infrastructure to apps to devices – helps enterprises innovate faster, scale smarter, stay secure, and do more with data than ever before.
SYS-CON Events announced today that Vivint to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. As a leading smart home technology provider, Vivint offers home security, energy management, home automation, local cloud storage, and high-speed Internet solutions to more than one million customers throughout the United States and Canada. The end result is a smart home solution that sav...
SYS-CON Events announced today that Opsani will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Opsani is the leading provider of deployment automation systems for running and scaling traditional enterprise applications on container infrastructure.
SYS-CON Events announced today that Nirmata will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Nirmata provides a comprehensive platform, for deploying, operating, and optimizing containerized applications across clouds, powered by Kubernetes. Nirmata empowers enterprise DevOps teams by fully automating the complex operations and management of application containers and its underlying ...
SYS-CON Events announced today that Opsani to exhibit at SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California. Opsani is creating the next generation of automated continuous deployment tools designed specifically for containers. How is continuous deployment different from continuous integration and continuous delivery? CI/CD tools provide build and test. Continuous Deployment is the means by which...