-
Notifications
You must be signed in to change notification settings - Fork 12
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
No Node interface? #159
Comments
But why? What tangible benefit would this bring? |
The benefit of a super-type would be that you could substitute a URI resource with a blank node and that would not require any changes to the code. More specifically, consider I want to implement SPIN API in JS. The base class of the model is Command, which extends Jena's Resource. Now, in RDFJS, which interface do I use as the base - |
RDF4J has exactly the same concept of Resource:
|
The benefit of a super-type would be that you could substitute a URI resource with a blank node and that would not require any changes to the code.
It’s JavaScript; we already can.
|
OK cool. And what about subclassing? |
Up to the implementer; no superclass relationship is imposed (but it can be used). Add your own Node in between if you wish to; doesn’t break contract. |
I'll see if this works out. To flip your question: what is the benefit of diverging from the RDF model used in major RDF frameworks? |
We follow the RDF spec, and leave the freedom to follow other frameworks up to the implementers. Our spec does not impose any superclass relations, not even to Term. |
@namedgraph would you ever create instances of Please also keep in mind that applications have to rely on |
No, instances of |
But that interface would not have any different methods than
They have that. |
Or phrased differently: name one thing that would be in |
I need to look into some (code) examples then. Are there any? How would RDF/JS
Any boilerplate would be candidates for new methods. What happens if I change |
I'm confused; are we talking here about JSON properties (= JavaScript object keys), or RDF properties (= predicates)?
You would be operating outside of the spec, as Node is a read-only interface. |
Updated comment |
These operations would be on the level of Dataset (https://rdf.js.org/dataset-spec/). |
#81 has strong support to define those instances as immutable |
Right... coming from Jena, this looks inconvenient to me as well. First of all, no Second, no
vs
Which one reads better? TL;DR I think graph- and resource-centric APIs are lacking. |
Rightly so, because they are different worlds. The question we asked ourselves is rather: what is a common way to work with the main elements of the RDF specification in JavaScript?
I honestly do not know the above answers. Also, note that this is the low-level interface. These are the minimal primitives we are agreeing on for interoperability. Feel free to build any higher-level interface that implements |
Re. the methods, it's all in Jena's javadoc for OK so I'm getting to my point :) If I was about to build a higher-level resource-centric interface above
That's why I'm saying Maybe some JS loosely-typed magic will allow to work around this, but I think having higher-level APIs in mind, the need for a common |
vs https://github.com/simplerdf/simplerdf
I bet @bergos will update it to use implementation of https://rdf.js.org/dataset-spec/ which should allow you to also build your proposed interface on top of it.
Just to clarify do you refer to actually using |
@elf-pavlik there's no code yet :) I'm looking into how to port some of my Jena code to JS in a painless yet standard-compliant way. I guess simplerdf is more like what I'm looking for. Too bad if it's not RDFJS compatible. Note that Jena also has low-level |
And what I'm saying is: implement Nothing in the spec stops you from having a |
If you look at reference implementation, it doesn't even have need to implement BTW If you prefer some notion of strong types, #129 has links to TS definitions which you can find useful. |
@namedgraph do you have any new input to this conversation or you think this issue can get closed? |
Someone clarify for me, isn't this what a I assume we call them Terms because Node would get confused with a DOM |
|
Yeah, then I'm not sure what benefit we get by creating a common superclass out of BlankNode and NamedNode. Recall that a BlankNode can also quantify a Literal, too! So it would probably be misleading, at best, I think. Is my assumption correct, that we call it a |
First time I hear that argument, so probably no. More likely to come from the RDF spec:
|
@RubenVerborgh Ah yes, of course. In RDF Interfaces it was RDFNode, but RDF 1.1 wasn't a thing then. |
@elf-pavlik nothing more from me |
I think it is a shortcoming that
NamedNode
andBlankNode
do not share a common super-type, which would make sense to callNode
. Even the naming indicates that there should be one. Blank nodes and resources are the same except how they are labelled, no?It makes it difficult to port code from Jena, which has such type hierarchy:
RDFNode
Resource
isBlank()
means bnodeisURI()
means URILiteral
The text was updated successfully, but these errors were encountered: