-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A FLOWR by any other name? #78
Comments
I know XQuery reasonably well - having studied it when it was launched, and written one or two programs - but it was not on my mind when I was designing Morel. I can see why people see similarities. The FLWOR query structure, the ability to do query optimization and therefore query large 'virtual documents' (i.e. databases), the ability to define functions. Regarding FLWOR. Putting 'from' first is a no-brainer; every query language does that these days, and the SQL folks would love to change it if they could. Morel does not require clauses to be in the rigid order that implied by FLWOR. Erik Meijer encouraged me to make it compositional, so that 'you can always add a new clause at the end of a query.' I was more strongly influenced by LINQ than XQuery. Before that, I was influenced by PL/SQL: I liked how you can iterate over a query in a cursor FOR loop, was sad that you could not write ' In LINQ you can always see where the query ends, because it is enclosed in braces. In Morel, I wanted relations and relational operators to be part of the language the way that integers, floats and arithmetic operators are part of most modern languages. I guess XQuery and JSONiQ achieve that goal - they bring their respective document models, and the operations that build documents, into the core language. That said, XQuery always seemed too focused on XML to make it as a general-purpose programming language or query language. This is mostly perception: when you see an XQuery program that is generating XML, the program looks a complete mess, and the structure of the program (including line endings) is lost in the XML syntax. And it has to accommodate baroque XML features such as namespaces and text blocks. I recall that I found XQuery patterns very beautiful. I need to refresh my memory of them. Maybe Morel's I don't know JSONiQ as well as XQuery. It isn't carrying the burden of XML's data model, and in fact JSON's data model - atoms, records, lists - has become almost the standard data model today. But Morel's data model adds algebraic data types (sum types), functions, and tuples (albeit syntactic sugar for records) and I claim that those are all useful extensions. What's in Morel that's not in XQuery/JSONiQ? Higher-order functions, functions as values, type variables (i.e. parametric polymorphism), strong typing, and Milner-Hindley type inference. Higher-order functions are important in Morel. Of course the relational operators (e.g. project and filter) are higher-order functions, but I want users to be able to use higher-order functions on relations (what SQL would call table functions) and to pass functions as values (so that the built-in relational operators are now operating on collections of functions). Higher-order functions allow us to think about computation differently: recursion, for instance, becomes the search for an efficient way to compute the fixed point of a function. In Morel you can write a program that returns an atomic value (e.g. an Morel could be extended to support XML and JSON. But probably via library functions that convert XML and JSON syntax to and from Morel's core data structures - lists, records, atoms. Bringing XML and JSON syntax into the Morel language makes programs more difficult to read for someone doing general-purpose computation. (We have made considerable sacrifices in Morel so that programmers rarely need to use types: this makes it look more like SQL or a weakly typed language than Haskell.) Thanks for asking the question. I am glad that people see echoes of languages that they love in Morel. I hope you can use Morel for some of the same things as those other languages. And that as we discover Morel's strengths and weaknesses, we continue the conversation about where to go next. |
Jeez. Youtube won't let me add a comment to my own talk. If someone is able to add a comment against https://www.youtube.com/watch?v=smUm3C5q2IM&t=2388s that points to this thread, I'd be grateful. |
Done 🙂 |
Hi Julian,
This question is inspired by this comment on your recent youtube video.
How do the goals of Morel align with / or diverge from the goals of XQuery/ JSONiQ?
David
The text was updated successfully, but these errors were encountered: