I've been programming Java since the Alpha days and it is getting to the point where all the extended syntax is a bit outrageous.
The real problem is that most of these extensions are required to make Java more powerful, certainly generics / templating was a huge boon. But examples like the above make my eyes hurt.
I suppose my question is whether you can add all the features that make functional languages powerful while also retaining static typing. That's what Java is trying to do. In same cases the type safety is a huge boon to building a large system with many people working on it, in others something more dynamic allows you to be far more productive. I'm not sure you can have both and still have code anybody wants to write.
I haven't played much with Clojure yet, not sure if that is the best of both worlds.
Of course you can. Look at Scala. (And on other platforms, F#, ML, and Haskell.)
How would you 'clean up' generics syntax in Java?
Map<String, Map<String, Map<String, Map<String, String>>> > meta_data = new LinkedHashMap<String, Map<String, Map<String, Map<String, String>>> >();
....
for (Map.Entry<String, Map<String, Map<String, Map<String, String>>> > schema : meta_data.entrySet()) {
I really would rather just type: meta_data = {}
....
for schema in meta_data.iteritems():EDIT: link to better article
new Ext.Panel({
width: 400,
height: 400,
title: 'Pie Chart with Legend - Favorite Season',
renderTo: 'container',
items: {
store: store,
xtype: 'piechart',
dataField: 'total',
categoryField: 'season',
//extra styles get applied to the chart defaults
extraStyle:
{
legend:
{
display: 'bottom',
padding: 5,
font:
{
family: 'Tahoma',
size: 13
}
}
}
}
});You're example Java declaration doesn't seem to actually capture the Javascript code you've got there - ie each initial string does not map to another Map - in some cases it just maps to an integer or string.
By the way - I totally agree that the declarations of stuff in Java with generics is way too verbose.
Bottom line: Java seems dated.
Now, to my rant.
import java.util.*; interface Sortable<T, U extends Comparable<? super U>> extends List<T> { void sortBy(Extractor<? super T, ? extends U> e) default Impl.sortBy; static class Impl { public static<T, U extends Comparable<? super U>> void sortBy(Sortable<T, U> sortable, final Extractor<? super T, ? extends U> e) { Collections.sort(sortable, #{T a, T b -> e.extract(a).compareTo(e.extract(b))}); } } }
I HATE this code. This is an example of when Java went downhill to me and started to get really, really ugly. I always thought Java was verbose, but with generics and others things it started to get ugly. That was enough for me. I knew Python and Ruby and decided to go a different way. Found Erlang and Clojure started to mature on the JVM. Bye bye Java.