in reply to I heart OO

OO is ok but it isn't that exciting. Come back when you've picked up declarative programming. OO is still procedural.

Replies are listed 'Best First'.
Re: Re: I heart OO
by stvn (Monsignor) on Mar 27, 2004 at 06:23 UTC

    Declarative programming is just the tip of the iceberg!

    How about multidimensional declarative programming based on intensional logic with Lucid. Or Concurrent Distributed Progamming of Soft Real-Time Systems in Erlang.

    And who could forget our wonderfully esoteric friends, the functional programmers. I think John Backus said it all in his 1977 Turning Award Lecture, when he uttered:

    (/+) ° (α×) ° Trans.
    Which is much better than the good ole von Neumann style:
    c := 0 for i := 1 step 1 until n do c:= c + a[i] * b[i]
    But seriously FP is the bomb! Not a variable in sight.

    And nothing, but nothing matches the power, poise and sophisitcation of APL.

    PRIMES : (~RεR°.×R)/R←1↓⌊R
    (see this mess explained here)

    -stvn

    no unicode was harmed in the composition of this post, some character entites were improvised and others were changed to protect the innocent

Re: Re: I heart OO
by flyingmoose (Priest) on Mar 27, 2004 at 03:10 UTC
    Yes, exactly. Lots of people miss that, despite the inclusion of encapsulation and inheritance, a lot of OO code is essentially just changing the semantics. This of course is bad OO, and 'good' OO will make some use of the new syntax, rather than just using it as sugar. The basic conversion is (pseudocode, not Perl, not C):

    foo($alpha,$beta,$gamma); // into $alpha->foo($beta,$gamma);

    These concepts can be used to do pseudo OO in C (a non OO language by all means), whereas many think you need C++. However, you lose the encapsulation so you have to have extreme discipline in that regard (just calling functions and refusing to twiddle structure bits) and you can't leverage inheritance without using function pointers to simulate method lookup tables. It's when you start using function pointers for virtual-ness when it starts to get ugly, very ugly, so you might not have gone there in the first place. Bad!

    So, anyway, what I mean to say is that while encapsulation, inheritance, and polymorphism are viewed as basic tenets, the simple idea of "keeping data together" (i.e. C structs or Perl nested datastructures such as an HoH) are perhaps some of the most widely used -- a "non OO" OO. It quickly devolves into basic proceduralism., especially if you have already broken encapsulation with too many trivial getter/setters. Inheritance, too, is widely overused.

    What was I saying? Ah yes, as you say, it's just proceduralism by any other name -- but a HECK of a lot cleaner than base proceduralism if you want the same power and safety in your data structures.

      By the way, the (highly useful) idiom for calling a method on an object in the Linux kernel is: foo->function(foo, arguments, go, here);. (Where foo is a pointer to a structure having a function pointer named function.) Note that this is almost exactly like perl.


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).