Shannon Fang <xrfang / hotmail.com> wrote in
news:20021212000456.8232.XRFANG / hotmail.com: 

> Hi Leif,
> 
> Thanks for the code. While reading your code, I remembered one thing
> I'm not happy with Java. Although it is much better than C++, I think
> Java is still quite low level language, it is artificially made
> complex by a huge tree of classes. When I learned Java, and checked
> the document I don't know which class will suit my need, for example,
> the PrintWriter class, I'm sure there are similar parent/child/sibling
> of it that does similar job...

You are quite right. However, the class library authors have ( sensibly 
) avoided duplicating functionality, so usually what you need is located
just one place.  The trick is to find it... ;)  I must admit I had to
browse the core api javadocs to get this sample right. 

> Ruby's class hierachy is simpler and it is easier to find suitable
> class/method for your purpose. What do you feel?

I haven't done much ruby coding (yet) so I'm not really qualified to 
answer that question.  One big difference between java and ruby is the 
sheer number of APIs in java, especially if you take into account the 
good stuff that comes from the jakarta project.  Usually one becomes 
quite proficient in the stuff one uses every day, such as servlets or 
JDBC, and blissfully ignorant of all the other APIs ( Swing, Crypto, 
Imaging, JavaCard, Jini or whatever). 

I view the number of API's in Java to be one of its strengths. If one 
uses a proper IDE, such as IntelliJ IDEA or Eclipse, then navigating the 
source code and third party components is usually not a problem.  Having 
access to lots of third party ( often open source )  components gives me 
as a developer a big advantage.  Java is also a proven technology in 
environments which needs high stability, security, processing volume, 
and transaction processing etc.  Although ruby have some nice features, 
you dont have to be a pointy haired boss to prefer java over ruby... 

The only real way to convince your boss that ruby is better is to prove 
it. Implement a non-trivial part of your system in ruby and show him
(/her?) that it is functioning well in a production environment ( 
simulated or real ), and that it is easy to extend and maintain.  
Seeing is believing.

-lj

btw: see small bugfix below 

> 
>> 
>> # File:  ProcessFile.java 
>> 
>> import java.io.* ;
>> import java.util.regex.* ;
>> 
>> class ProcessFile {
>>   public static void main(String[] argv){
>> 
>>     try {
>>       File f_in  = new File("input.txt");
>>       File f_out  = new File("output.txt");
>>       String line ;
>>       Pattern p =
>>       Pattern.compile("(.{4}(.{3})(.{6})(.{3}).{17}(.{6}))") ; 
>> 
>>       LineNumberReader in = new LineNumberReader(new
>>       FileReader(f_in)); PrintWriter out = new PrintWriter(new
>>       FileWriter(f_out)); 
>> 
>>       while ( null != ( line=in.readLine())) {
>>         Matcher m = p.matcher(line);
>>         if ( true == m.find()) {
>>           System.out.println(m.group(1) + "-" + m.group(2) + "-" + 
>> m.group(3)+ m.group(4));

// Should of course write to file, not stdout:

           out.println(m.group(1) + "-" + m.group(2) + "-" + 
 m.group(3)+ m.group(4));


>>         }
>>       }
>>     } catch ( Exception e ) {
>>       e.printStackTrace();
>>     }