if ((OOP + FP + AOP) == XSLT 2.0) then 'Composable Language' else 'Try Again'

by M. David Peterson

SIDENOTE: @amike: The run was good while it lasted, eh? ;-)

SIDENOTE.NEXT: After rereading the title, I'm not even sure it makes any sense. But then again, what's new? ;-) :D
---

[Post.Body]
DonXml's All Things Techie : Mixing Object, Functional and Aspect Oriented Programming


Within a DSL it would be cool if you could map its Nouns to Objects (described via OOP), its Verbs to Functions (described via FP), and its Adjectives and Adverbs to Aspects (via AOP).


I have to do some research, but does this fit within the definition of a composable language? I tried to fine a definition of what a composable language, but didn't seem to find one.


Oh, the power of XSLT 2.0 (and XPath 2.0), where you can bring together the knowledge-pool and massive underlying code base of OOP, fold in the power of Functional Programming, and weave all of it together with AOP to produce a truly composable language as a result.

For example,

8 Comments

Dan Sickles
2008-04-21 10:35:49
I like composable but the angle brackets still freak me out. But, hey, I have no problem with __double__ __underscores__ so what do I know ;-)


Scala is a nice mix of OO, FP and with mixin traits can be very Aspecty.

M. David Peterson
2008-04-21 11:14:39
@Dan,


>> Scala is a nice mix of OO, FP and with mixin traits can be very Aspecty


On the flip-side (speaking from a platform perspective), F# provides a lot of the same features/functionality as well. Of course, there's no reason you couldn't write an extension function in F# to then call that function from [pick your poison .NET-accessible] language, including (and in particular to this post) XSLT 2.0 which adds nicely to the composability layer.


All good things! :D

Dan Sickles
2008-04-21 12:13:35
F# and the DLR are almost enough to make me flip sides ;-)


Jim Hugunin's recent posts on the DLR have been fascinating.

Don Demsak
2008-04-21 13:14:50
David, yes, I should have mentioned that XSLT and XPath are composable languages (says so right in the XPath spec), which is probably where I got the idea from. But, I'm trying to go beyond XML, XSLT, & XPath and mix various languages, in the same "class" (aka the language's minimum structure), and have each one do what it does best. So, something like, using C#, F# and Ruby to create one "class". I can't see a compelling reason why we restrict ourselves to one language at a time. Which, I guess is really polyglot programming, but to the extreme.
M. David Peterson
2008-04-21 14:40:13
@Dan,


>> F# and the DLR are almost enough to make me flip sides ;-)


Throw IKVM.NET into the mix and you get all the benefits of both worlds :D

M. David Peterson
2008-04-21 14:48:28
@Don,


>> David, yes, I should have mentioned that XSLT and XPath are composable languages (says so right in the XPath spec), which is probably where I got the idea from.


Not necessarily (meaning where you got the idea...). While they are both composable languages, that's not exactly what most people highlight as their primary strength.


>> But, I'm trying to go beyond XML, XSLT, & XPath and mix various languages, in the same "class" (aka the language's minimum structure), and have each one do what it does best. So, something like, using C#, F# and Ruby to create one "class". I can't see a compelling reason why we restrict ourselves to one language at a time. Which, I guess is really polyglot programming, but to the extreme.


Oh, I absolutely agree! Between 70% of the code I write these days is C#, about 5% (though increasing fairly dramatically) is F#, about 5% in either Ruby or Python (via Ruby.NET, IronRuby, and IronPython), and the remaining 20% in XML and XSLT.


However, the XML/XSLT portion is primarily glue for all of the rest. In other words, a simple way to create logical blocks of code that bind together external components into reusable, service-oriented workflow's. But that's primarily because I prefer XSLT over most any other language, which I realize I am in the minority on. This same basic functionality can easily be replicated in a plethora of languages. *ESPECIALLY* Ruby, which facilitates a nice foundation for the creation of DSL's (e.g. Ruby on Rails)


Of course, I can't get enough of LINQ, and the introduction of expression trees in C# 3.0 has had me drooling ever since Anders provided a high level demo at the Microsoft Technology Summit last month. Talk about composability! :D

MattMan
2008-04-21 16:32:18
This is an oversimplified example ? Geez, I'd hate to see a complicated one.


I think my real problem with all of the XML based languages is the amount of noise that's required to get things done makes it almost impossible for the casual reader to get any idea what's actually going on. Based on this example, XSLT makes Perl look like sweet poetry.


I'm no Ruby bigot (in fact my favourite language is probably Perl), but it would be interesting to compare doing this same job with Ruby to see if it was more readable to lay-people. (Although given that I got lost with even the English version of what this was trying to do, perhaps not.)

M. David Peterson
2008-04-21 17:11:31
@MattMan,


>> I think my real problem with all of the XML based languages is the amount of noise that's required to get things done makes it almost impossible for the casual reader to get any idea what's actually going on.


It's a lot easier to read when you have things inside your favorite XML editor of choice, though I'll be the first to admit that XSLT isn't the easiest of languages to grok, regardless of the what tools you might have at your disposable.


>> Based on this example, XSLT makes Perl look like sweet poetry.


:D :D :D


>> I'm no Ruby bigot (in fact my favourite language is probably Perl), but it would be interesting to compare doing this same job with Ruby to see if it was more readable to lay-people. (Although given that I got lost with even the English version of what this was trying to do, perhaps not.)


The only language I think that could properly mimic this same general idea would be Lisp/Scheme/DSSSL, the latter being the foundation upon which XSLT is built upon (replace angle brackets with parenthesis and you have, for the most part, DSSSL (see: http://www.jclark.com/dsssl/ for more detail), DSSSL being built upon Scheme, which in turn is built upon Lisp.


That said, Ruby has a lot of Lisp'isms built into the language, so it wouldn't surprise me if you could pull together something similar in Ruby. Would have to think it through a bit, but it would be an interesting challenge to see what could become of it.


I'll think it through and see what I can come up with.