Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
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 ... 6
  ignore  |  Print  
  Java 7 to get Closures!  (Read 22532 times)
0 Members and 1 Guest are viewing this topic.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Posted 2009-11-19 13:32:11 »

Sun had publicly announced that there would be no closures in Java 7, however a surprise U-Turn was made yesterday when Mark Reinhold announced that Java 7 will now include 'Light' Closures. After years of debate it looks like they have chosen the FCM syntax style.

more info below

http://java.dzone.com/news/closures-coming-java-7
http://www.jroller.com/scolebourne/entry/closures_in_jdk_7
Offline CommanderKeith
« Reply #1 - Posted 2009-11-19 13:37:24 »

Gee that syntax looks really messy. I don't think it's necessary, the current way of doing it is fine using inner classes. I just wish they'd make it so that inner classes could change variables outside their class without them having to be final


Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #2 - Posted 2009-11-19 14:00:30 »

more info

http://weblogs.java.net/blog/cayhorstmann/archive/2009/11/18/closures-java-7
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2009-11-19 14:31:53 »

Oh no Sad More complexity. More opaque syntax. More ASCII being used in strange new ways. No longer readable. How crap.

Cas Smiley

Offline Roquen
« Reply #4 - Posted 2009-11-19 14:33:16 »

Also Milestone 5 came out a few days ago (download here). 

Includes some of the (Project Coin) language changes (binary literals, generic inference, strings in switches).  As well as escape-analysis and pointer compression.  Other stuff includes newer concurrency stuff from Doug Lea, elliptic curve crypto and a new swing component (JLayer).

I've mentioned Zero a few times in the past...it has been added to version control.
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #5 - Posted 2009-11-19 15:33:46 »

Oh no Sad More complexity. More opaque syntax. More ASCII being used in strange new ways. No longer readable. How crap.

Cas Smiley

Yea, I agree. I still haven't figured out how to properly use generics, annotations, although I wouldn't want to be without it.

Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
Offline JL235

JGO Coder


Medals: 10



« Reply #6 - Posted 2009-11-19 15:36:44 »

I like using anonymous classes for defining a single function to pass around, so for me clojures offer a better and more readable alternative to what I'm already doing.

But I don't like the use of #. Couldn't they have just used 'fun' like everyone else?

Offline gouessej
« Reply #7 - Posted 2009-11-19 16:07:31 »

Oh no Sad More complexity. More opaque syntax. More ASCII being used in strange new ways. No longer readable. How crap.
I agree with you. If Sun goes on complicating Java, it will look as crappy as C++. I would like to freeze its syntax, concentrate on maintaining existing APIs and creating new ones.

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #8 - Posted 2009-11-19 16:27:30 »

I don't see the point. What's the problem with just declaring a private class? At least then you know what's going on.

See my work:
OTC Software
Online princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2009-11-19 17:10:45 »

The problem is that a bunch of smartypants types who have been programming for years think it'd be great to add this fancy new feature to Java to make it look even more complicated than it really needs to be, and so the original goal of Java ("C++ without the knives, guns, and clubs") is going to be completely lost.

I had to debug some C++ code yesterday. If it ends up looking like that ... well, I'll get me coat.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #10 - Posted 2009-11-19 17:16:35 »

I had to debug some C++ code yesterday. If it ends up looking like that ... well, I'll get me coat.

where would you go though? don't think there really is an alternative good enough atm to jump ship too.
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 833
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2009-11-19 17:29:10 »

Pssst, Cas loves Blitz!

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline DzzD
« Reply #12 - Posted 2009-11-19 18:18:03 »

Yea, I agree. I still haven't figured out how to properly use generics, annotations, although I wouldn't want to be without it.
I agree too Sad, stop chnging the language every days....  Java is fine as it

Offline xinaesthetic

Senior Devvie


Medals: 1



« Reply #13 - Posted 2009-11-19 18:34:57 »

I don't understand the hostility... surely no-one thinks
1  
2  
3  
4  
button.addActionListener(
   new ActionListener() {
      public void actionPerformed(ActionEvent e) {
         System.out.println("Hi!"); } } );

