[OSM-dev] Re: osmeditor2 to Java, and a common Java OSM client library

Ben Gimpert ben at somethingmodern.com
Tue Jun 6 12:41:27 BST 2006


On Fri,  2 Jun 06 @02:40pm, Immanuel Scholz wrote:
> Hi,
> 
> > Here's a classic example:  Write a bit of code "foo" that takes a number
> > n and returns a structure that -- given an argument i -- returns n
> > incremented by i.  Just *try* to do that in less than 15,000 lines of
> > Java!
> 
> Well, I'll do it in 14,994 lines less as you estimated:
> 
> class Inc {
>   private int n;
>   public Inc(int n) {this.n = n;}
>   public int inc(int i) {return n+=i;}
> }
> public Inc foo(int n) {return new Inc(n);}

Ah but you cheated a little!  ;)  You also need all that skeleton code:

class Inc {
	private int n;
	public Inc(int n) {this.n = n;}
	public int inc(int i) {return n+=i;}
}
public class Wrapper {
	public Inc foo(int n) {return new Inc(n);}
	public static void main(String[] args) {
		Inc inc = new Wrapper().foo();
	}
}

> Including certain constructs (functions beeing first-level objects, inline
> function declaration) in the language specification is not always a good
> decision, since it make the language itself more complex.

It only makes the language more complex if the language is built on a
flawed assumptions.  If you're willing to establish design rules like
"everything is a method call" and "nothing is a primitve," the language
is actually much simpler.

> For ruby however, lambda's is a good thing! ;-)

HAIL LAMBDA!

		Ben





More information about the dev mailing list