XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] DOM's javascript roots (was Re: [xml-dev] Have JDOM / XOM / etc. failed?)

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@metalab.unc.edu
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


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2006 XML.org. This site is hosted by OASIS