Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26884
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx02.iad.POSTED!not-for-mail |
|---|---|
| From | Arved Sandstrom <asandstrom2@eastlink.ca> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java 8 closures vs. anonymous inner classes |
| References | <l7nuiv$ajm$1@news.albasani.net> |
| In-Reply-To | <l7nuiv$ajm$1@news.albasani.net> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Lines | 47 |
| Message-ID | <5yTqu.2639$oo4.861@fx02.iad> (permalink) |
| X-Complaints-To | abuse@newsgroups-download.com |
| NNTP-Posting-Date | Sat, 14 Dec 2013 07:13:05 UTC |
| Organization | Public Usenet Newsgroup Access |
| Date | Sat, 14 Dec 2013 03:13:05 -0400 |
| X-Received-Bytes | 2953 |
| X-Received-Body-CRC | 4283151248 |
| Xref | csiph.com comp.lang.java.programmer:26884 |
Show key headers only | View raw
On 12/04/2013 03:07 PM, Sebastian wrote:
> Someone made a passing comment in another thread to the effect that Java
> 8 lambdas ("closures") were nothing but syntactic sugar for (anonymous)
> inner classes. Here are a three differences:
>
> 1) lambdas can only instantiate "functional" (single abstract method)
> interfaces
I don't see this as being important. That's actually what Java lambdas
are for, to provide a shorthand for instances of single-method classes.
That's all they are for.
> 2) lambdas have different scoping rules ("this" means different things)
No argument here, the scoping is somewhat different.
> 3) lambdas perform better due to the use of the invokedynamic JVM
> instruction. Type representation, instance creation, and invocation
> strategy are decided at runtime. This offers optimization potentials,
> because evaluating a lambda expression need not create a new instance
> each time. There could be „shared lambdas“ through use of a constant
> static method in a constant pool, needing no new class and/or new object.
To put it bluntly, who cares? The last time I ran into a speed
bottleneck with any language was over a decade ago. The last time I ran
into memory issues with any language was just this year, it happened to
be Java, and the problem was easily solved by jacking up VM RAM - JVMs
with most apps are somewhat of memory pigs, and I doubt that Java 8
lambdas are going to help much with that problem.
> This is quite a bit more than what I'd call "syntactic sugar".
>
> -- Sebastian
In a way they are just syntactic sugar. Most Java programmers will be
unimpressed with your first point - if they don't completely miss it,
they won't even (most of them) notice your second point (until it bites
them and they sort of muddle through), and they won't even understand
what the hell you are talking about wrt your third point: most
developers work M-F 9-5 and don't have the time nor the inclination to
get particularly good at their profession.
AHS
--
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Java 8 closures vs. anonymous inner classes Sebastian <news@seyweiler.dyndns.org> - 2013-12-04 20:07 +0100
Re: Java 8 closures vs. anonymous inner classes Sven Köhler <remove-sven.koehler@gmail.com> - 2013-12-04 22:27 +0200
Re: Java 8 closures vs. anonymous inner classes Patrick Roemer <sangamon@netcologne.de> - 2013-12-05 00:38 +0100
Re: Java 8 closures vs. anonymous inner classes v_borchert@despammed.com (Volker Borchert) - 2013-12-04 23:45 +0000
Re: Java 8 closures vs. anonymous inner classes Roedy Green <see_website@mindprod.com.invalid> - 2013-12-06 13:28 -0800
Re: Java 8 closures vs. anonymous inner classes Arne Vajhøj <arne@vajhoej.dk> - 2013-12-14 16:46 -0500
Re: Java 8 closures vs. anonymous inner classes Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-14 03:13 -0400
Re: Java 8 closures vs. anonymous inner classes "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-12-14 12:03 +0000
Re: Java 8 closures vs. anonymous inner classes Arne Vajhøj <arne@vajhoej.dk> - 2013-12-14 17:02 -0500
Re: Java 8 closures vs. anonymous inner classes Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-15 14:33 -0400
Re: Java 8 closures vs. anonymous inner classes Arne Vajhøj <arne@vajhoej.dk> - 2013-12-14 17:00 -0500
Re: Java 8 closures vs. anonymous inner classes Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-15 15:05 -0400
Re: Java 8 closures vs. anonymous inner classes Wanja Gayk <brixomatic@yahoo.com> - 2013-12-17 20:09 +0100
Re: Java 8 closures vs. anonymous inner classes Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-20 22:28 -0400
Re: Java 8 closures vs. anonymous inner classes lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-21 11:54 +0000
Re: Java 8 closures vs. anonymous inner classes Joerg Meier <joergmmeier@arcor.de> - 2013-12-21 18:27 +0100
Re: Java 8 closures vs. anonymous inner classes lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-21 18:23 +0000
Re: Java 8 closures vs. anonymous inner classes Tim Slattery <tim@risingdove.com> - 2013-12-21 14:56 -0500
Re: Java 8 closures vs. anonymous inner classes lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-21 20:10 +0000
Re: Java 8 closures vs. anonymous inner classes lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-21 21:18 +0000
Re: Java 8 closures vs. anonymous inner classes Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-21 14:52 -0400
Re: Java 8 closures vs. anonymous inner classes lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-21 19:35 +0000
Re: Java 8 closures vs. anonymous inner classes Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-21 19:34 -0400
Re: Java 8 closures vs. anonymous inner classes leif.roar@invalid.com (Leif Roar Moldskred) - 2013-12-22 05:02 -0600
Re: Java 8 closures vs. anonymous inner classes lipska the kat <"lipskathekat at yahoo dot co dot uk"> - 2013-12-22 11:12 +0000
Re: Java 8 closures vs. anonymous inner classes Wanja Gayk <brixomatic@yahoo.com> - 2013-12-22 21:24 +0100
csiph-web