Re: "The biggest advantage of X is the fact that it has automatic memory management." - Joel Spolsky
I think the problem with C++ is we don't have enough ready made
libraries. This process has been blocked by those group of people who
are just concerned about runtime efficiency.
For example publishing a new Boost library is so time consuming that
people don't publish their work.
My organisation cares a lot about efficiency however, the problem is
simply being able to do the job weather efficiently or not. Doing the
job is better than not doing it at all.
[example
extern const struct gc_collected_t{} gc;
extern const struct gc_traced_t{} gc_traced;
void* operator new(size_t s, const gc_collected_t&) throw(bad_alloc) {
if(void* p = gc_malloc(s)) return p;
static bad_alloc excep; throw excep;
}
void* operator new(size_t s, const gc_traced_t&) throw(bad_alloc) {
if(void* p = gc_malloc_uncollectable(s)) return p;
static bad_alloc excep; throw bad_alloc excep;
}
void operator delete(void* s, const gc_collected_t&) throw() {
gc_free(s);
}
namespace {
template<typename T> class gc_allocator;
template<typename T> class gc_traceable;
template<typename T> class gc_auto_ptr;
}
#include <iostream>
int main(int argc, char** argv)
{
for(int i=0;i<1<<20;i++) {
gc_auto_ptr <char*> memory(new (gc) char[511]);
if(!(i&(i-1)) std::cout << gc_heap_size() << std::endl;
}
return 0;
}
example]
I had to research for few month to setup a good garbage collected
environment in C++.
Since the process of publishing a library for C++ is not as easy as
patching something and showing it to a project maintainer; something
like Python, my organisation will be the only organisation that will
use the garbage collection library.
If someone else is looking for the same thing they have to reinvent
the wheel. This means that overall everyone is less efficient;
spending most of the time that could be use to make an existing
library better is actually spent creating the same library with almost
exactly the same features.
I think C++ needs a unified runtime environment. A runtime environment
that doesn't have to be used by those who don't need it, but is there
for all the others that they do.
-- Kasra
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]