为什么有人说Ruby很慢? [英] Why do people say that Ruby is slow?

查看:62
本文介绍了为什么有人说Ruby很慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢 Ruby on Rails,我将它用于我所有的 Web 开发项目.几年前,有很多关于 Rails 是一个内存猪以及它如何不能很好地扩展的讨论,但这些建议被 Gregg Pollack 此处.

I like Ruby on Rails and I use it for all my web development projects. A few years ago there was a lot of talk about Rails being a memory hog and about how it didn't scale very well but these suggestions were put to bed by Gregg Pollack here.

不过,最近我听到有人说 Ruby 本身很慢.

Lately though, I've been hearing people saying that Ruby itself is slow.

  • 为什么 Ruby 被认为很慢?

我不觉得 Ruby 很慢,但话说回来,我只是用它来制作简单的 CRUD 应用程序和公司博客.在我发现 Ruby 变慢之前,我需要做什么样的项目?还是这种缓慢只是影响所有编程语言的原因?

I do not find Ruby to be slow but then again, I'm just using it to make simple CRUD apps and company blogs. What sort of projects would I need to be doing before I find Ruby becoming slow? Or is this slowness just something that affects all programming languages?

  • 作为 Ruby 程序员,如果您想处理这种缓慢"问题,您有哪些选择?

  • What are your options as a Ruby programmer if you want to deal with this "slowness"?

哪个版本的 Ruby 最适合像 Stack Overflow 这样的应用程序,在这种情况下速度至关重要且流量很大?

Which version of Ruby would best suit an application like Stack Overflow where speed is critical and traffic is intense?

这些问题是主观的,我意识到架构设置(EC2 与独立服务器等)有很大的不同,但我想听听人们对 Ruby 运行缓慢的看法.

The questions are subjective, and I realise that architectural setup (EC2 vs standalone servers etc) makes a big difference but I'd like to hear what people think about Ruby being slow.

最后,我找不到太多关于 Ruby 2.0 的消息——我认为我们离那还有几年的时间?

Finally, I can't find much news on Ruby 2.0 - I take it we're a good few years away from that then?

推荐答案

为什么认为 Ruby 很慢?

Why is Ruby considered slow?

因为如果您在 Ruby 和其他语言之间运行典型的基准测试,Ruby 就会失败.

Because if you run typical benchmarks between Ruby and other languages, Ruby loses.

我不觉得 Ruby 很慢,但后来再次,我只是用它来制作简单的 CRUD 应用程序和公司博客.我需要什么样的项目在我发现 Ruby 成为慢的?或者这种缓慢只是影响所有编程的东西语言?

I do not find Ruby to be slow but then again, I'm just using it to make simple CRUD apps and company blogs. What sort of projects would I need to be doing before I find Ruby becoming slow? Or is this slowness just something that affects all programming languages?

Ruby 可能不适合您编写实时数字信号处理应用程序或任何类型的实时控制系统.Ruby(使用今天的虚拟机)可能会在资源受限的计算机(例如智能手机)上窒息.

Ruby probably wouldn't serve you well in writing a real-time digital signal processing application, or any kind of real-time control system. Ruby (with today's VMs) would probably choke on a resource-constrained computer such as smartphones.

请记住,您的 Web 应用程序上的许多处理实际上是由用 C 开发的软件完成的.例如Apache、Thin、Nginx、SQLite、MySQL、PostgreSQL、许多解析库、RMagick、TCP/IP 等都是 Ruby 使用的 C 程序.Ruby 提供了粘合剂和业务逻辑.

Remember that a lot of the processing on your web applications is actually done by software developed in C. e.g. Apache, Thin, Nginx, SQLite, MySQL, PostgreSQL, many parsing libraries, RMagick, TCP/IP, etc are C programs used by Ruby. Ruby provides the glue and the business logic.

作为 Ruby,您有哪些选择程序员如果你想处理这种缓慢"?

What are your options as a Ruby programmer if you want to deal with this "slowness"?

切换到更快的语言.但这需要付出代价.这是一个可能值得的成本.但是对于大多数 Web 应用程序来说,语言选择并不是一个相关的因素,因为没有足够的流量来证明使用速度更快、开发成本更高的语言是合理的.

Switch to a faster language. But that carries a cost. It is a cost that may be worth it. But for most web applications, language choice is not a relevant factor because there is just not enough traffic justify using a faster language that costs much more to develop for.

哪个版本的 Ruby 最适合像 Stack Overflow 这样的应用程序速度是关键,交通是激烈吗?

Which version of Ruby would best suit an application like Stack Overflow where speed is critical and traffic is intense?

其他人已经回答了这个问题 - JRuby、IronRuby、REE 将使您的应用程序的 Ruby 部分在能够负担 VM 的平台上运行得更快.而且由于通常不是 Ruby 导致缓慢,而是您的计算机系统架构和应用程序架构,您可以执行诸如数据库复制、多个应用程序服务器、反向代理负载平衡、HTTP 缓存、memcache、Ajax、客户端缓存等操作. 这些东西都不是Ruby.

Other folks have answered this - JRuby, IronRuby, REE will make the Ruby part of your application run faster on platforms that can afford the VMs. And since it is often not Ruby that causes slowness, but your computer system architecture and application architecture, you can do stuff like database replication, multiple application servers, loadbalancing with reverse proxies, HTTP caching, memcache, Ajax, client-side caching, etc. None of this stuff is Ruby.

最后,我找不到太多关于Ruby 2.0 - 我认为我们是少数几年之后呢?

Finally, I can't find much news on Ruby 2.0 - I take it we're a good few years away from that then?

大多数人都在等待 Ruby 1.9.1.我自己正在等待 Rails 3.1 on Ruby 1.9.1 on JRuby.

Most folks are waiting for Ruby 1.9.1. I myself am waiting for Rails 3.1 on Ruby 1.9.1 on JRuby.

最后,请记住,许多开发人员选择 Ruby 是因为与其他语言相比,它使编程成为一种更愉快的体验,并且因为 Ruby with Rails 使熟练的 Web 开发人员能够非常快速地开发应用程序.

Finally, please remember that a lot of developers choose Ruby because it makes programming a more joyful experience compared to other languages, and because Ruby with Rails enables skilled web developers to develop applications very quickly.

这篇关于为什么有人说Ruby很慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