Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mac OS X Java Performance



Scott Ellsworth <email@hidden> wrote:

>Just like it currently says that
>println on a socket is not the right way to write code. Sure, it works
>on Windows without it, but it is not actually correct. Things fail.

Interesting example.

The Java spec doesn't say anything about not println()'ing to a socket.
All it says is that println() prints a platform-specific end-of-line.

To discover why println() to a socket sometimes fails, and so is always a
bad idea, one must instead read and understand another spec: the HTTP
RFC's. Or the FTP RFC's. Or whatever RFC is appropriate for whatever
protocol you're trying to implement where you're using println().

It's the RFC that says what a valid end-of-line is. For HTTP and myriad
other protocols, it's CR-LF. Since that also happens to be the Windows
end-of-line, one could argue that Windows is the only platform that
correctly implements the protocol using println().

So what we have is a conjunction of accidents that turns out to work, and
actually meets all the relevant specs. Irony, thy parents are Sun and
Microsoft.

It is often said "If it ain't broke, don't fix it." What is frequently
forgotten is "Just cuz it works don't mean it ain't broke."

Sometimes there's no substitute for knowing what you're doing.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.