is nicer than
1  
button.addActionListener(#(ActionEvent e) System.out.println("Hi!));


Java could be a lot worse, but having done quite a bit with C# recently I must say I do prefer it as a language.  This isn't "knives, guns and clubs" - we still have the managed environment of the JVM - and it's certainly not going to turn Java into C++, it's just implementing a little bit more of the functional side that's been sorely lacking.
Offline xinaesthetic

Senior Devvie


Medals: 1



« Reply #14 - Posted 2009-11-19 18:39:13 »

Oh, and did I mention... anyone who dislikes operator overloading is a foul heathen.
Offline ShannonSmith
« Reply #15 - Posted 2009-11-19 19:19:42 »

Quote
Oh, and did I mention... anyone who dislikes operator overloading is a foul heathen.

As a day job professional c++ developer who has to maintain other peoples "creative" c++ code I can categorically say that the ONLY instance in which operator overloading has not caused more pain than it is worth is '+' for string concatenation. Even that is suspect because it breaks the commutativity property of numeric addition.

Operator overloading should ONLY be defined by the language and ONLY for immutable types and ONLY where it makes logical sense. If you think operator overloading is only abused by bad programmers consider the fact that one of worst cases I have seen is the "bit-shift is totally logically similar to stream concatenation" in the c++ STL.

On closures:
Have investigated a few times and still don't really understand the concept fully. Anonymous inner classes have served me fine for the rare cases when I have needed them. I have always wondered how likely closures are to introduce obscure bugs and how they impact debugging.

The day I switch to Python will be the day operator overloading is added to Java.
Offline i30817

Junior Devvie





« Reply #16 - Posted 2009-11-19 19:29:36 »

Good news, but reading from the spec i can't understand if non-local returns are in or not.
Also with closures ParallelArray can be included into std java.

(Also good news in that this means that java 7 is delayed and so the various JSR - date and time, concurrency, coin. Will have some more time. I want composed exception types catch).
Offline i30817

Junior Devvie





« Reply #17 - Posted 2009-11-19 19:30:01 »

Also say hello to Collections 2.0 (almost a need with closures now).

As long as they don't do this:
http://blogs.msdn.com/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx

I'm fine.
Offline ShannonSmith
« Reply #18 - Posted 2009-11-19 19:42:02 »

Just noticed as part of coin:
1  
2  
3  
4  
5  
6  
7  
8  
9  
String s = ...
switch(s) {
  case "x":
    doX();
    break;
  case "y":
    doY();
    break;
}


Awesome!

Offline xinaesthetic

Senior Devvie


Medals: 1



« Reply #19 - Posted 2009-11-19 19:45:11 »

As a day job professional c++ developer who has to maintain other peoples "creative" c++ code I can categorically say that the ONLY instance in which operator overloading has not caused more pain than it is worth is '+' for string concatenation. Even that is suspect because it breaks the commutativity property of numeric addition.

Operator overloading should ONLY be defined by the language and ONLY for immutable types and ONLY where it makes logical sense. If you think operator overloading is only abused by bad programmers consider the fact that one of worst cases I have seen is the "bit-shift is totally logically similar to stream concatenation" in the c++ STL.
OK, I admit... I almost added to my post that I'd managed to stay out of the OS thread and felt like I was missing out on holy wars.  I don't usually troll like that, honest.

I'm also not the worlds experienced programmer, and I have no doubt that operator overloading can be bad... but I do hate doing vector maths with Java style syntax.  Then again, even XNA's vector stuff doesn't use operator overloading for some reason.  I suppose to avoid excessive new objects being created.
Offline bienator

Senior Devvie




OutOfCoffeeException


« Reply #20 - Posted 2009-11-19 19:50:36 »

looking forward to the test builds. (btw syntax is not final yet. The syntax was only chosen for demonstration purposes AFAIK.)

1  
invokeLater({setVisible(true)});

comparators, event listeners, forkjoin's ParrallelArray API, NIO2 Files.walkFileTree visitors... lot of usecases.

Offline Roquen
« Reply #21 - Posted 2009-11-19 22:16:15 »

There are reasonable arguments for and against pretty much all language design elements.  IMHO these issues are (logically) related to Godel's incompleteness theorem.  As someone who works often with programming elements that are algebraic in nature....it drives me crazy when a high level language does not support operator overloading.  Most arguments against are related to bad design.  However it is impossible for a language to prevent bad design.

1  
return SomeType.sqrt(x.mul(x).add(y.copy().mul(y)));

1  
return sqrt(x*x+y*y);



BUT, I think that designing a computer language that "fits all needs" is impossible (again: Godel).  Try reading some of the stuff from Gilad Bracha.  This is someone "important" in the design and development of Java...but to read his papers, one might think he was Java's worst enemy. Which, of course, is far from the truth.
 
Offline TheAnalogKid

JGO Coder


Projects: 2



« Reply #22 - Posted 2009-11-19 23:46:02 »

Well, I like the proposal but I think # as a keyword isn't intuitive. It's like the foreach loop that uses the : to separate the collection from the local var, this syntax isn't intuitive for me.

Online princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #23 - Posted 2009-11-20 00:45:21 »

why can't they just use bloody keywords??? That way at least I can read it out aloud.

Cas Smiley

Offline SwampChicken
« Reply #24 - Posted 2009-11-20 02:52:02 »

Oh my...
I'm still trying to get my head around generics. Looking back now, I remember that the java attraction for me (and others) was it's relative simplicity & ease of use. A few syntax differences and your off. (I used to be a realtime-embedded C guy before then, very procedural stuff so the increased OO was a refreshing change) I've been in the java camp for a while now, and it's frustrating that some of those java7 code snippets look completely foreign to me.

These days, I seem to be wrestling with the new features rather that utilising them.

Maybe it's time for me to move on to some other language.
Offline kaffiene
« Reply #25 - Posted 2009-11-20 03:33:08 »

where would you go though? don't think there really is an alternative good enough atm to jump ship too.

Scala
Offline kaffiene
« Reply #26 - Posted 2009-11-20 03:46:05 »

There are reasonable arguments for and against pretty much all language design elements.  IMHO these issues are (logically) related to Godel's incompleteness theorem.  As someone who works often with programming elements that are algebraic in nature....it drives me crazy when a high level language does not support operator overloading.  Most arguments against are related to bad design.  However it is impossible for a language to prevent bad design.

1  
return SomeType.sqrt(x.mul(x).add(y.copy().mul(y)));

1  
return sqrt(x*x+y*y);



BUT, I think that designing a computer language that "fits all needs" is impossible (again: Godel).  Try reading some of the stuff from Gilad Bracha.  This is someone "important" in the design and development of Java...but to read his papers, one might think he was Java's worst enemy. Which, of course, is far from the truth.
 

Godel's Incompleteness Theorem expresses the fact that algebraic systems can reach a point of complexity where there are things that are true in the system that cannot be expressed in the system and there are things that can be expressed in the system that are not true.  It is impossible to have a system where all valid strings are true and all truths are valid strings.

This contrasts with Godel's Completeness Theorem where he demonstrates the completeness of first order logic.

That has NOTHING to do with making a language that "fit's all needs" as you claim.  That is a matter of taste whereas Godel is referring to a property of systems, namely the truthfulness of valid strings in the system.

Offline kaffiene
« Reply #27 - Posted 2009-11-20 03:54:30 »

Oh my...
I'm still trying to get my head around generics. Looking back now, I remember that the java attraction for me (and others) was it's relative simplicity & ease of use. A few syntax differences and your off. (I used to be a realtime-embedded C guy before then, very procedural stuff so the increased OO was a refreshing change) I've been in the java camp for a while now, and it's frustrating that some of those java7 code snippets look completely foreign to me.

These days, I seem to be wrestling with the new features rather that utilising them.

Maybe it's time for me to move on to some other language.


I have sympathy for what you're saying.  My line with Java has always been that it handles complexity well - you can write large systems with it that are easy to understand.  Programming with teams of C++ developers where each one chose a different C++ style to be 'expressive' was a damn nightmare.  We had islands of programmers who couldn't understand how the other programmers worked and whos code suffered 'impedance mismatch' with their fellows.  It's a crap language for large systems unless you're managed by a rules ****.

All these new features reduce that simplicity.  I believe that people who want features like closures should use languages that support them natively (i.e.: cleanly) rather than hacking them on to what used to be a clean language design.

All that said, it doesn't bother me: I will continue to use Java the way *I* like.
Online princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #28 - Posted 2009-11-20 09:17:54 »

Same here.

Though I would like operators. But not with symbols, just function names. It is indeed pretty horrible trying to fiddle with vectors and matrices without operators.

Cas Smiley

Online kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #29 - Posted 2009-11-20 09:33:14 »

Quote
All that said, it doesn't bother me: I will continue to use Java the way *I* like.

Unfortunately thats also belaying one of the wonderful things about Java, the way that we all use each others code. If some developers start using the new features we all have to live with them, because we want to share code and libraries.

(misuse of) Generics already cripples us in this way. I've already started seeing library interfaces with generically used in "clever" (read complex and evil) ways.

Kev

Pages: [1] 2 3 ... 6
  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.

toopeicgaming1999 (23 views)
2014-11-26 15:22:04

toopeicgaming1999 (21 views)
2014-11-26 15:20:36

toopeicgaming1999 (7 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (24 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
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!