Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (512)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2] 3 4 5
  ignore  |  Print  
  Java Lambdas Finalised!  (Read 13709 times)
0 Members and 1 Guest are viewing this topic.
Offline OverKill

Junior Duke




Java games rock!


« Reply #30 - Posted 2011-09-14 07:04:26 »

I've managed 30 years without needing closures.
Dito!

Quote
Now they're going to co-opt a few more ascii characters to do something that makes not a lot of sense and does even more trickery under the hood. Oh well, not much we can do about it.
Yup. IMHO not much else then 'language x has y feature so we need it to, or else people won't think we are cool'.

Quote from: gouesse
I disagree with a lot of people here. Java is going to become so complicated and remember what happened to C++ in the past... A modern language cannot get all "cool" features, choices have to be made and using several programming languages in a single project should not be a problem. Some languages are better to express of some kinds of things. If a single language tries to express at best anything, it can only become extremely complicated to use. Closures give a (contestable) comfort to some people but Java can live without it.
Agree 100%
People want to turn Java into a different language, one where you don't 'have to type as much'.
Offline nsigma
« Reply #31 - Posted 2011-09-14 09:37:12 »

I love how they show anonymous inner classes with no highlighting, then lambdas with highlighted text.  Roll Eyes

Huh?  Isn't he just highlighting what he's talking about (these being slides after all).

Is the method reference stuff going in Java?

From the email that Kappa originally linked to (emphasis mine)
Quote
... have not yet come to a decision on method reference syntax.

which to me means, yes.  I also presume that the extension mechanism for interfaces is also going to come in, which would be great.

