Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 21 Aug 2013 04:09:34 -0500 Date: Wed, 21 Aug 2013 10:09:32 +0100 From: lipska the kat <"nospam at neversurrender dot co dot uk"> Organization: Trollbusters 3 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Autoboxing and Performance ? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 41 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-SpKJYB+uLRKFt9LwicFjekz7/uTKQOPRqa5LF25iX/CI1pdbpcIxK0xP2vUbyNPtcfFDSghu99Efihd!kWCyvlZDa2AIfXr0lVeZmsoyrwAbTRmKvpuOF+djRnbBegFR3OnCbGNYkNQGG22ksfjDlnaJxZlR X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2662 Xref: csiph.com comp.lang.java.programmer:25087 On 20/08/13 11:15, Peter Olcott wrote: > From Java A Beginner's Guide, Fifth Edition by Herbert Schildt, page 425: > > class AutoBox3 { > public static void main(String args[]) { > Integer iOb; > iOb = 99; > > // The following automatically unboxes iOb, > // performs the increment, and then reboxes > // the result back into iOb > ++iOb; > > It seems to me that all this unboxing and reboxing is a complete waste > of CPU time. It would make much more sense to provide an > Integer.Increment() member function that directly operates on the > contained data. > > Why does Java waste so much CPU resources with its unboxing and reboxing > in cases such as this, and not simply provide member functions that > directly operate on the contained data? I think a better question might be "why have primitives in the first place' When everything else is an Object does it really encourage clarity of thought and cohesion of design to pollute the Object Oriented paradigm with primitives. If there were no primitives then autoboxing would be a non-issue ... and before anyone gets excited and starts talking about components that only deal with primitives, if they didn't exist in the first place etc etc lipska -- Lipska the KatŠ: Troll hunter, sandbox destroyer and farscape dreamer of Aeryn Sun GNU/Linux user #560883 - http://www.linuxcounter.net