From: Richard Cole Date: 2005-04-10T12:37:32+09:00 Subject: Re: Welcome to our (ruby-talk ML) You are added automatically >> 7.How is Ruby's performance with huge DB resultsets.. > > > I don't think there is a bottleneck there, but you probably ought to > re ask this question on the Rails mailing list as well. > > Rails is not the only web development framework, of course, so you > might also want to look into the performance of the other choices > available. I agree with this answer, but would add: In my experience Ruby is pretty slow if you have to iterate through lots of data[1], correspondingly you wouldn't want to implement a database in Ruby due to performance considerations. Therefore when you use ruby with a database backend, you have to make the backend do all iteration, and you use Ruby to coorindate actions of the database[2]. In this mode languages like Ruby are fine. Ruby is a very nice language, but it has its own idioms, so it takes a while to learn them (I'm still learning them). One that I like very much is: File.open("input.txt", "r") do |file| @context = load_context_from_file(file) end What do I like about that? I like that you don't leak the file descriptor if an exception is thrown by the load_from_file function. This is a really neat way to avoid leaking system resources and it is concise and straightforward. In C++ I used to do stuff like: ifstream input("input.txt"); context = load_context_from_file(input); This won't leak a system resource either because _input_ has static scope and so gets free'd, even if an exception is thrown. I missed this "resouce bound to a static scope ideom" in other languages, e.g. java and ocaml, until I found it in the Ruby standard library. Finding it in the standard library gave me a lot of confidence in Ruby because I figured, hey these guys really know what they're doing. In modern systems there are all sorts of system resources that need to be accounted for and so this idiom often gets resued. I haven't looked into how multithreading works in ruby yet, but this idiom would also work quite nicely for mutexes and condition variables I imagine. Lastly let me say I've looked around at quite a few languages and invested some time in learning to use many of them and my favorite is Ruby. Sometimes I have to use Ocaml for speed, and Ocaml has its own charms, but I always wish I was programming in Ruby. One final warning in regards to Ruby. Since it is dynamically typed, you absolutely have to invest in writing and maintaining software design and interface documentation. But maybe that is a good thing, and since the language is so concise maybe you have time to do it. Well that was my two bits worth. regards, Richard. [1] I had some programs that generated large datastructures all in ruby without pushing the computation down into either a database backend or a custom C backend, and it was quite slow compared to a similar program written in Ocaml. [2] This is kind of what you're supposed to do with databases anyway, but maybe a language like Java, and a big processor, lets you get away with iterating though big results sets to filter them or whatever, when you should be pushing that computation down into the SQL expressions maybe even using stored proceedures.