Incidentally, I found this PDF by accident while googling for an old blog post I read on all this (which I still haven't found!) - pretty useful find.  And the naysayers around here should look at the cartoons near the end - I'm picturing all your faces in that crowd!  Grin

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline gouessej
« Reply #32 - Posted 2011-09-14 09:43:02 »

Thanks for the PDF. It is less bad than I thought but I will stay far from lambdas as it does not match with my natural way of programming. I agree with using predicates, reducers, etc... but with anonymous inner classes.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nsigma
« Reply #33 - Posted 2011-09-14 09:48:13 »

Thanks for the PDF. It is less bad than I thought but I will stay far from lambdas as it does not match with my natural way of programming. I agree with using predicates, reducers, etc... but with anonymous inner classes.
Quote
Lambda expressions are not sugar for inner classes
– Implemented with MethodHandle from JSR 292

Just sayin'!  Smiley

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline gouessej
« Reply #34 - Posted 2011-09-14 14:25:19 »

Thanks for the PDF. It is less bad than I thought but I will stay far from lambdas as it does not match with my natural way of programming. I agree with using predicates, reducers, etc... but with anonymous inner classes.
Quote
Lambda expressions are not sugar for inner classes
– Implemented with MethodHandle from JSR 292

Just sayin'!  Smiley

The implementation of lambdas is not based on inner classes, I know what the sentences above mean. However, what lambdas do can be done with inner classes and I hope that future APIs won't force programmers to use this feature like in this case:
1  
2  
3  
4  
5  
6  
7  
8  
9  
students.filter(new Predicate<Student>() {
             public boolean op(Student s) {
                    return s.gradYear == 2010;
             }
       }).map(new Extractor<Student,Double>() {
              public Double extract(Student s) {
                     return s.score;
             }
       }).max();

Offline sproingie

JGO Kernel


Medals: 202



« Reply #35 - Posted 2011-09-14 17:06:08 »

You ask me, that last bit of code demonstrates the use case for lambdas right there.  That sort of thing is a one-liner in every other language that matters that I can think of.  Syntax does matter.
Offline nsigma
« Reply #36 - Posted 2011-09-14 18:10:47 »

Quote
Lambda expressions are not sugar for inner classes
– Implemented with MethodHandle from JSR 292

Just sayin'!  Smiley

The implementation of lambdas is not based on inner classes, I know what the sentences above mean. However, what lambdas do can be done with inner classes and I hope that future APIs won't force programmers to use this feature like in this case:

I think the implication of that statement is that there is the potential to get better performance than inner classes.  At least that's what I gather from what else I've read.  If anyone can elucidate how and why, please step in!

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #37 - Posted 2011-09-14 18:52:45 »

Yeah but honestly it would have been better to write
1  
select max(score) from students where gradYear = 2010

wouldn't it? It does seem to me that introducing SQL as a first class syntax in Java would have been a whole lot nicer. Maybe some less kludgy examples would help illustrate the point, but honestly I'm just as happy with the code as it is because it's trivial to see what it's doing and understand it despite what all the detractors say.

Cas Smiley

Offline JL235

JGO Coder


Medals: 10



« Reply #38 - Posted 2011-09-14 19:13:53 »

Yeah but honestly it would have been better to write
1  
select max(score) from students where gradYear = 2010

wouldn't it? It does seem to me that introducing SQL as a first class syntax in Java would have been a whole lot nicer. Maybe some less kludgy examples would help illustrate the point, but honestly I'm just as happy with the code as it is because it's trivial to see what it's doing and understand it despite what all the detractors say.
I'd agree, if only so I can have DB SQL queries validated at compile time.

It would also be nice to see some original ideas in Java, rather then just stealing them from C#.

Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #39 - Posted 2011-09-14 19:17:13 »

I was doing that in Powerbuilder nearly 20 years ago Sad

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline sproingie

JGO Kernel


Medals: 202



« Reply #40 - Posted 2011-09-14 20:05:27 »

It would also be nice to see some original ideas in Java, rather then just stealing them from C#.

It's not like C# invented them either.  Even LINQ came from HaskellDB and extended comprehensions, and list comprehensions themselves are a Prolog thing that found their way into Erlang.  Like Picasso said, "great artists steal".

Finding out that lambdas aren't sugar for inner classes makes me wonder whether we'll have to wait for libraries to bless us with lambda-fied versions of their cumbersome API (e.g. Collections) or whether there'll be some sort of implicit conversion on top of it.  Implicits from Scala, now there'd be a radical feature that will assuredly Never Make It In to regular java...

The pushback for basic features like anonymous functions was bad enough.  I suspect anything truly original in Java will be met with pitchforks and torches.

Offline gouessej
« Reply #41 - Posted 2011-09-16 10:11:16 »

It would also be nice to see some original ideas in Java, rather then just stealing them from C#.
C# is a bad clone of Java with some other features and I still find lambdas not very interesting and less natural.

Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #42 - Posted 2011-09-16 10:17:12 »

I think the problem most of us find with Lambdas is that Java is a pretty low-level language when all's said and done and this is a very high-level feature being bolted on to it. It obscures a lot of low-level wizardy under the scenes which makes it look like "magic" and many of us feel uncomfortable with stuff like that. But like garbage collection and JIT compilation it's magic we'll probably grow used to ... with time. It's just that this is an addition to something which already takes quite some explanation and mastery - Java, the core language - and every new bit added on just makes the whole darned thing harder to learn and master.

Cas Smiley

Offline gouessej
« Reply #43 - Posted 2011-09-17 09:49:32 »

I think the problem most of us find with Lambdas is that Java is a pretty low-level language when all's said and done and this is a very high-level feature being bolted on to it. It obscures a lot of low-level wizardy under the scenes which makes it look like "magic" and many of us feel uncomfortable with stuff like that. But like garbage collection and JIT compilation it's magic we'll probably grow used to ... with time. It's just that this is an addition to something which already takes quite some explanation and mastery - Java, the core language - and every new bit added on just makes the whole darned thing harder to learn and master.

Cas Smiley
I agree with you but my problem is both the syntax and the fact I was already happy with inner classes.

Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #44 - Posted 2011-09-17 23:24:58 »

They do seem to do something a bit beyond inner classes which I can vaguely understand, especially as it seems to have needed a couple of new bytecodes to achieve it.

Cas Smiley

Offline tom
« Reply #45 - Posted 2011-09-18 02:13:59 »


I agree with you but my problem is both the syntax and the fact I was already happy with inner classes.
[/quote]
Inner classes are ugly and produces to much boilerplate code. I cant wait for lambdas. It will be the best thing that happened to java since the enhanced for loop.

Offline longino

Junior Duke


Medals: 1



« Reply #46 - Posted 2011-09-18 15:01:18 »

Can someone tell me why closures are so awesome? They cause me so many bugs in javascript.
Relax Smiley they aren't closures. They are lambda expressions and they are an entire different species. You won't run into the javascript/closure issues you mentioned earlier.

WHAT? Then what is the point? Just syntactic sugar for anonymous classes?

Lame. If they want to do it then do it right.

Closure and lambda being synonyms is a natural way of thinking, since in Lisp, where this all originates from, lambdas close the lexical environment. Lambdas without closing it it is kind of lazy actually, because it doesn't really offer anything new to the developer. It doesn't enable him to do anything he didn't already do.
Offline kaffiene
« Reply #47 - Posted 2011-09-19 03:59:08 »

I think Scala is complex and inefficient. Something in between Java and Scala would be better. Kotlin sounds promising.

+1

I don't care much one way or the other about the closures proposal.  If it's in the language, I'll use it (like generics) but I wasn't hanging out for them (and I *do* know how lambda functions work from LISP, Javascript, Haskell etc).  It's just a flavour issue, not the second coming as some language bigots would argue.
Offline OverKill

Junior Duke




Java games rock!


« Reply #48 - Posted 2011-09-19 13:00:28 »

@longino:
So if it does not add anything ... why is it being added? Just so Java can be 'cool'?

I sometimes wonder if people really want to program any more. Just following the next hype that brings nothing to the table except saving people from using the language as it was intended and/or some typing.

If I want to use features from a different language, why don't I just use that language?
Offline gouessej
« Reply #49 - Posted 2011-09-19 13:20:02 »

Inner classes are ugly and produces to much boilerplate code. I cant wait for lambdas. It will be the best thing that happened to java since the enhanced for loop.
It is a matter of taste. Some people find them ugly, some other people like me find them easier to understand than these lambdas.

Offline sproingie

JGO Kernel


Medals: 202



« Reply #50 - Posted 2011-09-19 16:46:05 »

Yes, it's just syntax sugar, but here's a dirty little secret: all programming languages are just syntax sugar for turing machines (ala brainf*ck) or SKI combinators (unlambda).

Syntax does in fact matter.  A lot.


Offline nsigma
« Reply #51 - Posted 2011-09-19 16:57:18 »

Yes, it's just syntax sugar, but here's a dirty little secret: all programming languages are just syntax sugar for turing machines (ala brainf*ck) or SKI combinators (unlambda).

Syntax does in fact matter.  A lot.

While I agree with the general gist of your comment, as I've already quoted above, Oracle are claiming these aren't just syntax sugar for inner classes - they're implemented differently under the hood, and in a way that may allow improved performance over inner classes in the future.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #52 - Posted 2011-09-19 17:22:31 »

When you compile java code with anonymous classes you get a seperate *$#.class file for each class which has always been a pet peeve for me. Hoping that these lambda things don't do that same Smiley
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #53 - Posted 2011-09-19 17:24:23 »

[...] Wonder how I'll be applying it to the sort of noddy coding I do for games. Probably won't Smiley

Last week I kinda agreed with that. Today, I kinda don't.

I think the problem most of us find with Lambdas is that Java is a pretty low-level language when all's said and done and this is a very high-level feature being bolted on to it. It obscures a lot of low-level wizardy under the scenes which makes it look like "magic" and many of us feel uncomfortable with stuff like that.[...]

It's actually not that magical. It's a concept borrowed from functional programming. Now, the interesting part is that if you write it in such a way, it's clear (for the machine) that the order doesn't matter, because there isn't some kind of state. You only care for the result at the very end.

This allows the machine to do things in parallel. Intel's River Trail (some parallel processing extension for JavaScript) demonstrated that this is indeed a pretty interesting approach and it can indeed work pretty damn well.

So yea, it actually is kinda interesting, because it can improve performance without the usual pitfalls associated with multi threaded programming. (Interestingly, SQL is kinda similar. The driver can re-arrange your statements and do some things in parallel if it looks like a good idea.)

Well, at least that's the theory as far as I can tell.

My next CPU will probably have 8 cores. Without shortcuts like this, most programs won't be able to do anything useful with those beefy resources. Would be a shame, really.

弾幕 ☆ @mahonnaiseblog
Offline Roquen
« Reply #54 - Posted 2011-09-19 18:42:19 »

KEEP CHINA BRITISH!  Err..wait!
Offline nsigma
« Reply #55 - Posted 2011-09-20 09:37:47 »

This allows the machine to do things in parallel. Intel's River Trail (some parallel processing extension for JavaScript) demonstrated that this is indeed a pretty interesting approach and it can indeed work pretty damn well.

I was reading some stuff about this the other day.

Putting some things together -

http://www.theregister.co.uk/2011/09/17/intel_parallel_javascript/ - this article, particularly the penultimate paragraph, together with this thread on Aparapi - http://www.java-gaming.org/topics/amd-open-sources-aparapi/24778/view.html and the Aparapi FAQ item on lambdas - all starts to look kinda interesting for the future!  Smiley

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline longino

Junior Duke


Medals: 1



« Reply #56 - Posted 2011-10-08 18:04:01 »

Yes, it's just syntax sugar, but here's a dirty little secret: all programming languages are just syntax sugar for turing machines (ala brainf*ck) or SKI combinators (unlambda).

Syntax does in fact matter.  A lot.

Really? So all programming languages are the same to you?

Technologies are as good as they are useful. If they aren't introducing anything new then in the end nothing has changed.

Syntax is just a tiny fraction of what matters in a programming language. The concepts behind it are the "meat" of it, that which will make people want to use it because it enables them to accomplish something they previously couldn't.
Offline Roquen
« Reply #57 - Posted 2011-10-08 18:40:32 »

You're missing the point.  All useful programming languages are the "same" in the sense that they are Turing complete (which if memory serves only requires 5 operations).  The syntax of various languages, in effect, only create lots of different specialize versions of these operations. BUT sytnax (and paradigim) matter...a ton.
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #58 - Posted 2011-10-08 19:33:26 »

Syntax is everything to a programmer.

Cas Smiley

Offline longino

Junior Duke


Medals: 1



« Reply #59 - Posted 2011-10-08 20:03:00 »

You're missing the point.  All useful programming languages are the "same" in the sense that they are Turing complete (which if memory serves only requires 5 operations).  The syntax of various languages, in effect, only create lots of different specialize versions of these operations. BUT sytnax (and paradigim) matter...a ton.

I think you are the one who doesn't get it.

Different programming languages are conceptually different in the sense that they employ complete different approaches to solving the same problem.

It means that using a different language requires you to think in a completely different way. It is not a simple one to one translation of the code.

An example of a worthy feature was LINQ in C#. LINQ is conceptually different than anything previously present in a mainstream language, and it really enables the developer to do things he couldn't before. LINQ is more than syntactic sugar. It changes how you think about the software you are developing.
Pages: 1 [2] 3 4 5
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (36 views)
2014-10-15 16:18:58

TehJavaDev (66 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!