5 ms·
Every time you use CSS, you're doing Aspect-Oriented Programming
- sosuke 17y agoAwesome! Another buzzword bingo card to put in my resume: "Proficient in Aspect-Oriented HTML/CSS Programming"
- kalid 17y agoI thought this was a great analogy. One of my favorite teaching techniques is to introduce a new concept as a variation of something you know, vs. presenting it in an vacuum.
- jonnytran 17y agoAgreed. Analogies can open the doors in someone's mind. The hard part, though, is coming up with the analogy. If your goal is to teach something, it's hard to come up with one that people can relate to.
- RyanMcGreal 17y agoI had the hardest time trying to grok Lisp in any capacity until I read a great essay that explained it in terms of XML. http://www.defmacro.org/ramblings/lisp.html http://www.defmacro.org/ramblings/lisp.html
- mahmud 17y agoSome say XML is Lisp in drag. I think it's more like a fat-suit.
- mortenjorck 17y agoAre there any general-purpose languages that actually follow an aspect-oriented paradigm? Would such a language even be possible or desirable?
- jerf 17y agoJava has some add-on libraries that do it. It's hard to judge whether it's a good idea there because Java's OO is so brain-dead by design that it's hard to tell whether a technique is truly good, or just offsetting Java's utter simplicity. (By "by design", I mean that Java chose its simple model; it is by design. It is so simple that it is very difficult to use any sort of sophisticated programming technique without serious external libraries or immense class hierarchies.) Many other languages have things that are very similar, certainly more "aspect oriented" than CSS. Lisp can do this very easily, and emacs uses something very like it a lot, complete with similar terminology for "advice". Ruby and Javascript's monkeypatching can be seen as something very like aspect oriented programming. Writing your own aspect system is pretty easy; I've got something in work in Perl that actually has things called aspects, for instance. In each case, pedants will justifiably point out that they aren't actually "aspect-oriented" according to some strict definition, but I've sworn off caring about whether something meets a strict definition unless you can show me at least one scientific study of reasonable scope that verifies that things meeting a particular definition are good and even small deviations from the particular definition show noticeably worse performance. (See also: arguing about exactly what the "unit" in "unit" test means as if it actually has any actual force behind it.) I will say that each of them shares enough similarities that it crowds out the full technical definition of "aspect oriented". It's not a coincidence that the term became large in Javaland. See also "dependency injection", where what was common practice in other languages actually grew a pattern name in Java because it's so much harder you have to do it deliberately, instead of accidentally like you can in better languages. (Yeah, I will cop to thinking Java is a very technically weak language, in the sense it takes reams of code to do anything useful from a design standpoint. That doesn't mean it's bad, but it does mean I personally don't like it and I do not apologize for my personal preferences.)
- jonnytran 17y agoI think a better question would be, do any languages have features that help _you_ follow an aspect-oriented paradigm? At the end of the day, you can use just about any paradigm in Java. By no means does it enforce OO. Ditto for just about any other language. But certain features make it easy to use OO, so when using it, you feel compelled to use that paradigm. Do any languages make it easy? Ruby, for example, allows it. But it feels like it was never intended. Someone actually just posted about this on HN: http://cfis.savagexi.com/2007/09/05/rails-unusual-architecture http://cfis.savagexi.com/2007/09/05/rails-unusual-architectu...
- Flemlord 17y agoGray on black, eh? Great place to plug Readability: http://lab.arc90.com/experiments/readability/ http://lab.arc90.com/experiments/readability/
- deleted 17y ago[deleted]
- jared314 17y agoSo, AOP is applying a function (CSS styles) to objects in a graph (DOM), all selected by a query (CSS selectors)?
- achille 17y ago"applying a function to objects in a graph" implies something like: bold(element) and center(element) which yields: <bold><foo /><bar /></bold> <center><baz /></center> CSS Selectors can be applied a number of ways (id, class name, parent class name etc) And they can be modified without touching the source HTML. But yeah, that's what AOP is: You specify a function that can be dynamically applied to various pointcuts.
- fforw 17y agoIt's more like Aspect-Oriented Styling, because CSS is seriously lacking programming constructs. No variables, loops, conditions etc.
- vdm 17y agoWhat about JQuery, which uses CSS selectors everywhere?