Sunday, May 27, 2007

Shackles of Compatibility

indicator light
The Shackle of Compatibility means you can never recover from mistakes in language design.

Well, I don't think so. If you do an incompatible feature you could just make it possible to enable and disable it. For example the newest rage amongst Java programmers is to declare every variable and parameter final. This is intended to catch accidental (as opposed to purposeful) variable reuse, which is a good idea.

But it is questionable whether sprinkling the source with final isn't too high a price. Ok, you can't just change the language semantics to have final be the default. But, why not make it switchable? Add something like pragma "default_final_vars";, and enjoy the best of two worlds. Old code stays as it is, new code can be not cluttered.

Similarly, any language could make the subversion or misfeatures selectable.

Of course there is a drawback as you must be aware which dialect is in use. But you need to do that anyway since many of the mainstream languages look pretty similar to each other.

1 comment:

helium said...

Uhm ... Imagine you open some files, one starts with

pragma "allowThis";

the next with

pragma "forbidThat";

the next with

pragma "enableWhatever";


while every file contains code written in the same language the same statements would have different meanings in every file. And as the language evolves it will get more and more pragmas. Old parts of a project might be written in a completly different style than newer parts.
Nobody can maintain that.