From: Brian Candler Date: 2009-08-20T17:06:49+09:00 Subject: Re: Confirm my Performance Test Against Java? Ben Christensen wrote: > ## Fast Enough ## > > I often hear that Ruby is "fast enough" or that the performance > difference is not important since IO is generally the real source of > performance issues. > > I understand that in certain cases - though when I see potential > performance degradation as multiples (2x, 3x, etc) as opposed to small > percentages, it makes me question the decision to use Ruby much more > than if we were talking percentages of 10-20% - such as 115ms vs 100ms > on a page response. > > For example, a java environment my team has built provides SOAP/REST > webservices for product catalog search - and responsiveness is a very > significant measurement criteria of the success of the product and > system. Therefore, our average server side response time is something we > watch very closely. And in that case, your response time may be dominated by the time to process the SOAP request and format the SOAP response, so evaluating the performance of those libraries is important. I still don't buy the "fastest to execute must be best" reasoning. In reality, there will be a threshold of acceptability - e.g. 90% of requests must be returned within 150ms - in which case you're free to choose a platform which meets that goal, and/or apply money to the hardware platform as required. However, if your competitor using Ruby gets a product to market in one third of the time, then it doesn't matter if your Java solution performs 50% better - you won't have any customers. > ## Maintainability, Speed of Development and 'Enjoyment' ## > > I hear "speed of development", "maintainability", and "enjoyment of > coding" as the reasons to move to Ruby - and to accept the negatives in > performance, tools, libraries etc. > > I'm still not sold on these reasons - as I truly enjoy working in the > Java ecosystem of tools, projects, libraries etc Then you have no need to ask anything more here. You're sold on Java, you're productive with Java, you enjoy Java, so use Java. But computing is not static. There are probably still people who use Algol and Fortran daily, and they are Turing-complete of course, but newer languages make programming easier. You found the same when you moved from C to Java, so you can see the benefits of keeping abreast of new developments. It's always good to stretch yourself out of your comfort zone to experience how people are using different languages effectively. Perhaps you should try something more radically different for a C/Java programmer, like Erlang. > Nor am I convinced yet that managing a codebase over 5-10 years and 40+ > developers is any easier with Ruby - Java's static typing and now its > generics (the polar oppostite approach of 'duck typing' in Ruby) are > actually very nice for readability, navigation of code, refactoring and > other such things on such large codebases Again, if you find this a benefit, then go with Java. Most people here find the opposite, but then, you're on a ruby users' mailing list so what do you expect :-) That is: most of us hugely value Ruby's speed of development (like writing the same thing in 1/10th of the number of lines of code), and if there's a reduced run-time penalty, that's a minor issue. You won't really get a taste for what we mean until you start writing Ruby (real Ruby, not Java ported line-by-line to Ruby). Perhaps you could start with using jruby to wire up your Java objects. You'll get the raw performance of the underlying Java objects, but using jruby as the integration glue. > As for "brevity" equalling "maintainability" and "less bugs" - I tend to > disagree when the pursuit results in code such as this example given: > > puts "The number of tokens is: %d." % File.open(ARGV[0]){|f| > f.inject(0){|a,l| a+l.split.length } } , > "It took #{(Time.now - start) * 1000} ms" > > I find it intellectually stimulating and admirable at the power of what > is accomplished in such a short statement. > > Understanding it however takes time and thought - and a certain level of > skill. I agree with you, this is an unnecessary use of inject, and people who push this sort of code at newcomers are not doing any favours. I would write this simply as: tokens = 0 File.foreach(ARGV[0]) do |line| tokens += line.split.length end puts "The number of tokens is: #{tokens}" Regards, Brian. -- Posted via http://www.ruby-forum.com/.