Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Garbage Collection Considered Harmful

Name: Anonymous 2014-04-02 2:24

Name: Anonymous 2014-04-02 2:58

John Goblin apparently doesn't know about inlining and escape analysis.

Unfortunately, neither do the implementors of most programming languages.

Name: Anonymous 2014-04-02 5:50

Good article. GC is shit. But MMM is shit also.

So let the compiler do it, not runtime!

Consider these examples:

in Java

Integer i = new Integer(1);
// do something with i and forget about it


in C

int* i = malloc(4);
*i = 1;
// do something with i
free(i);


in C++

int i = 1;
// do something with i and forget about it


Now, I guess many C-hackers come yelling here how the C is obviously the best and fastest here and easiest to read and understand since no magic happens. But if you think about, it's the C++ that's really brilliant here.

In Java example, garbage collection handles our memory. In C example, we run much faster since there is no GC, but we have to free the memory ourself. Now, bot Java and C use heap memory for storing the variable. In C++ example, there is no GC and we still don't have to free the memory ourself! How is this possible, you ask? It's because the compiler decides when our variable goes out of scope and frees it for us (C++ supports RAII). As an extra, there is no heap memory allocation here, so it is both faster and safer than the C example. I would also claim that the C++ example is easier to read than the C-example, even though there's quite a lot magic happening there.

Name: SEPPLES 2014-04-02 6:06

THE READABLE LANGUAGE

Name: Anonymous 2014-04-02 6:34

>>3
Then you save a reference to something allocated that way and the entire model collapses horribly. RAII isn't bad, but it's not the silver bullet to memory problems you make it out to be either. Otherwise, we could just allocate everything on a giant stack.

Since we are talking about memory and GC, is RAII actually a viable approach for Scheme (or at least parts of it), with continuations blocking many popular optimization techniques?

Name: Anonymous 2014-04-02 7:02

>>5
Since we are talking about memory and GC, is RAII actually a viable approach for Scheme (or at least parts of it), with continuations blocking many popular optimization techniques?
That would actually be an interesting research subject. How efficient can a static analyzer be in the presence of (delimited) continuations, for the purpose of determining object lifespan?

Name: Anonymous 2014-04-02 10:30

>>3
I'll play the C advocate here, for a moment. How is this

void foo(void)
{
struct bar a_bar;
make_bar(&a_bar);
[...]
}


inferior to C++'s

void foo()
{
bar a_bar();
[...]
}


? The only answer I can come up with right now is ``In C, you would have to manually call a destructor, if you wrote one'', which isn't too exciting to me, but might be to others. I really ask because the example implies C++ is doing something with memory allocation and/or scoping that C can't beyond destructors, and I'd like to know what that is.

Name: Anonymous 2014-04-02 16:35

>>3

Actually, most implementations of Scheme allocate everything on stack. It is just happened that stack became the first generation of garbage collector, because x86 CPU are optimized for stack execution.

Name: Anonymous 2014-04-02 22:57

>>3

You aren't wrong, BUT FOR GOD FUCKING SAKE, use a actual meaningful example next time.

No, really, FUCKING INTEGERS? WHICH ARE STACK-ALLOCATED BY DEFAULT IN ALL THESE LANGUAGES?

Name: Anonymous 2014-04-02 23:38

All these stack bois (and I'm even one of them). I wish Mr. Calculus were here.

Name: Anonymous 2014-04-03 4:26

Everything is considered harmful actually for which a circumstance exists when it can hurt you. Because under such circumstance whatever is that thing it can hurt you. The most harmful thing actually is life, because it is going to hurt you: it is going to kill you. For the last part no spoiler intended.

Name: Anonymous 2014-04-03 13:35

>>11
That's just definition fiddling. To show that everything is considered harmful, we at least have to construct a case for which it can hurt us.

Luckily, that's trivial. Consider the case where you are taken hostage by tdavis, who will execute you unless you can disprove the [non]existence of X, where X is the thing we wish to prove harmful. There may be many obstacles in the way of such disproof, but certainly X's [non]existence is one of them, and so can be considered harmful to you by extension.

That takes care of every X except, perhaps, statements that lead to paradoxical statements (as has been so eloquently demonstrated a few threads down). In that case, replace tdavis' ultimatum with a demand for proof that the language in which that statement was phrased contains no paradoxical statements.

Name: Anonymous 2014-04-03 22:42

[/b]Atheism Considered Harmful[/b]

Name: Anonymous 2014-04-03 22:43

woops

Name: Anonymous 2016-07-12 14:50

>>3
Isn't "C++ style" also possible in C?

Name: Anonymous 2016-07-12 15:13

502 Bad Gateway
nginx/1.10.0 (Ubuntu)

Name: Anonymous 2016-07-15 18:51

>>2
Escape analysis is unnecessary. Allocate everything on the stack and evacuate to the heap if necessary.

Name: Anonymous 2016-07-15 18:54


Don't change these.
Name: Email:
Entire Thread Thread List