<?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-24611184.post4738211618814088231..comments</id><updated>2010-02-14T02:36:49.959-08:00</updated><category term='xml'/><category term='scala'/><category term='podcast'/><category term='StAX'/><category term='java'/><category term='programming'/><category term='jdo'/><category term='socialnetworks'/><category term='gwt'/><category term='monitoring'/><category term='open source'/><category term='Thrift'/><category term='linkedin'/><category term='javaposse'/><category term='protobuf'/><category term='Google App Engine'/><category term='test'/><category term='guic'/><category term='guice'/><category term='ibm'/><category term='groovy'/><category term='spring'/><category term='twitter'/><category term='OHF'/><category term='Eclipse'/><category term='Mac'/><category term='voldemort'/><category term='kaching'/><category term='testing'/><category term='j2ee'/><category term='work'/><category term='conferences'/><category term='xstream'/><category term='json'/><category term='Books'/><title type='text'>Comments on Wondering around: Beware of Scala’s type inference !</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.eishay.com/feeds/4738211618814088231/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html'/><author><name>Eishay Smith</name><uri>http://www.blogger.com/profile/09443096006184006852</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='30' height='32' src='http://4.bp.blogspot.com/_O9TJAb-LjDE/S44K61181wI/AAAAAAAAAj0/oYGO2xz_kf4/S220/eishay.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-24611184.post-8542799423341557061</id><published>2009-05-08T06:52:00.000-07:00</published><updated>2009-05-08T06:52:00.000-07:00</updated><title type='text'>There are two options here, for both Java and Scal...</title><content type='html'>There are two options here, for both Java and Scala:&lt;br /&gt;1. You change your return type on your library, but not the dependent code, i.e. no recompile.&lt;br /&gt;2. You change your return type and recompile your dependent code against the new return type.&lt;br /&gt;&lt;br /&gt;Can we agree that for 1., both Scala and Java will throw exception at runtime?&lt;br /&gt;&lt;br /&gt;For 2, you will get compile errors in both cases, hence my argument that Scala is no different than Java.&lt;br /&gt;Scala will reinfer the type and find an unknown method call. It will complain about this at compile time.&lt;br /&gt;Java is the same, except you'll first get a type error, which you then fix manually and then the unknown method call.&lt;br /&gt;&lt;br /&gt;If you still disagree, I would urge you to actually try it out.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/8542799423341557061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/8542799423341557061'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241790720000#c8542799423341557061' 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.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1271240673'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-6328782468392131505</id><published>2009-05-07T09:06:00.000-07:00</published><updated>2009-05-07T09:06:00.000-07:00</updated><title type='text'>You're right, there are no implicits involved. Imp...</title><content type='html'>You're right, there are no implicits involved. Implicit in Scala is an overloaded word, shouldn't have used this term. When you're not explicitly defining a return type (using type inference) the return type of the method signature is implicitly defined by the actual return type, nothing to do with Scala's implicits constructs.&lt;br /&gt;In the example, the client uses the library return value as a Map (not as a mutable HashMap that is returned). If it would have explicitly declared val map as {val map : Map[String, String]} as you would do in Java, i.e. not relay on type inference, then there would not be any problem if the library changed the implementation from immutable to mutable. In other words, if you are not well defining the value you receive from the library at the time you receive it in the client, and you don’t recompile your client when the library change (though you don’t change your client code), then they will break on runtime.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/6328782468392131505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/6328782468392131505'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241712360000#c6328782468392131505' title=''/><author><name>Eishay Smith</name><uri>http://www.blogger.com/profile/09443096006184006852</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='30' height='32' src='http://2.bp.blogspot.com/_O9TJAb-LjDE/SdlzHG9KSlI/AAAAAAAAAYc/kCnqSgnk0es/S220/n646386018_2207361_5928583.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1856236024'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-8973768376606131287</id><published>2009-05-07T06:00:00.000-07:00</published><updated>2009-05-07T06:00:00.000-07:00</updated><title type='text'>You code example does not use implicits. It infers...</title><content type='html'>You code example does not use implicits. It infers the type, which is no different than in Java where you manually enter it.&lt;br /&gt;In both cases, if the library changes the type, the dependent code will fail. Same for Scala as for Java.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/8973768376606131287'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/8973768376606131287'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241701200000#c8973768376606131287' 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.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-361014066'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-3729895793018738082</id><published>2009-05-06T13:09:00.000-07:00</published><updated>2009-05-06T13:09:00.000-07:00</updated><title type='text'>mmm, not sure we understand each other. When a lib...</title><content type='html'>mmm, not sure we understand each other. When a library changes an implicit return type the client code does not necessarily have to change (like in the example in the post) and neither the Java or Scala compilers should fail when recompiling the client. But in this case the client compiled bytecode actually change - does not happen in Java since there are no implicits. Having the client bytecode change without the source code modified is not typical to Java code (unless you switch compilers) and as in the example, if you don't change the client binary in your runtime then it might break there.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/3729895793018738082'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/3729895793018738082'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241640540000#c3729895793018738082' title=''/><author><name>Eishay Smith</name><uri>http://www.blogger.com/profile/09443096006184006852</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='30' height='32' src='http://2.bp.blogspot.com/_O9TJAb-LjDE/SdlzHG9KSlI/AAAAAAAAAYc/kCnqSgnk0es/S220/n646386018_2207361_5928583.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1856236024'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-4661074148773143737</id><published>2009-05-06T12:37:00.000-07:00</published><updated>2009-05-06T12:37:00.000-07:00</updated><title type='text'>&lt;i&gt;Java will fail at build time (and runtime)&lt;/i&gt;S...</title><content type='html'>&lt;I&gt;Java will fail at build time (and runtime)&lt;/I&gt;Scala will fail at the same points under the same conditions. There is absolutely no difference.&lt;br /&gt;Also, there's no mention of using implicits, which could lead to unexpected behavior, though not of the kind mentioned here.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/4661074148773143737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/4661074148773143737'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241638620000#c4661074148773143737' 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.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-152378217'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-770657205905512770</id><published>2009-05-06T10:28:00.000-07:00</published><updated>2009-05-06T10:28:00.000-07:00</updated><title type='text'>Java will fail at build time (and runtime). To be ...</title><content type='html'>Java will fail at build time (and runtime). To be more clear, if in Java you change the source one class it does not changes the compilation of other classes (though it could break their compilation). I don't know much about dynamic languages, but I believe the case is similar there (please correct me if I'm wrong). On the other hand, if in Scala you use implicit all around then changing one the source code of a library class does change the compilation output of the consumer class and this is the dangerous part.&lt;br /&gt;In many large projects there are binary dependencies between libraries / modules, compiled versions of the modules are kept in a repository and unless you change their code they are will not be rebuilt. Lets say I wish to upgrade a version of a module v1.0 to v2.0 which is used by a client v1.0. I will build it with all the others and run some tests, and if all goes well then I assume that the module is backwards compatible and add it to the binary repository. Not the folks that build the product are taking together all the jar files and they break on runtime!&lt;br /&gt;Now, this is not a big deal as itself. The bigger deal is that the module is not really backward compatible and you may not have all the sources handy to rebuild them from scratch as in the unfortunate case of using not open source library, but even if you do have the sources its a pain.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/770657205905512770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/770657205905512770'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241630880000#c770657205905512770' title=''/><author><name>Eishay Smith</name><uri>http://www.blogger.com/profile/09443096006184006852</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='30' height='32' src='http://2.bp.blogspot.com/_O9TJAb-LjDE/SdlzHG9KSlI/AAAAAAAAAYc/kCnqSgnk0es/S220/n646386018_2207361_5928583.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1856236024'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-3617309186639009379</id><published>2009-05-06T09:21:00.000-07:00</published><updated>2009-05-06T09:21:00.000-07:00</updated><title type='text'>This is no different than in Java. If you change t...</title><content type='html'>This is no different than in Java. If you change the return type in a third party library and attempt to run it, Java too will fail at runtime.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/3617309186639009379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/3617309186639009379'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241626860000#c3617309186639009379' 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.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1941045721'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-1753226428143205863</id><published>2009-05-04T23:27:00.000-07:00</published><updated>2009-05-04T23:27:00.000-07:00</updated><title type='text'>Right Ismael,

