|
Re: Graceful Failure
|
Posted: Aug 24, 2005 10:31 PM
|
|
@Isaac Gouy:
> Do you think you would be more productive with languages > that provided some minimal local type inference - so you > didn't have to explain the type to the compiler in both > the declaration and the constructor? (How rude that it > doesn't listen the first time you tell it!)
I find this difficult to answer, I will explain why:
1. I don't have a lot of experiance with this type of language (some Clean/Haskell experiance)
2. There seems to be pro's and con's; yes there was less typing and it did find the type errors, but the error message were very obscure (like C++ template error messages)
3. Like Gregg Wonderley has pointed out; the typing is probably not the limitation in writting speed, so reducing typing probably has little effect. I would add particularly in a good IDE that does code completion for you.
4. Declaring types adds clarity to a program, its part of the documentation
5. Having sort of knocked implicit typing in the above points I do at times think you could reduce the typing with little or no penalty (see below)
The areas that I think you could reduce typing without much of a hit on clarity, error detection, and error messages are:
A. Make new optional, make {} optional if a body has only one line (like if, for, etc.), make method name and argument types optional if just one method is to be overriden (you still have to leave the brackets though), e.g. instead of:
textField.addActionListner( new ActionListener() {
public void actionPerformed( ActionEvent notUsed ) {
textArea.append( textField.getText() );
}
});
Allow
textField.addActionListner( ActionListener() ( notUsed ) textArea.append( textField.getText() ); );
B. Supress the constructor C++ style when a variable is declared and initialized with a constructor in one line, e.g. instead of StringBuilder message = new StringBuilder() allow StringBuilder message()
In summary: I suspect the gains would be small from implicit typing, but I am in favour of reducing the typing when there is little or no penalty in other areas.
|
|