Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.netfront.net!not-for-mail From: Wanja Gayk Newsgroups: comp.lang.java.programmer Subject: Re: are lambdas a way to bring functional programming to java? Date: Wed, 2 Jul 2014 21:23:59 +0200 Organization: Netfront http://www.netfront.net/ Lines: 37 Message-ID: References: <53ae08d5$0$304$14726298@news.sunsite.dk> <53ae0af4$0$302$14726298@news.sunsite.dk> <53b36e09$0$293$14726298@news.sunsite.dk> NNTP-Posting-Host: 77.8.105.242 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit X-Trace: adenine.netfront.net 1404329021 93831 77.8.105.242 (2 Jul 2014 19:23:41 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Wed, 2 Jul 2014 19:23:41 +0000 (UTC) User-Agent: MicroPlanet-Gravity/3.0.4 Xref: csiph.com comp.lang.java.programmer:28914 In article <53b36e09$0$293$14726298@news.sunsite.dk>, Arne Vajhøj (arne@vajhoej.dk) says... > > static final Comparator COMPARE_BY_LENGTH > > = (s1,s2) -> s1.length() - s2.length() > > > > Collections.sort(lst, COMPARE_BY_LENGTH); > > > > ..or even implementing a more general interface. > > But would people do that very often, if the original expression is so > > concise? Hmm.. > > I look at it a bit differently: the introduction of lambda > makes the benefits of reusing close to zero and we only like > reuse when it actually has benefits, so I do not see it as > a problem. You say that until you see an application with about 15 different implementations of a date comparator, some of them plain wrong, some of them without a proper way to handle null values (as the Comparator above, I'd like to add) and you feel urged to fix them all (checking all usages if there is not one case that really needs it the way that looks wrong). Apart from that I find a it more readable by a large margin - and that's even more important in my humble opinion. Kind regards, Wanja -- ..Alesi's problem was that the back of the car was jumping up and down dangerously - and I can assure you from having been teammate to Jean Alesi and knowing what kind of cars that he can pull up with, when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer] --- news://freenews.netfront.net/ - complaints: news@netfront.net ---