by cronjobber · 9y ago · 0 comments
So I added a mandatory file header to the language which (amongst other things) specified the language version.
I thought this was a win... with one exception that would have bothered me a lot if this had been a language intended to achieve world domination:
Mandatory version headers totally ruin your "hello, world!" comparison chart story ;-)
Once, when the C standards committee was struggling with the semantics of "main" under Windows, I suggested that "main" not be part of the language at all. You would include <unix.h> or <posix.h> or <dos.h>, and get "int main(int argc; char *argv[]);" as a prototype, which you must define. Or you include <windows.h>, and "int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);" is the function you must write. The runtime pulled in would call the appropriate function. "main" would no longer be a special case. This was generally agreed to be the correct solution, but too upsetting for beginners.
1) Code written against a compiler should continue working
2) New code should be able to use new features and not pinned to an old compiler
3) The language / compiler should be allowed to innovate w/o maintaining strict backwards compatibility for all past code.
I am personally ok with and support having any large scale, long term project require multiple versions of the compiler to build.
Or even better, have every compiler support all versions of the language. It obviously requires some careful architecting to keep it maintainable, but that's better than every user of the compiler having to sort out versioning issues themselves.
Edit: I've re-read your comment, and I can't tell if we're in agreement or not :)
If having an interface that looks like the compiler do this, I am fine with it, but a single codebase ... not so sure. Large systems collapse under their own weight, having to support all versions when the current-4 already supports it seems kinda ridiculous.
The idea is that each version would still be translated into a common internal representation pretty early on after parsing, so it would almost be like supporting multiple versioned mime-types in a REST API.
And it's probably harder to do with languages that already exist, but if the spec is defined from the start with versioning in mind, then it might not be so difficult.
E.g. the LLVM IR representation takes that route, though admittedly it's not really intended for humans to write.