# Tools Review solid-client and RDFlib
The data behind a **Solid** Application is called Linked Data. You can read more about that [here](https://www.w3.org/wiki/LinkedData). While there are many ways you can interact with the data in your **Solid** Pod, this blog post highlights two libraries. (we can link here to blogs to other ways...)
One from Inrupt, called [solid-client](https://github.com/inrupt/solid-client-js). This is used in the [PodBrowser](https://github.com/inrupt/pod-browser) an application that can be used to view your contacts, bookmarks, as well as the files you have stored in your Pod. This library attempts to simplify the concepts and make it easier to use for Application Developers who are just starting to learn about Linked Data.
The second is one of the originals [RDFlib](https://github.com/linkeddata/rdflib.js). This is the library used in [SolidOS](https://github.com/SolidOS), and while a bit harder to understand for those who are just beginning their Semantic Web journey it has much more packed in to harness the power of Linked Data.
## Authentication
Before getting into the data libraries, it should be mentioned that you will also need an authentication library. Right now the best one to use is [Solid Client Auth](https://github.com/inrupt/solid-client-authn-js). There are two different libraries you can use depending if you are writing client or server applications and both are mentioned in the library above. In order to read and write private data you will need to make sure the user is authenticated.
## solid-client
When you are working with the solid-client library one of the biggest things to get your head around is something called a Dataset. ...
https://github.com/inrupt/solid-client-js ... Docs are here https://docs.inrupt.com/developer-tools/javascript/client-libraries/structured-data/ ..
1. Explain what a dataset is and how it is used.
2. How do you read and write the data in the dataset.
3. What are the steps to get something working read, write... explain this with an example
4. What are the advantages to use solid-client
Code Example: bits taken from pod-browser and tweaked.
Explain.. what is a responder, why do I need it.
Explain my data... but just point to another document that does this...
explain getResource
etc... explain what the code is doing and any detail around it that is important.
```
export async function getAddressBooks(fetch) {
const { respond, error } = createResponder();
const addressesIri = joinPath(CONTACTS_CONTAINER, ADDRESSBOOKS_INDEX);
const { response: addressesResponse, error: resourceError } = await getResource(
addressesIri,
fetch
);
if (resourceError) return error(resourceError);
const { dataset } = addressesResponse;
const addressesThingUrl = `${getSourceUrl(dataset)}#this`;
const addressesThing = getThing(dataset, addressesThingUrl);
const iris = getUrlAll(addressesThing, vcardExtras("includesAddressBook"));
const addresses = iris.map((iri) => {
const addressThing = getThing(dataset, iri);
return {
iri,
name: getStringNoLocale(addressThing, vcard.fn),
};
});
return respond(addresses)
}
```
## RDFlib
RDFlib is a powerful set if tools for not just dealing with RDF and turtle,
but also reading and data to and from the web, and syncing your app when
the data is changd by other apps or other users. There are three level of power you can invole with different leves of store. They all store quads - in other words they keep track of where the RDF facts, triples, each came from. This is important when you want to bring multiple pieces of data together.
- Store is a quadstore which in load and dump data in many wasy, and can be queried
- OnlineStore is a Store which also has extra power - to read and write data from the web.
- LiveStore is like OnlineStore but also has the ability to send small changes from your app and to coordinate them with changes coming the other way,
### LiveStore
You should almost certainly use LiveStore for your app. A typical thing to do it to create one LiveStore for the process, which acts as a cache of the data in the web. That way any request for data which has already been fetched will be returned from the cache immediately without waiting for the network and the server.
The way SolidOS uses LiveStore, there is one for the whole client process. One cache of the data web across the process. This is important because when you write you code in functions like thngs to make a meeting, render a meeting, find yor addressbooks, display icons of people in the meeting, etc, if you do it naively those functions all end up loading the same solid document again and again. if you fix that by making app-level caching, having plain old JS objects where eyou keep everything you have read as a app-level cache, that’s a lot of work, lots of code, and you probably will be ineffective because you will miss some things, and also you will make classic cache mistakes .. using an out of date one etc. Instead, if you use rdflib as we do, with a process-wide livestore, it will do the caching automatically and you can just write the logic of the app.
### Fetcher and Update Manager
The functionality of the fetcher allows you to do all the web I/O with functions of the fetcher — and esp. the update-manager. Normal RDF libaries, especially the standard API, has none of thos fnctionality. So you have simple functions for things like ‘make this change to this documents’ and ‘call me whenever this doc changes’. The nice thing about that last thing .. setting a listener for changes — s that it leaves RDFLIB to worry abou the upgade from the old protcol to the new ne fro example — your code stays the same.
### Performance
The standard RDFJS library is designed for parser writers, not for users, not for developers who use it. So it is designed to be as fast as possible rather than to be easy for users to understand. And we have simple methods like x.doc() x.dir() etc whcih are handy for moving between a thing and the doc its data is stored in, the folder the doc is in, etc. And our store has not just match() but also things like each and any which are more intuitive to use and more powerful, so you end up writing fewer lines of code.
1. Explain what rdflib is.. a bit of history and point to https://linkeddata.github.io/rdflib.js/Documentation/webapp-intro.html
2. Explain how to read and write data
3. Show the same example from above in rdflib
## Comparison
The library you select really depends on what you are trying to accomplish and where you are in your journey. At the end of the day any library interacting with Linked Data is backed by the HTTP protocol. Both libraries can take some time to understand how to work with the API, but if you are just starting out and do not have a serious Linked Data application idea in mind it will be easier for you to start with the solid-client library. What do I mean by serious Linked Data application... this I will need to explain in another blog post, but I'm talking about leveraging the power of Linked Data in your applications. This is something I am exploring myself and at the heart of this exercise.
RDFlib, as mentioned previously was built with the intention of getting the full power of Linked Data.
Some additonal things you get when you use it are completely flexible searching (e.g. find all triples with predicate X), the possibility to run sparql against the store, serialization into multiple formats, querying across multiple sources at once, and easy access to request data (headers,etc). If you want to see what Linked Data is really about and you don't mind taking a bit more time and enjoy the learning process you should really try it out. Another blog post to come about how to use all the cool features.
## My Journey
One of the big things I struggled with was the concept of a Dataset and a LiveStore. Having come from SolidOS where we use LiveStore, but in a vanilla Javascript application, I wasn't sure how to translate this into the React world. I wanted to use React because it is faster for me to implement my idea.
will add more as I go...
### Questions to clarify or research
1. Confirm if dataset is the same as a LiveStore
2. How is rdflib different from solid-client.. nowOrWhenFetched() is it true that you can follow data easier. need to ask or confirm.