I should have added that this and s...</title><content type='html'>Right Ismael,&lt;br /&gt;&lt;br /&gt;I should have added that this and some of my other posts are aiming using java in large code bases where you may not own all the code or be able to recompile it all (some of it may be in a maven like repository).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/1753226428143205863'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/1753226428143205863'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241504820000#c1753226428143205863' title=''/><author><name>Eishay Smith</name><uri>http://www.blogger.com/profile/09443096006184006852</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='30' height='32' src='http://2.bp.blogspot.com/_O9TJAb-LjDE/SdlzHG9KSlI/AAAAAAAAAYc/kCnqSgnk0es/S220/n646386018_2207361_5928583.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1856236024'/></entry><entry><id>tag:blogger.com,1999:blog-24611184.post-3721479499746950524</id><published>2009-05-04T23:18:00.000-07:00</published><updated>2009-05-04T23:18:00.000-07:00</updated><title type='text'>Hi Eishay,

I agree that using explicit result typ...</title><content type='html'>Hi Eishay,&lt;br /&gt;&lt;br /&gt;I agree that using explicit result types is a good idea for public APIs.&lt;br /&gt;&lt;br /&gt;As you say, with implicit result types, it's too easy to change the signature of the method without noticing and causing a binary incompatible change as result.&lt;br /&gt;&lt;br /&gt;It should be noted that if the client recompiled the code, a compiler error would occur (instead of the runtime error). That is probably what you had in mind when you said:&lt;br /&gt;&lt;br /&gt;"This issue is especially relevant for large projects that break up to binary dependent modules."</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/3721479499746950524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/24611184/4738211618814088231/comments/default/3721479499746950524'/><link rel='alternate' type='text/html' href='http://www.eishay.com/2009/05/beware-of-scalas-type-inference.html?showComment=1241504280000#c3721479499746950524' title=''/><author><name>Ismael Juma</name><uri>http://www.blogger.com/profile/17398483226873559286</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.eishay.com/2009/05/beware-of-scalas-type-inference.html' ref='tag:blogger.com,1999:blog-24611184.post-4738211618814088231' source='http://www.blogger.com/feeds/24611184/posts/default/4738211618814088231' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2084065487'/></entry></feed>
