Hacker News new | past | comments | ask | show | jobs | submit login

[deleted]



There's nothing unusable about it (by definition). But wouldn't:

    \(Integer i1, Integer i2) { return i1.compareTo(i2); }
be nicer? (or whatever else syntax) Redundancy is already pretty common in Java and the current syntax just seems to try to win the price for most redundancy. You're implementing one interface, which you can infer in most cases with one function which you already know, which returns one result you already know the type of. So why would I want to repeat that?

Sure - you can use the verbose syntax when you have many methods, but this example could be cut down to one line. Less line noise -> less errors.


Compare that to how you would do it in C# (note that's not how you do comparisons specifically, this is just to demonstrate the C# lambda syntax):

  list.Sort((i1, i2) => i1.CompareTo(i2));
Isn't that an awful lot more readable / usable?


Yes, actually, while I was editing, I was going to mention C# delegates and new lambdas (I've been using C# 2.0, haven't upgraded yet). In my opinion, C# has been the better Java for a while; I think they should just copy C# stuff since it's already been proven to work and has some nice properties/syntax. It's not like C# didn't copy from Java in the earlier days...




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: