|
Just to point out some other things a lecturer once told me about GC's that I found to be interesting.
A GC does not always mean that an application will complete its task in a greater time than using manual memory management.
When you manage your own memory you have to essentially call malloc and free or new and delete. These operations have quite a bit of overhead, especially malloc and new. Apparently allocation of memory on a managed heap can be considerably quicker than on a conventional heap. I am not sure the reason for this though. This means that it could be faster to new up an object in C# than it is in C++.
When the GC decides its time to collect it is not necessary a lot slower than doing manual frees or deletes. There are various types of GC's. They type used in the JVM and .net is a Generational GC, which is quite complex and is a relatively slow type of GC. This all means that the combined time for memory allocation and deallocation in .net or the JVM is probably similar to conventional memory management.
So put simply the time for a malloc + a free is roughly equal to the time for a C# new and a .net GC sweep for an object.
The advantage is that you should never be able to have a memory leak which is a major plus. The only major issue is the non determinate nature of a GC. You just cant tell when it will run. If it runs as a user interacts with a GUI for instance it can seam that the program is very slow. But if you look at the whole program running as a whole there should be no major performance drawbacks to a GC.
On the KISS and RAD argument, I think that RAD tools make development much easier and faster. In the .net world the level of abstraction is raised so that complex programs can be written in a much simpler way. A simple example is a simple GUI app. In C you need to have quite a bit of code just to set of a window and a few controls. Then you have the message loop and event handlers to write. This is simple to do if you understand it but it is a waste of time. In .net all you need is a class that inherits Form and then you have a window. Events are handled by delegates which are incredibly simple to use. It is IMO simpler to understand a C# GUI app than a C GUI app using Win32. As a programmer I do not care how .net sets up the GUI and the underlying system to make my window and controls, as long as makes me more productive. So in this case KISS and RAD to go together.
|