<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-6098392112071095875.post2125854442395024415..comments</id><updated>2012-02-09T17:06:23.769-05:00</updated><category term='Hibernate'/><category term='Code'/><category term='Productivity'/><category term='Opinion'/><category term='Spring'/><category term='Performance'/><category term='Agile'/><category term='Java'/><category term='Scrum'/><title type='text'>Comments on Code Instructions: Busting java.lang.String.intern() Myths</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.codeinstructions.com/feeds/2125854442395024415/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html'/><author><name>Domingos Neto</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://2.bp.blogspot.com/_HHFrwTieqY8/STh7yQ1m0bI/AAAAAAAAABs/8BJWpydZgZ4/S220/cruzes.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-1447092825793270003</id><published>2012-01-24T16:12:05.510-05:00</published><updated>2012-01-24T16:12:05.510-05:00</updated><title type='text'>Dont forget Matt Quigley, String.equals short-cuts...</title><content type='html'>Dont forget Matt Quigley, String.equals short-cuts the comparison with a this==that, then tries a length comparison, then finally tries a == comparison on the char array elements.&lt;br /&gt;&lt;br /&gt;William Louth, looking up your cost table for method calls means absolutely nothing when you&amp;#39;re running code in a JVM that auto-inlines methods and compiles to native code. Unless you&amp;#39;re comparing a large number of identical length strings it would be very rare to enter the loop that iterates the char array.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/1447092825793270003'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/1447092825793270003'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1327439525510#c1447092825793270003' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1025229639'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-8288014804290291288</id><published>2010-08-21T12:44:57.763-04:00</published><updated>2010-08-21T12:44:57.763-04:00</updated><title type='text'>Another reason why == performs only marginally fas...</title><content type='html'>Another reason why == performs only marginally faster than equals() is that String.equals(String) will probably do the == comparison as the first check (e.g. see sun jdk 1.6)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/8288014804290291288'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/8288014804290291288'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1282409097763#c8288014804290291288' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-713524230'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-8131688270399539742</id><published>2010-06-22T15:38:44.406-04:00</published><updated>2010-06-22T15:38:44.406-04:00</updated><title type='text'>I find it strange that you said &amp;quot;&lt;i&gt;== is 5 t...</title><content type='html'>I find it strange that you said &amp;quot;&lt;i&gt;== is 5 times faster than String.equals()&lt;/i&gt;&amp;quot; and then right after that said that the myth was busted.  It&amp;#39;s not a myth if it&amp;#39;s 5 times faster! When one considers it in O(n) notation, String.equals() is O(n) and == is O(1); this is not a myth, it&amp;#39;s fact.&lt;br /&gt;&lt;br /&gt;Furthermore, I guarantee you that it&amp;#39;s much more than 5 times faster in many applications; depending on the type of strings and how they are used, it can be &lt;b&gt;many&lt;/b&gt; orders of magnitude faster that cannot be ignored.&lt;br /&gt;&lt;br /&gt;In any case, to your point, if people don&amp;#39;t know why they are using .intern() then they most certainly should not be using it.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/8131688270399539742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/8131688270399539742'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1277235524406#c8131688270399539742' title=''/><author><name>Matt Quigley</name><uri>http://www.blogger.com/profile/01652979535335976265</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-910432084'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-304878622351919823</id><published>2010-02-16T14:58:53.767-05:00</published><updated>2010-02-16T14:58:53.767-05:00</updated><title type='text'>Hi,

I don&amp;#39;t agree with your post. I&amp;#39;m wor...</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t agree with your post. I&amp;#39;m working in the area on natural language processing. There we do a lot of data crunchings with words and lots of statistics. Let me say that without &amp;quot;intern()&amp;quot; we could go nowhere. It saves our day. Without it, I busted 64 Gb of Ram just because each word made its small nest memory. When you have applications where you must have vocabularies of hundreds of thousands of words permanently in memory, it helps a lot. As I said, you couldn&amp;#39;t do anything without it ...except mapping them to integer ids and going on with the integers instead of the words. And in terms of speedup, it is not fiction but reality, transforming a program thout would take days into a program that takes hours.&lt;br /&gt;&lt;br /&gt;So, please be cautious in what you say and investigate thouroughly. ...a last word though: yeah, for the classic avergae application, it&amp;#39;s useless.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/304878622351919823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/304878622351919823'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1266350333767#c304878622351919823' title=''/><author><name>sidewords</name><uri>http://www.blogger.com/profile/07617597243831242011</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-847081596'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-660701365852890050</id><published>2009-08-28T17:31:21.139-04:00</published><updated>2009-08-28T17:31:21.139-04:00</updated><title type='text'>Great article.
I agree, I think that the general p...</title><content type='html'>Great article.&lt;br /&gt;I agree, I think that the general philosophy should be to optimize later, and only if needed.&lt;br /&gt;Looking into a heap dump of you app, during load, you can see right away what are the good candidates for intern.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/660701365852890050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/660701365852890050'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1251495081139#c660701365852890050' title=''/><author><name>Gili Nachum</name><uri>http://www.blogger.com/profile/16996461994293511014</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-132143578'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-3851680288502830348</id><published>2009-01-08T08:20:00.000-05:00</published><updated>2009-01-08T08:20:00.000-05:00</updated><title type='text'>Sorry but I think the "5 times" observation is inc...</title><content type='html'>Sorry but I think the "5 times" observation is incorrect as a general statement.&lt;BR/&gt;&lt;BR/&gt;Can you post the actual code? I would love to see what  is actually being measured in your micro-benchmark in particular the strings used and were the deviation happens if some do not match. &lt;BR/&gt;&lt;BR/&gt;I have a cost table beside me for each op (field read, field write, method call,...) and the number you have quoted seems pretty low unless failures in matching happening very early or you are  measuring something else.&lt;BR/&gt;&lt;BR/&gt;William</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/3851680288502830348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/3851680288502830348'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1231420800000#c3851680288502830348' title=''/><author><name>William Louth</name><uri>http://www.blogger.com/profile/00414063535114178838</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-581307503'/></entry><entry><id>tag:blogger.com,1999:blog-6098392112071095875.post-3161391190746733684</id><published>2009-01-07T07:02:00.000-05:00</published><updated>2009-01-07T07:02:00.000-05:00</updated><title type='text'>In case you haven't read it: http://kohlerm.blogsp...</title><content type='html'>In case you haven't read it: http://kohlerm.blogspot.com/2009/01/is-javalangstringintern-really-evil.html&lt;BR/&gt;&lt;BR/&gt;FYI, that's not my post :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/3161391190746733684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6098392112071095875/2125854442395024415/comments/default/3161391190746733684'/><link rel='alternate' type='text/html' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html?showComment=1231329720000#c3161391190746733684' title=''/><author><name>nanda</name><uri>http://www.blogger.com/profile/17335206798457235900</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.codeinstructions.com/2009/01/busting-javalangstringintern-myths.html' ref='tag:blogger.com,1999:blog-6098392112071095875.post-2125854442395024415' source='http://www.blogger.com/feeds/6098392112071095875/posts/default/2125854442395024415' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1206234402'/></entry></feed>
