3 ms·
For those of us hazy on the AOP concept... Is it an artifact stemming from restrictions of static languages, or would it be a valid concept with dynamic languag
by fulafel 7y ago
For those of us hazy on the AOP concept... Is it an artifact stemming from restrictions of static languages, or would it be a valid concept with dynamic languages too?
- brabel 7y agoIn the dynamic languages world this is done with monkey patching. If you invent a declarative way to monkey patch your code, you've got AOP as done in Spring.
- sgrove 7y agoI believe emacs lisp's advice system is an AOP system in a highly dynamic language, and doesn't make much use of monkey-patching. Advice/AOP is a pattern that can fit (if you want it) in dynamic language as well.
- fulafel 7y agoWhat about this Clojure library? https://github.com/technomancy/robert-hooke https://github.com/technomancy/robert-hooke
- mping 7y agoDon't forget AOP can work on top of compiled classes, not sure I'd there is an equivalent in python or ruby.
- rclayton 7y agoI don’t thin AOP is specific to static languages. From my understanding, the “aspect” part implies the ability to “hook into” and extend an application at specific “cut points”, which are typically pre/post function/method calls. This is done in Java by modifying byte code to insert proxies. I imagine something similar could be developed with other languages. It might just be easier to do in Java because the type signatures are static.
- louiskottmann 7y agoIt is very close to python's @ syntax on top of methods definitions. Like: @get('/posts') mymethod ...
- _ZeD_ 7y ago? no, it's not. look at https://python-aspectlib.readthedocs.io/en/latest/ https://python-aspectlib.readthedocs.io/en/latest/ for an example of using aspect with python
- louiskottmann 7y agoDecorators and AOP are very similar concepts in my opinion then, if you prefer.
- lmm 7y agoPython decorators are a (limited) form of AOP: they let you transform functions in-place to implement cross-cutting concerns. Aspectlib allows you to do a more intrusive form of AOP.