Dear Open Source Santa,

by Paul Browne

Dear Open Source Santa,

Now that you have Java in your open source toy bag, can I have Duck Typing please ? It shouldn't be too hard to do, since the elves in Ruby-Wonder-Land have been making toys with Duck Typing for years. I've been a good boy all year and promise to play nicely with the .Net kids next door.

You don't know what Duck Typing is? Sorry, I forgot that you're more than 1000 years old. Little Jamie next door got Ruby last year and he says that 'if it looks like a duck, and walks like a duck , then it is a duck'. He says making the computer do more work makes it a lot easier to write programs.

My Teacher says not to be greedy, and that you're very busy making Toy Trains. She says just ask for getters and setters. You know, the boring code like 'getSomeValue()' and setSomeValue(). She says the Apache imps have been very good with Dynaforms but that writing a Java web application is still just too slow.

Rudolph will tell you that writing get("someValue") is about as cool as having a bright red nose. He would also want to put 'someValue' in one place only (the web page). Having to write config files and javabeans feels too much like homework.

Santa, I know there are other children that need changes to the core Java code more than I do, so maybe you know of an open source project that already has this.

Paul , Technology in Plain English

P.S. :I still want to keep compile time type checking to make sure I don't make any mistakes.



9 Comments

George Jempty
2006-12-04 10:15:27
"I still want to keep compile time type checking to make sure I don't make any mistakes."


Sounds like you want two wives, but I'm pretty sure polygamy gets a checkbox in the naughty category on Santa's list

Trevor
2006-12-04 11:10:04
"I still want to keep compile time type checking to make sure I don't make any mistakes."


I'm not an expert in type checking, but I thought duck typing and compile-time type checking were mutually exclusive. Can anyone elaborate on this?

cooper
2006-12-04 11:32:15
See... I have this thing...


It seems to me that both Duck Typing and (effectively) mixins could be easily "added" to Java by simply giving us the ability to create DynamicProxy classes from Objects, and not just Interfaces. It seems like such an easy add to the language, or at least to the compiler.

Paul Browne
2006-12-04 13:52:47
There is a good reason I don't design computer languages :-)


Sometimes you want ease of use (duck typing), sometimes you want stability (compile time type checking)

Neal Gafter
2006-12-06 09:40:11
Duck typing is known as "structural typing" to language theory geeks, and it means that two types are the same if they have the same set of members; it is the opposite of "nominal typing", which says that two types are the same if their names are the same.


This is completely distinct from the static versus dynamic typing dimension. You can have structural "duck" typing in a language with a static type system. ML, for example, is a statically structurally typed language.

Paul Browne
2006-12-06 12:53:32
Neil,


I stand corrected :-)


My original point is still valid : Can we make it easier to use Java , without making losing some of the safety net?


Paul


2006-12-07 05:06:51
so stop using struts already. All those config files and forms and dyna forms and other stuff you have to maintain go away, even if you don't actually get duck typing. There are other java web frameworks available to you. And you can have compile time type checking right up until you use an expression in your view template (but boy, what wouldn't I give for compile time type checking in my template expression language, although that's a really difficult problem to solve). As for maintaining beans, I'm not an IDE guy, but some quickie scripts which parse a very simple config file (not xml - too verbose) and render it into a set of .java files (interface + class) at build time didn't take very long to generate and has surely saved countless hours of error prone typing. And yes, it'll happily mix in code you can't autogenerate, too.
Paul Browne - TIPE
2006-12-07 07:14:42
There are plenty of 'legacy' projects that still use Struts 1, I think it is going to be around a long while. Struts 2 is much better in this regard, with JavaBeans instead of ActionForms, but the same basic problems remain.


The 'quickie scripts' solution always seems simple at first, but the ones I've see have quickly grown into unmaintainable monsters.

Robert Prince
2006-12-12 09:18:10
Dear Santa, please save Java from becoming a scripting language. Please. Pretty please. Annotations, enhanced for-loop, and (shiver me timbers) enums with *behavior* are bad enough. But please, if you want to script, use Python or something else that's made for scripting.