Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Could you elaborate a bit what you meant by "static language" versus "dynamic language"? I don't think I understand. Thanks.

I was searching for a more diplomatic term for the LFSP/LFM divide :-) Perhaps some examples will illustrate.

In an language with metaclasses you can isolate behaviour to a metaclass in a similar way to the way you move behaviour to an aspect. For example, in Python you could add behaviour to object initialisation by creating a custom __init__ method in a metaclass. See A Primer on Python Metaclass Programming for an examples.

In languages with eval() like functionality you can make runtime changes to your codebase. Perl developers regularly do code generation at compile time. In languages like Java this is impossible. Aspects give some of this power to Java.

In languages that support mixins and other forms of multiple implementation inheritance you can separate out some concerns into separate class-hierarchies.

If you have mixins, metaclasses, macros, runtime access to your language, etc. you find that you need aspects less. Many uses of aspects in languages like Java are to get around issues with Java's design (e.g. the use of AspectJ to create mixins).

This isn't to say that AOP is a useless or unoriginal concept. There is still the core difference from normal OO code in that an aspect imposes a behaviour on a class, rather than a class requesting behaviour from an aspect.

However, IMO, the arguments for AOP are less compelling when your language is more flexible.

In reply to Re^4: Aspect-Oriented Programming: Couple of Short Examples by adrianh
in thread Aspect-Oriented Programming: Couple of Short Examples by chunlou

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (7)
    As of 2018-05-27 09:00 GMT
    Find Nodes?
      Voting Booth?