From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA15905; Thu, 29 Apr 2004 14:23:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA16200 for ; Thu, 29 Apr 2004 14:23:07 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i3TCN6jq009833 for ; Thu, 29 Apr 2004 14:23:06 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BJAZF-0002Mo-00 for ; Thu, 29 Apr 2004 13:23:05 +0100 Date: Thu, 29 Apr 2004 13:23:05 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Re: Common IO structure Message-ID: <20040429122305.GA6688@redhat.com> References: <016401c42bc4$b6438840$19b0e152@warp> <20040428.004358.45522587.yoriyuki@mbg.ocn.ne.jp> <016501c42c73$24e64b30$ef01a8c0@warp> <20040428.015800.126758722.yoriyuki@mbg.ocn.ne.jp> <408EEE3E.7050008@socialtools.net> <20040428034415.GB19564@complete.org> <40902265.9040702@socialtools.net> <20040428214442.GE10198@excelhustler.com> <4090E597.1080603@socialtools.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4090E597.1080603@socialtools.net> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 glance:01 api:01 governing:99 api:01 surgical:99 ltd:98 equipment:98 ocaml:01 interfaces:01 trivial:01 unix:02 encoded:02 encoded:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Apr 29, 2004 at 12:23:03PM +0100, Benjamin Geer wrote: > John Goerzen wrote: > >I'm looking at java.io right now. I count no less than 10 interfaces > >and 50 classes. Let's say that I want to open up a file for read/write > >access and be able to seek around in it. Looking at the class list, I > >don't know if I want BufferedInputStream, BufferedOutputStream, > >BufferedReader, BufferedWriter, CharArrayReader, CharArrayWriter, > >DataInputStream, DataOutputStream, File, FileDescriptor, > >FileInputStream, FileOutputStream, FileReader, FileWriter, InputStream, > >InputStreamReader, OutputStream, OutputStreamWriter, RandomAccessFile, > >Reader, or Writer. Really, I literally *do not know how to open a > >simple file*. I would not call that intuitive. > > You actually have to *read* the documentation, not just glance at the > class names. :) That's to be expected with a powerful API. Once you > understand the key concepts governing the design of the API, it makes > sense, it and becomes intuitive to select the classes you need. I tried > to point out these concepts in the message you replied to. You shouldn't need to read a boatload of documentation just to read a file, even one encoded in UTF-8. Especially one encoded in UTF-8, since in the future most files on Unix will be encoded that way. Think of an API as like a user interface. It's a UI for programmers to use. Good user interface design does *not* require you to read manuals to find out how to use it (excepting very special cases like airplanes, surgical equipment, etc.). If you designed a website or a computer program that required you to read a manual before you could use it, no one would ever use it. Simple fact. Don't make an API which needs you to read manuals to do a trivial operation like slurping in a UTF-8 file. Here's how you read in and parse a CSV file using my OCaml CSV library: let csv = Csv.load csvfile in ('csv' is a list of list of strings). I deliberately chose to make the common case this simple because it's the common case and people shouldn't have to remember much to use it. > To read a file containing UTF-8 text, one line at a time: > > BufferedReader in = > new BufferedReader > (new InputStreamReader > (new FileInputStream(filename), "UTF8")); This example really reflects all that's wrong in Java. Thankfully I don't have to do Java programming any more - I got out of that job as soon as I could. Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment http://www.YouUnlimited.co.uk/ - management courses ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners