>From: Greg Nudelman <[EMAIL PROTECTED]> >I just KNEW I was going to get somebody started! >}:> *evil grin*
Who IS that trip-trapping under my bridge? > >Well, to be sure, this doesn't give you a filehandle. It gives you an >output > >stream that goes to a filesystem, buffers it, and then provides utility > >functions. > >This is exactly what I am talking about. Writing to file using Java IO is >like using a supercomputer to add 1 + 1. Java is a full-featured language >for the enterprise. However, this means that every little thing now >requires a "sledgehammer" approach to solve it. Hm, not really - or maybe so, depending on how you look at IO. If you've ever seen C++'s IOStream architecture, you'd find the same thing hidden under the covers, possibly even moreso since C++ uses multiple inheritance for it in the implementations I've seen. (In fact, doing cin and cout without MI would be a pain.) I guess THAT aspect comes down to preference: do you want things that can go wrong hidden from you? That way, when lightning strikes and something DOES go wrong, you're left scratching your head saying, "But I thought this wasn't buffered..." -- I prefer not, myself. The streaming architecture isn't hard conceptually, and it's what you actually DO want, except you apparently want the complexity hidden. I understand, really, but respectfully disagree. *CLAP* *STOMP* For the record, in Java, adding two ints is easy: int a=1+1; >Although some people (possibly those bitten by radioactive spiders?) will >froth at the mouth from this thought, I want to state once again: I am NOT >trying to solve the world's hunger problems or create peace in the Middle >East. I am just trying to write a String to a file. That is all. 99% of >all the file-writing code just wants to do that and nothing else. Yet this >"very simple" functionality is not at all that simple in Java. In fact it >is awkward for almost everyone who does not deal with this every day. Again, "write a string to a file" is a VERY complex concept! Java does hide a lot from you, by giving you "string," which isn't simple, and "file," which is, like, WAYYY not simple, dude, and, whoa, "write," which has, like, you know, a ton of things that can, like, go into it, you know? So you say something with, like, six words, dude, and actually explaining it to, like, the common man is, like, so simple, and, dude, peeking under the covers is, like, you know, expecting the Model T's engine and getting a Formula 1. (Sorry, the surfer lingo isn't my natural dialect, and it's gotten really tiresome.) You say it's awkward, that's fine, I suppose - except examples and tutorials exist to remind you of the implementation of all that complexity. Plus, humankind's memory structure tends to remember egregious exceptions, so once you hit this, you tend to remember that IO had some crazy stuff to it (if you like: I don't find it crazy, and here's why) and Java does A LOT of things this way. That means IO is less exceptional than it could be, which explains why people don't remember it as often as they should: they use the same paradigms elsewhere in Java, and conveniently forget that IO works the same way. They're used to Perl, or C++, or C, each of which works hard (really hard, in Perl's case) to hide this common complexity from you. >Sure, I can write an OO language that will require all sorts of conversions >and writers to declare a variable. Because, hey, I twill not just declare >a >variable!! (to paraphrase your statement above) "It give you an pointer to >some memory address, allocates memory, and then provides utility >functions." Except a pointer IS a variable, which kinda demolishes the entire analogy. Good try, though. >So a simple statement used 99.99% of the time: > int i = 0; >to Joseph's indescribable delight, can now become: > int i = new IntegerWriter(new MemoryAllocator(new Integer(0))); Alas, I can describe my delight at this. It has the property of nonexistence. Besides, i is a primitive; no memory is allocated for it, and you're STILL using "0" in there - try Integer.ZERO and ask me again. :) Your second example isn't equivalent to your first one, so it falls apart. >And you do not need to be a super powered freak with adamantine retractable >claws and a bad temper to see what a waste of time this idle exercise would >be. Perl for example, recognizes that, so the code to write to file is >very >simple. Again, I am NOT talking about 1% of the time when you need to >tweak >something. I AM talking about a simple function you do 99% of the time. >You really do not need "Six or a half dozen" ways to do this simple thing. See above. I've already thrown the lightning, so the rest of this post can be ignored, I think... >To think that Java is perfect for everything and fits every need is >ridiculous. Our tools must keep evolving in order to remain useful -- Java >IO should be no exception. So what should IO do, exactly, that it does not do? Is simplicity all you're looking for? >Greg > >-----Original Message----- >From: Joseph Ottinger [mailto:[EMAIL PROTECTED]] >Sent: Wednesday, August 21, 2002 11:13 AM >To: JDJList >Subject: [jdjlist] RE: Java IO Question > > > >From: Greg Nudelman <[EMAIL PROTECTED]> > > >This is one of a few things I find of extreme annoyance in Java. I do >not > >think any other modern programming language makes you remember: > > > >new PrintWriter(new BufferedWriter(new FileWriter("foo.out"))); > > > >just to get a file handle!! (This is one area where C syntax may even be > >easier to remember then Java... Scary!) > >Well, to be sure, this doesn't give you a filehandle. It gives you an >output > >stream that goes to a filesystem, buffers it, and then provides utility >functions. With great power comes great responsibility, and all that rot. >Maybe people would remember that if they were all bitten by radioacive >spiders and mutated into genetic freaks who would walk on walls. > > >I can never remember the syntax, as I have to write to a file maybe 5-6 > >times a year. And just imagine being tested on an interview by some moron > >who just looked it up himself that very morning. ("Greg, how do you > >implement reading the binary file vs. ASCII file in Java?") So, Mr. > >Bright, > >how often do YOU write that code (without docs and Google)? > >It's orthogonal: streams are binary, writers aren't. Verrrrry difficult to >remember. > > >Hmmm... Maybe I should just write my own utility that I can at least > >remember the syntax for. > > > >I'm thinking something like: > > > >BufferedFileWriter fw = new BufferedFileWriter("foo.out"); > >fw.write(stringBuffer.toString()); > > > > > >For PrintWriters: > > > >PrintingBufferedFileWriter pfw = new >PrintingBufferedFileWriter("foo.out"); > >pfw.print(stringBuffer.toString()); > > > >To be fair, I guess I have the advantage - I can go back and refactor my > >stuff, and I do not need to be v1.0 backward compatible... > >And even fairer, you end up writing classes to do SPECIFICALLY what you >want, and if you actually want to step outside your little lines, you end >up > >right back where you were, relying on Java's piped input architecture. >*shrug* Six or a half dozen, it doesn't matter. > > >----------------------------------------------- >Joseph B. Ottinger [EMAIL PROTECTED] >http://enigmastation.com IT Consultant > >_________________________________________________________________ >MSN Photos is the easiest way to share and print your photos: >http://photos.msn.com/support/worldwide.aspx > > >To change your membership options, refer to: >http://www.sys-con.com/java/list.cfm > > >To change your membership options, refer to: >http://www.sys-con.com/java/list.cfm ----------------------------------------------- Joseph B. Ottinger [EMAIL PROTECTED] http://enigmastation.com IT Consultant _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com To change your membership options, refer to: http://www.sys-con.com/java/list.cfm
