Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: The greeting code in Java Date: Sun, 19 Jun 2011 16:25:54 -0400 Organization: A noiseless patient Spider Lines: 42 Message-ID: References: <3d6aab49-9a4a-4614-af12-bb1c95bebbe7@w4g2000yqm.googlegroups.com> <4dfdf77e$0$4132$426a74cc@news.free.fr> <06cf6f85-5473-47da-b599-de2e7f81976d@d1g2000yqm.googlegroups.com> <125bbd94-dca2-4692-8c18-3c80d8717048@c41g2000yqm.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 19 Jun 2011 20:25:55 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="bAymlyY9SkaJNa8Tz2rerw"; logging-data="5893"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hbh1EO/AEJvghOH82Iw0NdgxGgcn4KKQ=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16pre) Gecko/20110305 Lightning/1.0b3pre Thunderbird/3.1.10pre In-Reply-To: <125bbd94-dca2-4692-8c18-3c80d8717048@c41g2000yqm.googlegroups.com> Cancel-Lock: sha1:WC5qcme/SRwYJd+CJncN177JDoM= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5406 On 06/19/2011 10:17 AM, Saeed Amrollahi wrote: > Well, in the case of C++ code, I have to > explain cin, cout, string and two overloaded operators:>> and<< > in the case of java one: I have to > explain, the stream class hierarchy, InputStreamReader, > BufferedReader, > in, string, new operator, final, the meaning of buffered, > readLine, ... If that is what you're explaining in Java, you also need to explain for C++ stack constructed-objects, references, #include (trust me, beginners can get very confused about #include, as simple as it looks), and probably the entire iostream interfaces if you're talking about Java's stream class hierarchy. > I believe the C++ code is simpler for a beginner. If it's simpler, it's only superficially so. C++'s interfaces heavily optimize for the most common case and render the development of the more critical components inordinately more difficult. For example, a fair amount of my work has to worry about the use of international characters and multiple charsets (it's not unimaginable that I have to use one stream to write in two simultaneous charsets (i.e., the control protocol is in UTF-8 but I send 8-bit MIME payloads of ISO 8859-1)). In Java, I can keep both the raw Stream and a controlling Reader/Writer around and use the character-based one for control information and the octet-based one for data payloads. And, naturally, any talk of C++ being simpler becomes hard to stomach once you introduce templates, i.e., any use of the STL. std::string isn't actually a class, it's actually std::basic_string, std::allocator >, as every error message involving std::set will helpfully inform you. I mean std::set, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > > >. Have fun debugging your template errors! -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth