Link Details

Link 522897 thumbnail
User 478055 avatar

By mitchp
via allthingsprogress.com
Published: Nov 28 2010 / 16:57

The Ruby language is beautiful. And I think it deserves to break free from the Web. Unfortunately, I think the future of Ruby is firmly stuck in Web development, so I’m going to invest in a new language. This is a look at the fantastic language I came to from Java. It’s also a peek at a potential substitute.
  • 36
  • 3
  • 6220
  • 6

Comments

Add your comment
User 298727 avatar

ludni replied ago:

1 votes Vote down Vote up Reply

Wow, an article about ruby and python without any bashing. Ok, a diehard Java hacker would take the paragraphs describing the 'Java Verbosity' as an attack, but these guys will never take off their blinders ;-)
Sadly it's true, science, statistics and natural language processing seem not to be a core interest of the vibrant Ruby communitiy - especially in comparison with the wealth of libraries Python has to offer in these fields.

User 161244 avatar

hohonuuli replied ago:

2 votes Vote down Vote up Reply

I agree, there was a lot of tedious Java bashing in the article. Yes, for the umpteen millionth time, Java has more bioler plate than most languages. But come on, how many articles do I have to read that complains about reading a text file with Java IO. Get over it, take 5 minutes and write a static IO method once that emulates Ruby's File.read in Java and reuse it, voila you'll never have to write the IO boiler-plate again.

User 208597 avatar

sskjames replied ago:

5 votes Vote down Vote up Reply

DRY.

import org.apache.commons.io.FileUtils
.....

String fileContent = FileUtils.readFileToString(file1);

User 187417 avatar

sproketboy replied ago:

1 votes Vote down Vote up Reply

Unless you don't want to have dependencies on Apache commons. There are a lot of reasons to not want the extra dependencies.

User 237765 avatar

Mario Arias replied ago:

0 votes Vote down Vote up Reply

Lot of reasons?

User 211643 avatar

zynasis replied ago:

1 votes Vote down Vote up Reply

only reason i can think of is commons-logging. curse that library and especially it being dragged in by the much more useful: commons-beanutils

User 208597 avatar

sskjames replied ago:

0 votes Vote down Vote up Reply

Yes, commons-logging should be avoided. Fortunately, we have "slf4j".

User 208597 avatar

sskjames replied ago:

2 votes Vote down Vote up Reply

I humbly believe having these extra dependencies is worth the time and effort than maintaining these ourselves. Nowadays I don't think I will sit and write all these stuff myself in any Java project. Instead, I would leverage stuff like commons-*, joda, guava etc.

Groovy users are fortunate to have these one liners and much more (especially xml stuff) built in without any dependencies.

And that's why I love Python too!

User 161244 avatar

hohonuuli replied ago:

0 votes Vote down Vote up Reply

Yes, that's my point. There's off the shelf stuff that handles the IO boiler plate for you; or you can write it, it's very simple stuff, not sure you need to include apache jars for a simple IO method.

p.s. I think you meant NIH not DRY.

User 208597 avatar

sskjames replied ago:

0 votes Vote down Vote up Reply

If you are going to use io in some simple use cases, may be you don't need all these. But these libraries bring in lot of value added stuff. Especially, I can't imagine working on a Java project without commons-lang.

I think the file input streams were not handled correctly in the article we are talking about. If you include stuff to handle that as well, there's even more
boiler-plate. Something like this...

try{
blah blah..
}catch(IOException ex){
blah blah
}finally{
if(reader != null){
try{
reader.close();
}catch(IOException ex){
logger.error("Some thing weird happened while closing this stupid stream", ex);
}
}

Whilst even if you want to read the file line by line or byte by byte in some use cases, commons-io has some handy methods to close the stream. It would go like this:

try{
........
}catch(Exception ex){
......
}finally{
IOUtils.closeQuietly(reader); //streams work as well
}
}

PS: I think JDK 7 has some improvements in this area.

User 755021 avatar

devent replied ago:

0 votes Vote down Vote up Reply

He should try Groovy. Plus, I can use all Java libraries from Groovy.

def evenItems = [1, 2, 3, 4, 5, 6].findAll{it % 2 == 0}

println evenItems

User 208597 avatar

sskjames replied ago:

0 votes Vote down Vote up Reply

Great..!

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Play Framework
Written by: Ryan Knight
Featured Refcardz: Top Refcardz:
  1. Akka
  2. Design Patterns
  3. OO JS
  4. Cont. Delivery
  5. HTML5 Mobile
  1. Akka
  2. JUnit/EasyMock
  3. Java Performance
  4. REST
  5. Java