Writing decent indentation for a major mode is very hard. You need a non-trivial performant parser. I dare not look at perl-mode or C++.