13 Replies - 9012 Views - Last Post: 11 January 2012 - 10:08 PM

#1 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

If you could have two things added to Java SE..

Posted 25 November 2011 - 09:52 PM

LAMBDA/LINQ (Right now JPA's database stuff is just vomitous to write)
Is This A Good Question/Topic? 1
  • +

Replies To: If you could have two things added to Java SE..

#2 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: If you could have two things added to Java SE..

Posted 28 November 2011 - 07:40 AM

lambdas and internal iterator support in the Collections framework.
Was This Post Helpful? 0
  • +
  • -

#3 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,682
  • Joined: 13-March 10

Re: If you could have two things added to Java SE..

Posted 28 November 2011 - 07:59 AM

Lambda, something like Entity Framework, Visual Studio
Was This Post Helpful? 0
  • +
  • -

#4 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: If you could have two things added to Java SE..

Posted 05 December 2011 - 07:25 AM

Actually right now for entity framework java has JPA 2.0; given its nowhere near as clean in terms of querying data with LINQ/LAMBDA but it does the job and can be clean if you go to the trouble of defining named queries.. (Everywhere)
Was This Post Helpful? 0
  • +
  • -

#5 harmy01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 179
  • Joined: 15-June 10

Re: If you could have two things added to Java SE..

Posted 08 December 2011 - 07:12 AM

xml layout just like android uses.
Was This Post Helpful? 3
  • +
  • -

#6 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: If you could have two things added to Java SE..

Posted 11 December 2011 - 11:56 AM

LINQ/Lambada. I would fall in love.
Was This Post Helpful? 0
  • +
  • -

#7 master.bennett  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 41
  • Joined: 09-September 11

Re: If you could have two things added to Java SE..

Posted 05 January 2012 - 12:15 PM

View Postharmy01, on 08 December 2011 - 02:12 PM, said:

xml layout just like android uses.


Definitely this, although I do believe JavaFX 2.0 is pushing for something similar so it could be worth looking at.

Its called FXML: http://docs.oracle.c...get_started.htm

It is now bundled with the latest JavaSE editions.

This post has been edited by master.bennett: 05 January 2012 - 12:18 PM

Was This Post Helpful? 0
  • +
  • -

#8 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: If you could have two things added to Java SE..

Posted 06 January 2012 - 03:00 AM

Yes... definitely Lambdas. I just wrote two methods: identical boilerplate with one character difference: + and -. What I needed was a lambda (better, a closure!). What I wrote was this, and I feel dirty about it.

	private enum OperatorLambdaHack {
		// TODO Replace with lambdas in Java 8.
		ADD {
			@Override
			double eval(double a, double B)/> {
				return a + b;
			}
		}, 
		SUBTRACT {
			@Override
			double eval(double a, double B)/> {
				return a - b;
			}
		};
		
		abstract double eval(double a, double B)/>;
	}

Was This Post Helpful? 0
  • +
  • -

#9 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: If you could have two things added to Java SE..

Posted 09 January 2012 - 12:54 PM

Another thing is better port support. I've not experimented very deeply with it, but C# makes Java's support for ports seem pretty hideous.
Was This Post Helpful? 0
  • +
  • -

#10 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 561
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: If you could have two things added to Java SE..

Posted 09 January 2012 - 03:09 PM

For us who do not understand maths, what on earth is Lamda? I have tried looking into it, but it makes no sense whatsoever. What would you use it for?
Was This Post Helpful? 0
  • +
  • -

#11 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,027
  • Joined: 11-December 07

Re: If you could have two things added to Java SE..

Posted 09 January 2012 - 07:04 PM

Like a lot of things in programming, you don't need maths to understand lambdas. They are basically anonymous functions that can be assigned to variables and passed as arguments. In my example, I was adding (or subtracting) two arrays.

(i.e. [1, 2, 3] + [4, 5, 6] = [5, 7, 9])


You can imagine some code:

int[] add(int[] a, int[] B)/> {
  int[] c = new int[a.length];
  for(int i = 0; i < a.length; i++) {
    c[i] = a[i] + b[i];
  }
  return c;
}

int[] subtract(int[] a, int[] B)/> {
  int[] c = new int[a.length];
  for(int i = 0; i < a.length; i++) {
    c[i] = a[i] - b[i];
  }
  return c;
}


Apart from their names, they only differ by a single character. Any good programmer would want to cut out the repetition. Except you can't, at least not in Java.

What you would need is the ability to pass functions around. We can do something similar with interfaces and anonymous classes, but it's all a bit verbose and you end up making more of a mess than you started with. Being able to pass functions around would solve the problem. You would be able to write the method call something like this:

int[] a = ......
int[] b = ......
int[] result = calculate(a, b, {x, y => x + y});

Was This Post Helpful? 2
  • +
  • -

#12 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 238
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: If you could have two things added to Java SE..

Posted 11 January 2012 - 02:18 PM

An IDE as good as Visual Studio :)
Was This Post Helpful? 1
  • +
  • -

#13 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1150
  • View blog
  • Posts: 2,528
  • Joined: 05-May 05

Re: If you could have two things added to Java SE..

Posted 11 January 2012 - 02:59 PM

Just to strengthen the consensus, LINQ/Lambda support would be great.

This post has been edited by blackcompe: 11 January 2012 - 11:13 PM

Was This Post Helpful? 0
  • +
  • -

#14 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 561
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: If you could have two things added to Java SE..

Posted 11 January 2012 - 10:08 PM

I see what your getting at now, and it would be useful to have something like that. I have a very faigue memory of using this somewhere before, but I cannot think where. Is this used in PHP?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1