Is it really a waste of time to develop an unmanaged C ++ library, which, like the .NET Framework class library, is in design and architecture?

There are many C ++ class libraries, either open source or commercial, like MFC, ATL, SmartWin ++, QT. but not one of them has the design, architecture, or cleanliness of the .NET framework class library. Regarding the idea of ​​implementing the C ++ library, which is similar to the .NET framework class library and provides developers with a wide range of functions, and, of course, the library will be unmanageable and will wrap the win32 and COM APIs

+6
c ++
source share
2 answers

Interest Ask. But I believe that this will be either a waste of time or not optimal for re-creating the .NET BCL (base class library) for unmanaged C ++. Why is this?

  • The C ++ language is very different from the .NET languages. This means that if you were to rewrite BCL for C ++, you would optimally try to make the most of C ++. This will likely lead to a rather different structure structure:

    • IDisposable and Close methods are not needed, since C ++ offers deterministic release releases and object deletion; something like using blocks, but much more general. (The relevant C ++ concepts are areas, auto-storage areas, RAII, and smart pointer classes.) Thus, C ++ BCL has the potential for more elegant design in this regard.

    • C ++ templates are very different from .NET generics. C ++ also has no delegates or events (although you could probably mimic them). With C ++, it is also easy to work with mapping and runtime and code generation. Finally, C ++ (before C ++ 0x) does not support lambda functions. This means that more recent additions to BCL are likely to look very different in C ++.

  • There are things in BCL that are out of date, or if you developed BCL today, it will turn out very differently. Take System.Reflection . This part of BCL was created before the introduction of generics. If it were rewritten from scratch today, most likely it will affect the use of generics and, therefore, the safe type.

  • As you can see, the new version of BCL in C ++ is likely to be completely different than the .NET BCL on which it is based; so you should consider whether you should even create such a new library in .NET BCL. Do you even need to have one single structure, or, in the end, is it easier to develop separate libraries? One for networks, one for abstract data types, one for graphical interfaces, one for reflection, etc.

    • Individual libraries have the disadvantage that they may not have a consistent API design. Therefore, experience with one library does not help you learn another API at all.

    • Because of this, individual libraries can be simplified. For example, you can maintain a reflection library without having to coordinate each of the activities with supporting GUI libraries.

    • Separate libraries have the advantage that you can exchange them for another if you find a cleaner, faster, or better replacement.

  • Even if someone wrote a version of BCL in C ++, long-term support for such a library would require a lot of resources, especially if you think that it should be platform independent. Microsoft has this potential and these resources. You too?

The bait of one large library for everything is, in fact, the sequence of one API and the fact that "everyone" will use it. But I think that even if you wrote such a C ++ BCL, it will be difficult for you to reach almost every C ++ programmer and convince them in your library.

+4
source share

I assume: What do you like C ++ for performance reasons. What do you like about .NET for performance reasons.

You can try, but in the end, you will notice that C ++ will not provide language constructs in managed languages ​​(functions like delegates, native interfaces, variance, lambda expressions, LINQ, etc.), you can imitate , but it will not look clean, as you see in C # (you will need an ugly preprocessor, and you will get critical code that will not help code refactoring and other mantainance tasks).

You can check 2 alternatives:

  • An alternative to using D (new language) . D is inspired by C ++ performance and Java or .NET performance. D compiler for native code, not a set of virtual machine commands. But you need to remove many editor tools, such as Visual Studio Intellisense, and there is already a base library of the standard class.

  • Or you can use AOT (ahead of time compilation) or NGEN (native image generation) . Compile .NET bytecode into native code. But he has some limitations.

In both cases, you get a modern language designed for performance and better performance than the original .NET platform without the cost of implementing your own C ++ BCL.

0
source share

All Articles