[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: DOM's javascript roots (was Re: Have JDOM/ XOM /


fileoutputstream javascript
Robin Berjon wrote:

> But now I'm writing in my platform's default encoding. That might have 
> been tolerable in the 80s when the folks who came up with this 
> ridiculous API were sharpening their text-munging fu on ASCII, but those 
> benighted days are thankfully over, in no little part thanks to XML's 
> arrival.
> 

You're right. In reality I'd write something like this:

Writer out = new OutputStreamWriter(new FileOutputStream("file.txt"), 
"UTF-8");

It's still one line, though a longish one. Perhaps I'd even break it 
into two lines. But I'd have to do similar things in Perl or Python if I 
wanted to handle character sets sensibly there too.

The real difference is that Java assumes you want to do the right thing 
with full error handling, appropriate character set support, and more by 
default. It's a language designed for professional applications that 
cross the t's and dot the i's.

Perl et al. assume you want to write quick and dirty throwaway hacks. 
It's a difference in focus. Of course, you can write professional apps 
in Perl or quick and dirty hacks in Java, but you work against the 
language when you do that. Pick the language that's appropriate to your 
task.

>   open my $fileHandle, ">utf-8", "filename.txt" or die "Error opening 
> file: $!";

Perfect example. The entire app shuts down because you couldn't open one 
file. I can make a Java program shut down in one line too, but it's not 
the natural thing to do in an end user facing application or a reliable 
library.

-- 
Elliotte Rusty Harold  elharo@m...
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.