in reply to Re^5: No garbage collection for my-variables
in thread No garbage collection for my-variables

ou seem to be saying: Oh, I mustn't use this language feature, because that would make my code more efficient and that would be an optimisation and it might be premature!

No, I'm not. I'm merely saying that ... well, what I said. Everything else was interpretation from you.

Wouldn't it be great if we could actually fix the problems in the compiler, instead of work around them?

Why does Text::CSV_XS exist? Or the XS version of List::Util? Or ...

The XS version of List::Util is a perfect example of where the interface is not affected by performance optimizations at all. As a programmer I don't even know if the pure perl or the XS version is actually loaded, which is exactly how performance optimizations should be: unintrusive in terms of interface.

It drives me nuts.

Relax. Remember there's always somebody wrong on the internet.

Just like any natural language it becomes weird if you over-use a particular feature. IMHO context sensitivity is nice, but best used sparingly. It should just DWIM, but when it's used too often I have to actually think about contexts, which defeats the whole purpose of contexts.

And just like in natural languages opinions on how to best use it vary greatly, so I don't really expect to come to a consensus with you.

  • Comment on Re^6: No garbage collection for my-variables

Replies are listed 'Best First'.
Re^7: No garbage collection for my-variables
by BrowserUk (Patriarch) on Sep 17, 2008 at 08:28 UTC
    Wouldn't it be great if we could actually fix the problems in the compiler, instead of work around them?

    That presumes that this is a problem in the compiler. And I for one, don't think it is. It is a problem with education and attitudes.

    For the vast majority of Perl applications, this compiler optimisation is a positive boon. Any application that calls subroutines and methods more than once benefits from this optimisation. And the more times you call those routines, the more you benefit.

    The OP outlined a very specific scenario in which this can be perceived as a problem. His example: I've named the subroutine "init" to suggest that this is code that will only be used at the very start of a long program lifetime, which means that the long string buffer will linger around needlessly..

    For the vast majority of situations, passing scalars by reference simply isn't necessary or beneficial. But for that small set of cases when you are passing a large volume of data to a used once (or few times) subroutine, then Perl has the facilities to handle that. If people would just use them.

    It doesn't make sense to throw away the benefits in the general case, for the sake of avoiding a mildly advanced but perfectly understandable and usable technique, for the degenerate case. Especially not for the sake of a little read-it-once-and-understand-it, education. And certainly not for the sake of some CS dogma.

    Relax.

    I'm perfectly relaxed thank you. This isn't emotional frustration I'm expressing. It's intellectual frustration.

    The same sort you feel when you see some politician, when asked; "Why have you cocked up the economy?", respond with: "First let me say that since I/we came to power there is far less dog poo in our parks and 100,000 more police officers handing out ASBOs and nicking people for seat belt violations...". And never actually answering the question asked.

    It would be far better to 'fix' the modules that create the problem, for that tiny subset of all Perl code that are memory constrained, than to penalise the performance of every non-memory constrained Perl app in order to avoid the use of pass-by-reference or aliasing.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.