Monday, March 5, 2012

Why critics of Rails have it all wrong (and Ruby's bright multicore future)

Edit: Contrary to what I said here, José Valim is not stepping down from Rails core, he is merely on sabbatical. My bad.

Lately I've been getting the feeling the Ruby community has gotten a bit emo. The enthusiasm surrounding how easy Ruby makes it to write clean, concise, well-tested web applications quickly is fading. Rails has become merely a day job for many. Whatever hype surrounded Rails at its inception has died down into people who are just getting work done.

Meanwhile, Node.js is the new hotness, and many in the Node community have sought to build Node up by bringing Ruby and Rails down. I know that once upon a time Ruby enthusiasts were doing this sort of thing to Java. However, the tables have turned, and where Ruby used to be the mudslinging hype-monkey, it's now become the whipping boy and Node.js the new provocateur.

The sad thing is many of these people are former or current Rubyists who have taken a liking to Node and build it up by spreading blatant untruths about Ruby. I won't go as far as to call them liars, but at the very least, they are extremely misinformed, ignorant of the state of the Ruby ecosystem, and pushing their own agendas.

Jeremy Ashkenas, the creator of CoffeeScript, recently trashed Rails 3 and claimed "Node.js won":


The idea that Rails 3 was a major step backward was recently reiterated by both Giles Bowkett and Matt Aimonetti. Both of them painted building ActionController::Metal applications as some sort of byzantine, impossible task which can only be accomplished by a Rails core member. Are people actually building lightweight Rails applications using the newfound modularity of Rails 3?


Jose Valim, (now former) Rails core member, published a small, simple gist illustrating how to build barebones apps on ActionController::Metal (one of the most forked gists I've ever seen) which is further documented in his book Crafting Rails Applications. In just 50 lines of code you can strip Rails down to its core, making it ideal for use in modern client-heavy HTML5 applications. The funny thing about this gist is that while the idea of a 50 line Rails app seems pretty impressive, the basis of that gist is what Rails 3 puts into your config/boot.rb, environment.rb, and application.rb, just combined into a single file. Did I just blow your mind? Sadly, all the (in my opinion completely undeserved) bad press seems to have made Jose emo as well, and he has stepped down from Rails to pursue his Elixir language.

ActionController::Metal-based applications (along with apps written in Clojure) were the basis of our backend at Strobe, where we sought to ease the pains of people building modern client-heavy HTML5/JS applications with frameworks including SproutCore/Ember, Backbone, and Spine. ActionController::Metal provided a great, fully-featured, mature, and modular platform for us to build applications on top of, and Strobe's ActionController::Metal stack for client-heavy HTML5/JS applications is available on Github. The apps we built with the Strobe ActionController::Metal stack talked only JSON and our frontend was an HTML5/JS application written with SproutCore.

Before Strobe, I worked at a company building rich HTML/JS applications for digital television. Our backend was written in Rails. Our frontends were Flash and HTML/JS applications, the latter of which were single-page client-heavy HTML/JS apps that were packaged in .zip files and installed onto digital televisions and set top boxes, a sort of weird hybrid of web technologies and installable applications. Our Rails application didn't have any views, but provided only a JSON API for the HTML/JS frontend to consume.

Rails was great for this, because it provided the sort of high level abstractions we needed in order to be productive, ensure our application was well-tested, and above all else provided the necessary foundation for clean, maintainable code. I was doing this in 2008, and even then this was already considered old hat in the Rails community. In case you're not paying attention, that's one year before Node even existed.

Modern HTML5/JS apps depend on beautiful, consistent RESTful JSON APIs. This is a great way to develop rich interactive applications, because it separates the concerns of what the backend business logic is doing from the view layer entirely. Separate teams, each specialized in their role, can develop the frontend and backend independently, the frontend people concerned with creating a great user experience, and the backend people concerned with building a great API the frontend application can consume.

Rails is great for JSON APIs.

And yet this meme persists, that somehow Rails is actually bad at JSON APIs. Those who propagate this meme insist that Rails has lost its edge, and that only Node understands the needs of these sorts of modern client-heavy web applications. Giles recently attempted to argue this position:


Giles recently blogged about this issue at length. Let's look at what he has to say about ActionController::Metal and the new level of modularity and clean design that Rails 3 brings to the table:


So Jose wrote a great book about the incredible power of Rails 3's new modular APIs... but... but... but what?

WARD CUNNINGHAM BITCHES. TWEETS > BOOKS. NODE WINS. QED.

Hurrrrrrrr? Ward Cunningham is a cool guy and his concept of a Wiki was a transformative technology for the web, but what the fuck does that have to do with Rails 3's new modular APIs or Jose's book? I think that's what people in logical debate circles call a "non-sequitur".

Perhaps there's still a cogent argument to be had here. Let's dig deeper:


Okay, so the problem is there's not a damn simple way to do websockets. OH WAIT, THERE IS:


Cramp is an awesome, easy-to-use websockets/server-sent events framework (with socket.io support) which runs on Rainbows or Thin, and Thin is a great web server. According to my benchmarks it's approximately the same speed as Node's web server:

Web Server            Throughput  Latency
----------            ----------  -------
Thin    (1.2.11)      8747 reqs/s (7.3 ms/req)
Node.js (0.6.5)       9023 reqs/s (7.1 ms/req)
Yes folks, Node isn't significantly faster than Ruby at web server performance. They're about the same.

Giles also bemoans bundler, because typing "bundle exec" represents ceremony, and using any of the myriad solutions to avoid typing "bundle exec", such as bundler binstubs or rvm gemsets, represents configuration which violates the Rails mantra of "convention over configuration", and how npm is that much easier. I'm sure we would all love to not have to add a one line .rvmrc file to each project to avoid typing "bundle exec", but uhh Giles, bro, mountain out of a molehill much?

Meanwhile, let's check out how convention over configuration is going in the JavaScript world:


But enough about Giles... what kinds of awesome, modern HTML5 applications are people using Rails to build?

I think one of the best examples of this sort of application is Travis CI. Travis is an open source distributed build system with an Ember-based frontend and a Rails backend. Travis's interface shows, in real time, the state of all builds across the entire (distributed) system, allows you to interactively explore the history, see the distributed build matrix completing jobs in realtime, and even have it stream the console output of builds in progress directly to your browser as they complete. It's an amazing, modern client-heavy HTML5/JS application, and it's built on Rails.

Who else is using Ruby/Rails for their frontend? Oh, just Twitter, LivingSocial, Groupon, Heroku, EngineYard, Github, Square, Zendesk, Shopify, Yammer, Braintree, Boundary, Stripe, Parse, Simple, and of course let's not forget 37signals. Rails is the technology underlying the frontend web stack of many huge businesses. Many of these companies have client-heavy HTML5/JS applications which consume a JSON API coming out of Rails. Many of them have APIs that are routinely cited as archetypical RESTful JSON APIs. Many of them have top notch engineering teams that choose the best tools for the job and use many languages for many different tasks. Many of them were founded "post-Node" and had the opportunity to choose Node as their frontend web technology, and while they may use Node in some capacity, their main consumer-facing sites are written with Rails.

Node is three years old now. Where are the Node.js success stories? Who's built a brand on top of Node?  Nodejitsu? Hubot? Is Node anything more than a pyramid scheme or a platform for Campfire bots? Where Rails selling points eschewed performance and instead focused on clear code, rapid development, extensive testing, and quick time-to-market, Node's selling points seem to universally revolve around its insanely fast, destroy the internet fast performance (benchmarks not provided). Meanwhile code quality is de-emphasized and large Node programs degrade into incomprehensible, byzantine structures of callbacks and flow-control libraries, instead of being written in sequential code, you know, the code you can read:

 

What about Ruby in general? What advancements in the Ruby ecosystem are worth getting excited about?

JRuby is maturing into a high-performance Ruby implementation which taps the JVM's advanced features including the HotSpot compiler, multiple pluggable garbage collectors, and parallel multithreading which makes it suitable for multicore applications. One thing I think sets JRuby apart is that it's the most mature language on the JVM which didn't start there. Other projects to implement non-JVM languages on top of the JVM, such as Rhino and Jython, have languished, while JRuby keeps going strong.

The most exciting development in JRuby is Java 7's new InvokeDynamic feature. The Java Virtual Machine was originally designed for the statically-typed Java language, but has its roots in dynamic languages, namely Smalltalk. With InvokeDynamic, the JVM has come full circle and now natively supports dynamic languages like Ruby. InvokeDynamic provides the necessary information to the JVM's HotSpot compiler to generate clean native code whenever Ruby methods are called, in addition to many other potential optimizations. So how much faster will InvokeDynamic make Ruby?


Rubinius, a clean-room Ruby virtual machine based on the Smalltalk-80 architecture, is also a very exciting prospect for the Ruby community as it matures and reaches production quality. It features an LLVM-based JIT compiler, parallel thread execution, and advanced garbage collection, also making it suitable for multicore applications. Beyond being an awesome Ruby implementation, Rubinius has evolved into a true polyglot platform and now features multiple Rubinius-specific language implementations including Fancy and Atomy.

MacRuby also eliminated the GIL from their implementation and now supports parallel thread execution along with an LLVM-based JIT compiler.

There are no less than three Ruby implementations which now support thread-level parallelism and thus multicore CPUs. This is especially relevant in a time when computing is undergoing a sort of phase transition from single-threaded sequential applications to massively multithreaded concurrent applications and distributed systems made out of these multithreaded applications.

It wasn't too long ago that having even four CPU cores in your home computer seemed like a lot, and now 16-core commodity AMD CPUs are available. The future is multicore, and if your programming language doesn't have a multicore strategy, its usefulness is vanishing. Following Moore's Law, the number of cores in a CPU is set to explode exponentially. Is your programming language prepared?

Thanks to JRuby and Rubinius, Ruby can take advantage of multicore CPUs. This still leaves the small matter that multithreaded programming is, uhh, hard. Fortunately I have some ideas about that.

Celluloid is an actor-based concurrent object system that tries to pick up on the concurrent object research that was hot in the mid-90's but died shortly after the web gained popularity. In the '90s concurrent objects were ahead of their time, but with the advent of massively multicore CPUs I believe it's an area of computer science research that's worth reviving.

Celluloid packages up Ruby's core concurrency features into a simple, easy-to-use package that doesn't require any modifications to the language. Where many functional languages solve the issues surrounding concurrency with immutable state, Celluloid solves it with encapsulation (more information is available on the Celluloid github page).

Celluloid takes advantage of many of the features of Ruby, including parallel threads, fibers (coroutines), method_missing (proxy objects), and duck typing. There aren't many other languages with this particular mix of features. Python probably comes the closest, aside from multicore execution due to its GIL. Jython supports parallel thread execution thanks to the JVM but seems abandoned. For what it's worth, Python once had a concurrent object system quite similar to Celluloid back in the '90s called ATOM, unfortunately the source code has been lost.

Ruby is by far the best language available today to implement a system like Celluloid, and that alone makes me excited to be a Rubyist. Where Node.js gives you a hammer, the single-threaded event loop, Celluloid gives you a large toolbox and provides a singular framework of interoperable components which can be used to build arbitrary hybrids of concurrent multithreaded applications, event-based nonblocking applications (that are callback-free!), and distributed systems.

Ruby is a language which can survive the massively multicore future. Whether Node will stick around remains to be seen.

251 comments:

«Oldest   ‹Older   201 – 251 of 251
Unknown said...

Thanks for the sharing
java software development company
hire java developer
Java web development company
Java development companies
Java development companies

Roja Priya said...

Thank you for sharing your article. Great efforts put it to find the list of articles which is very useful to know, Definitely will share the same to other forums.

best openstack training in chennai | openstack certification training in chennai | linux openstack training in chennai | openstack training in chennai | Openstack certification course in chennai | best Openstack certification training in chennai | openstack course fees in chennai | openstack certification in chennai

VRITPROFESSIONALS said...

Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
Thanks & Regards,
VRIT Professionals,
No.1 Leading Web Designing Training Institute In Chennai.

And also those who are looking for
Web Designing Training Institute in Chennai
SEO Training Institute in Chennai
Photoshop Training Institute in Chennai
PHP & Mysql Training Institute in Chennai
Android Training Institute in Chennai

Roja Priya said...

Good Post! It is very useful information to me. Thanks for sharing this...

pmp training in chennai | best pmp training in chennai | pmp course in chennai | project management courses in chennai | pmp certification course in chennai | pmp certification training chennai | pmp certification course fees in chennai | pmp certification cost in chennai

المتألقون للصيانة والتشطيب وكشف تسريبات المياه said...

شركة مكافحة حشرات بالخبر
شركة كشف تسربات المياه بالقطيف
شركة تنظيف بالقطيف

amsa leka said...

Thanks for such a great article here. I was searching for something like this for quite a long time and at last, I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays.angularjs best training center in chennai | angularjs training in velachery | angularjs training in chennai | best angularjs training institute in chennai

janu said...

You are doing a great job. I would like to appreciate your work for good accuracy
r programming training in chennai | r training in chennai
r language training in chennai | r programming training institute in chennai
Best r training in chennai

Cartoon HD said...

Hey, thanks for posting amazing articles. These blogs would definitely help us keep posted about new trends in the market. Thanks for sharing
Dentist in Kanpur

DjSongz said...

I have been a keen follower of your website.
recently I came across this topic and after reading the whole article I am amazed that how well you have written it.
All Latest Punjabi Song with Music Videos and Quotes - Here is the New Punjabi Songs list 2019 containing Best mp3 song of 2019

Aman CSE said...


Such a wonderful blog on Machine learning . Your blog have almost full information about Machine learning .Your content covered full topics of Machine learning that it cover from basic to higher level content of Machine learning . Requesting you to please keep updating the data about Machine learning in upcoming time if there is some addition.
Thanks and Regards,
Machine learning tuition in chennai
Machine learning workshops in chennai
Machine learning training with certification in chennai

Ramya Krishnan said...

This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points. To appreciate this I like to share some useful information regarding Microsoft Azure which is latest and newest,

Regards,
Ramya

azure training in chennai
azure training center in chennai
best azure training in chennai
azure devops training in chenna
azure training institute in chennai

karthick said...


Its a good post and keep posting good article.its very interesting to read.


Best Blockchain Training Institute in Chennai

التسويق الاكترونى said...

شركة تنظيف منازل بالرياض
شركة تنظيف فلل بالرياض
شركة تنظيف شقق بالرياض
شركة تنظيف موكيت بالرياض
شركة تنظيف كنب بالرياض
شركة تنظيف مجالس بالرياض
شركة تنظيف واجهات بالرياض
شركة تنظيف مساجد بالرياض
شركة تنظيف مكيفات بالرياض
شركة تسليك مجارى بالرياض

Ogen Infosystem said...

This was really informative and valuable information. Visit for the creative Website Designing and Development Services by Ogen Info system.
Website Designing Company in Delhi

roskey said...

I want to to thank you for this excellent read!! I certainly enjoyed every little bit of it. I have got you bookmarked to check out new stuff you post…

Happy Easter Images 2019
Happy Easter Coloring Pages 2019 Free Download
Happy Easter Quotes 2019 And Wishes
Happy Easter Poems 2019 And Quotes
Happy Easte Wishes 2019 For Status

Y and H Cargo India said...

Visit for the best Logistics and Freight Forwarders Companies in Delhi at Y & H Cargo India.
Freight Forwarders in Delhi

Spin Gurus said...

Spin Gurus is provided you the best service of Music Production.
Audio Engineering Courses

Mutual Fundwala said...

Nice Blog. If you Need best Mutual Fund in India MutualFundWala is best for you.
Mutual Funds India

unknown said...

Munnar is a motley canvas of sloping lush green tea plantations, gushing streams by the hillsides, and winding undulating paths. And there are some absolutely delightful activities to absorb the overwhelming beauty of the largest tea growing region of peninsular India.

best places in munnar to visit

Dj-Jatt said...

I have been a keen follower of your website.
recently I came across this topic and after reading the whole article I am amazed that how well you have written it.
All Latest new latest punjabi song download with free download punjabi songs and top punjabi song download

Rajesh Dhoni said...

Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
SEO company in coimbatore
Digital Marketing Company in Coimbatore

IT Tutorials said...

Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement | UiPath training in Chennai | UiPath certification in Chennai with cost

abhi pranesh said...

Great information you have been shared and it will be useful to everyone.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
German Classes in Chennai
TOEFL Coaching in Chennai
IELTS Coaching in Chennai
spanish language in chennai
Spoken English Classes in OMR
Spoken English Classes in Porur

Unknown said...

really awesome information dear. Great article you did.
SHAREit Download GB WhatsApp https://downloadluckypatcher.co

Infocampus said...

Good one.

selenium training in Bangalore
web development training in Bangalore
selenium training in Marathahalli
selenium training institute in Bangalore
best web development training in Bangalore

Raji said...

Your blog was really impressive and meaningful. Thank you so much for sharing with us.
R Training Institute in Chennai | R Programming Training in Chennai

المتألقون للصيانة والتشطيب وكشف تسريبات المياه said...

شركة تسليك مجارى بالجبيل
شركة تنظيف بعنك
شركة تنظيف بسيهات
شركة مكافحة حشرات براس تنوره

ammu12 said...

Thanks for such a great article here. I was searching for something like this for quite a long time and at last, I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays.Also Checkout: blockchain training in chennai | best blockchain training in chennai | blockchain courses in chennai | blockchain training center in chennai

abhi pranesh said...

Great innovative information about this technology. Thanks for posting this.
pearson vue exam centers in chennai
TOEFL Coaching in Chennai
French Classes in Chennai
German Language Course in Chennai
IELTS Coaching centre in Chennai
Japanese Language Classes in Chennai
Spoken English Classes in Porur
Spoken English Classes in Adyar

Yash Sharma said...

9Apps
Get-vidmate

Aruna Ram said...

Thanks for sharing with us.

Thank you! I learn lots of information from your post and I like your written style. I hope more unique post from your blog...

Corporate Training in Chennai
Corporate Training institute in Chennai
Social Media Marketing Courses in Chennai
Advanced Excel Training in Chennai
Tableau Training in Chennai
Pega Training in Chennai
Oracle DBA Training in Chennai
Corporate Training in Chennai
Corporate Training institute in Chennai

Roja Priya said...

Good job and thanks for sharing such a good blog You’re doing a great job. Keep it up !!

pmp training in chennai | best pmp training in chennai |
pmp certification cost in chennai | pmp training centers in chennai |
pmp certification fees | pmp certification requirements

Health Tips said...

Migrate a WordPress site webpage to another host is very pressure full due to lacking facilitating information or dread of harming inward piece of our site.

abhi pranesh said...

Good and awesome work by you keep posting it and i got many informative ideas.
German Classes in Chennai
german coaching classes in chennai\
IELTS Coaching in Chennai
Japanese Classes in Chennai
spanish language in chennai
Spoken English Classes in Chennai
German classes in Velachery
German classes in Tambaram

Kayal m said...

Great post! I hope more unique tips about this topic and I am always following your blog. Please keeping more updates...


Embedded System Course Chennai
Embedded Training in Chennai
Spark Training in Chennai
Unix Training in Chennai
Linux Training in Chennai
Primavera Training in Chennai
Tableau Training in Chennai
Oracle Training in Chennai
Embedded System Course Chennai
Embedded Training in Chennai

dhivya said...

I feel satisfied to read your blog, you have been delivering a useful & unique information to our vision.keep blogging.
Regards,
Certified Ethical Hacking Course in Chennai
Ethical Hacking Training in Chennai
Tally Course in Chennai
Salesforce Training in Chennai
Angularjs Training in Chennai
ethical hacking course in chennai
hacking course in chennai

MyTraining said...

Nice Information , Thank you so much for taking a time to post this blog

AWS Training in Bangalore

Best AWS Training Institute in Bangalore

Pankaj Ogeninfo said...

Amazing Blog, Thank you so much for sharing such an amazing blog. Visit Ogeninfo for the creative and Dynamic Website Designing Services in Delhi.
Website Designing Company in Delhi

IT Tutorials said...

Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement | UiPath training in Chennai | UiPath certification in Chennai with cost

Soumitasai said...

Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.

Check out : hadoop training in chennai cost
hadoop certification training in chennai
big data hadoop course in chennai with placement
big data certification in chennai

Y and H Cargo India said...

Amazing blog, Visit Y&H Cargo India for Shipping and Freight Forwarding Services.
Shipping Company in India

divyapriya said...

Excellent blog for the people who needs information about this technology.
French Classes in Chennai
french classes
German Language Course in Chennai
IELTS Coaching centre in Chennai
Japanese Language Classes in Chennai
spanish classes in chennai
French Classes in Tambaram
French Classes in OMR

Mutual Fundwala said...

Thanks for this informative blog sharing with us, Visit Mutual Fund Wala to get Investment Schemes and Mutual Fund Advisors.
Mutual Fund Agent

IELTS Coaching in Dwarka said...

I feel happy about and learning more about this topic. keep sharing your information regularly for my future reference. This content creates new hope and inspiration within me. Thanks for sharing an article like this. the information which you have provided is better than another blog.
Best IELTS Coaching in Dwarka sector 12

Ram Niwas said...

Amazing write-up. You have explained everything very well. Thanks for sharing.

Web Designing Company in Delhi
Website Design Company in Delhi
Website Designing Company in Delhi
Website Development Company in Delhi


Vicky Ram said...

Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.

Article submission sites
Education

Cartoon HD said...

CartoonHD

Soumitasai said...

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. 

Check out : big data hadoop training in chennai
big data training in chennai chennai tamilnadu
spark training in chennai

IT Tutorials said...

Really useful information. Thank you so much for sharing.It will help everyone.Keep Post. RPA training in chennai | RPA training in Chennai with placement | UiPath training in Chennai | UiPath certification in Chennai with cost

Soumitasai said...

Nice Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

hadoop training in Chennai
big data training in chennai
big data hadoop training in chennai
big data training and placement in chennai

Laxman S said...

I’m really impressed with your article, such great & usefull knowledge you mentioned here. Thank you for sharing such a good and useful information here in the blog
Kindly visit us @
SATHYA TECHNOSOFT (I) PVT LTD
SMO Services India | Social Media Marketing Company India
Social Media Promotion Packages in India | Social Media Marketing Pricing in India
PPC Packages India | Google Adwords Pricing India
Best PPC Company in India | Google Adwords Services India | Google Adwords PPC Services India
SEO Company in India | SEO Company in Tuticorin | SEO Services in India
Bulk SMS Service India | Bulk SMS India

«Oldest ‹Older   201 – 251 of 251   Newer› Newest»