News for hackers. Stuff that matters.
Re:How to Parse Ruby by jshen on Thursday February 07, 2013 @10:07PM (#5186076)
Why didn't you add the sort?
Re:How to Parse Ruby by jchan on Friday February 08, 2013 @12:05AM (#5186388)
Use a Comparator. http://docs.oracle.com/javase/6/docs/api/java/util/Comparato...

Since it seems like you're talking about visual activity now instead of visual clarity, I agree that Java will be more "hard to read" under your definition. But aside from the two lines for the class declaration & method declaration and the other two for the ending brackets, there really isn't much bloat.

All that you have to implement for a simple numerical sort is some logic if a > b return 1 else if a == b return 0 else return -1.

Re:How to Parse Ruby by jshen on Friday February 08, 2013 @12:39AM (#5186487)
I'm absolutely talking about visual clarity. In the ruby code it is significantly more visually clear what is going on because the java code has a lot of incidental noise. If you would show a java version that would be clear to everyone, which is probably why you didn't add the sort. The code side-by-side will speak for itself.
Re:How to Parse Ruby by noacct on Friday February 08, 2013 @01:22AM (#5186575)
Wow guys really.

  Iterable<String> s = Splitter.on(" ").split("Hello World");
  Multiset<String> counts = HashMultiSet.create(s);
  Multiset<String> sorted = Multisets.copyHightestCountFirst(counts);
Or to sort by counts directly

  TreeHashSet.create(Splitter.on(" ").split("Hello World"))

Granted this uses guava, but there is nothing really more readable about your ruby code than this guy's java code. To say he 'lacks courage' ... jesus I'm still laughing. "Why didn't you add the sort!" You're too much man.
Re:How to Parse Ruby by jshen on Friday February 08, 2013 @02:03AM (#5186679)
Your code doesn't do the same thing as mine. You need to start with an array of sentences.

Show the java code that does the same thing and it will be clear that the ruby is more readable.

Re:How to Parse Ruby by odenze on Friday February 08, 2013 @06:49AM (#5187357)
It will not be clear: You can replace the first line with the following two

  String[] sents = {"the quick", "the slow", "the blue"};
  Iterable<String> s = Splitter.on(" ").split(Joiner.on(" ").join(sents));
Re:How to Parse Ruby by jshen on Friday February 08, 2013 @10:14AM (#5188195)
Guava is nice, it makes java almost bearable.