From: mordor.nospam@fly.srk.fer.hr   
      
   On 2012-01-15, Daniel James wrote:   
   >   
   > In the hands of a skilled programmer C++ is a more powerful language   
   > than C, and it will always have its following, but many programmers are   
   > tempted away to other languages because the support available from code   
   > generators, code browsing and analysis tools, smart editors,   
   > refactoring tools, and the like is better in those languages.   
   >   
   Not only this: compilation speed is also a factor. The C# compiler is   
   *blazingly* fast: it compiles AND links a 200kLOC project in less than 30s.   
      
   Unfortunately, what is widely accepted as "modern C++" is heavily   
   template-based, which brings at least two kinds of difficulties:   
      
   - Template definitions must always be parsed before they are used. This   
    goes against the idea of separate compilation and is detrimental to   
    compilation performance.   
      
   - Tool support on par with, e.g., C# is impossible to write. Take, for   
    example this:   
      
   template   
   class MyClass   
   {   
    T t_;   
      
    void mymethod() { t_.somemethod(); t_.othermethod(); }   
   }   
      
   T can be arbitrary type, and an IDE has no hope of knowing what members   
   to list when you type "t_.". C#, on the other hand, has the following   
   construct for generic types:   
      
   public class LinkedList where K : IComparable   
      
   Not only will this allow IDE to give you a proper list of supported methods, it   
   will also constrain the implementation of LinkedList methods: trying to invoke   
   a method on object of type K that is not contained in the interface(s) it is   
   constrained by will result in a compile-time error. Similarly, you won't be   
   able to instantiate a LinkedList with a type K that doesn't implement   
   IComparable interface, and you will get a sane error message at the point of   
   instantiation instead at the point of use of unsupported feature. In other   
   words, C# generics are not macros on steroids, but first-class entities.   
      
   >   
   > Tool support of that kind is harder to achieve in C++ than in, say,   
   > Java or C# because the language is harder to parse, but if tool support   
   >   
   Parsing is hard, but the main obstacle is that the template (sub)language is   
   turing-complete and provides no means of constraining possible values for   
   type-parameters. Even with concepts, you would still have the compilation   
   speed problem. C++ compilers being dog-slow, the same could be expected from   
   a hypothetical C++ IDE that would be on-par with C# IDE.   
      
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|