Wednesday, August 08, 2007

Is the Java Culture changing ?

Came across a reference to this slightly old artima post through an unlikely source - a posting by Paul Graham in a discussion thread on lightweight programming languages. The weblog quotes Gilad Bracha defining Java Culture in the context of explaining why hygienic macros should not be added to the Java programming language ..
The advantages of Java is that it easily serves as a lingua franca - everyone can read a Java program and understand what is going on. User defined macros destroy that property. Every installation or project can (and will) define its own set of macros, that make their programs unreadable for everyone else. Programming languages are cultural artifacts, and their success (i.e., widespread adoption) is critically dependent on cultural factors as well as technical ones. .. Most Java developers are happy to have dedicated, narrowly focused solutions that are tailored to a specific problem. I am keenly aware of the drawbacks of such an approach, but I don't see it changing very quickly.

Does this mean lesser power in abstraction and dumbing down programmers in an attempt to get a wider audience for your language (aka Language For the Masses - LFM) ? Paul Graham, in one of his rants against OO, mentions about the pack-programming world of discipline-imposing languages being oriented to social packs.

Do you think we are going through a change in the Java Culture and that Sun has changed its position on LFM over the last couple of years ? And how much it has got to do with the Ruby (r)evolution ? We have had the whole slew of features in Java 5 and now we are talking about adding on closures in the language and tail calls and tuples in the VM ..


Ricky Clarkson said...

I'd say that the overall Java culture isn't changing, but the fringes of it are. The few Java programmers I know socially aren't aware of generics, nevermind closures.

Gilad Bracha makes a good point badly. Java allows you to write a mini-language by defining your own classes and methods - you can end up with things like persons.sortBy(age).printTo(file), etc. That kind of API is great, but possible to screw up. All you need to do is include some bad names:


In some programmer's heads, remove will actually remove old customers. In others it will act as a filter, producing a new list with only the customers newer than 10 years old. That kind of thing gives bugs.

Macros are subject to the same problem that classes and methods are - badly named macros can be very confusing, perhaps more so than badly named classes and methods. I think that a typical novice programmer would use macros badly, but I also think that is a good thing - because once they have learned how to use macros badly, they can spot their own problems and move on to using them well. Macros used well add more to a language than classes and methods can.

In short, Java plus macros would make it harder for a company to use novice programmers, but would give more rewards once those programmers had improved.

Personally I think the programmer is more important than the company.

Caveat: Smalltalkers apparently don't miss macros - perhaps using Smalltalk for a while would make me revert some of the above points.

Unknown said...

Ricky -

Do I get a strawman argument in your comment ? It is possible to design mini-languages in Java using classes, methods, fluent-interfaces. But we will always miss the elegance that higher order functions have brought to functional languages. DSLs are possible , to some extent in Java, but I prefer to call those DSLs fluent apis (as Apache Camel provides today). Java is surely not the best language to build DSLs. Any advanced language feature can be misused by a poor programmer, and macros are no exception. Sometime back Neal Ford blogged about open classes in Ruby, which also suffers from that apparent drawback of the strawman argument. To prevent such misuse u need to have policing from within the language, which Java and most statically typed languages do. Not that there is anything wrong with it! The huge community of Java is partially due to this Java Culture. I was just wondering if movements like Ruby has anything to do with the introduction of some of the exotic features in the Java platform.

Ricky Clarkson said...


I think you said the same thing as me in that comment. I would err on the side of giving programmers freedom of expression, because with some training they'll produce better code that way, and be happier.

By the way, if you are going to implement such shackles, you can do it through source analysis - it doesn't have to be part of the language you're using. That lets you turn it off easily when you realise it's retarded, too.

Guillermo Schwarz said...

The main problem I see is that Java has already been tainted with generics and @tags that render code unreadable.

Try to understand some code using generics and you will see what I mean...

What is it?

Also what is this?

void m1()

If we continue to add functionality to something that is already complex, I bet we are going to end with a langauge as complex as C++, in which you can now receive pairs of objects from a function.

I mean, come on!

C++ is a serious language or is it an scripting language?

I think we are confusing things here.

When you are doing some scripting it is ok to fail. The system underneath is prepared and has been designed for script writers to write sloppy code.

That is not true for C++ programmers.

And yet the syntac of pair in C++ makes me code more, makes the program more confusing, and is equivalent to retrofit C++ with "you no longer need to declare variables".

Non sense!!!

Because you can do that in perl or Awk doesn't mean you need to do the same in C++.

Yet compiler writers seem to have feature envy and try to pack and cram the languages we love with the features of languages we are trying to avoid.

Garidan said...

I think something changed. Now is acknowledged it's good to integrate with the native(s). Java in Open Office, Java and gnome or on the windows desktop, COM objects and Adobe Reader, flash driven by java, 3D bindings etc.
At last, java culture looked out of its borders.