in reply to Re^2: I dislike object-oriented programming in general
in thread I dislike object-oriented programming in general

Not so fast.

In Perl you're not really creating functions at run time (unless you're calling eval). You're creating closures. So what is really needed is to be able to create and pass around closures at run time.

C, of course, does not natively support having closures. But C does support structs, and it really isn't hard to define a struct that consists of a pointer to a function and a pointer to whatever. And then have a function to call the function pointer and pass it the other pointer. Now we have something equivalent to a closure. (Well, it doesn't do its own memory management, but let's not quibble,)

Sure, our functions that can be used that way all have to accept a random pointer to a data structure as an argument, and have to manually unpack their environment from that. It is ugly. (What do you expect from C?) But now you can use functional programming techniques in C.

  • Comment on Re^3: I dislike object-oriented programming in general

Replies are listed 'Best First'.
Re^4: I dislike object-oriented programming in general
by Aristotle (Chancellor) on Oct 28, 2007 at 18:03 UTC

    The presence of the explicit struct; the necessity of manual assignment of values (as opposed to implicit capture); manual management of the memory involved: none of these can make functional-style code so ugly as the mere fact that C’s syntax provides no device for writing functions anonymously and inline.

    Once you combine the latter fact with the faults you mention, you inevitably run into a curious equivalence. Structs with function pointers; to functions written out of line; which accept a pointer to a user data struct: does that not sound oddly familiar? It should: there is no decidable distinction between writing OO-style C and functional-style C. Both involve the exact same mechanics of construction.

    Makeshifts last the longest.

Re^4: I dislike object-oriented programming in general
by Anonymous Monk on Aug 14, 2011 at 16:40 UTC
    In assembler you can also do OOP, what you expect from assembler?