Sophia

A Linked Data and Semantic Web toolkit for Rust

Pierre-Antoine Champin (Univ. de Lyon – UCBL – LIRIS)

Developers Track – The Web Conf 2020

  1. Why Rust?
  2. Why Sophia?
  3. Present and Future

Why Rust?

Rust is a system programming language
(fine-grained control)
with high-level abstractions.
(genericity, polymorphism...)

“Rust emphasizes performance”

  • statically typed compiled language
  • zero-cost abstractions

“Rust emphasizes reliability”

i.e. memory-safe, thread-safe

Handled by Rust at compile time

  • Relatively young, yet mature (1.0 released in May 2015)
  • “Most beloved language” by Stack Overflow users 4 years in a row
  • Dynamic and welcoming community
Ferris, Rust mascot

Why Sophia?

  • Teaching myself Rust
  • An RDF implementation in Rust
  • A unified API for RDF in Rust (alla RDF-JS)

Zero-cost abstraction for RDF

  • in memory / on disk
  • speed / space
  • query / update
  • thread-safe?

Present and Future

Uniform traits (~interfaces)

  • Term*
  • Triple / Quad
  • Graph / Dataset
  • Triple- / Quad-Stream

with default implementations

* currently a concrete type, but may become a trait soon

Graph & Dataset

Syntaxes

ParseSerialize
RDF/XML
N-Triples
N-Quads
Turtle🚧
TriG
JSON-LD🚧✔*

* expanded form only, v0.5.0

Performances

time to retrieve all results

What about the rest of the stack?

SPARQL
Not yet (except for Oxigraph)
RDFS/OWL
Thomas Bourg is working on a rule-based inference engine (based on Inferray)
N3
Matthias Farnbauer-Schmidt is working on Metis

Web Assembly

[Your contribution here]

Thank you for your attention

Any question?

https://github.com/pchampin/sophia_rs

Appendix


						let mut graph: FastGraph =
							parser::turtle::parse_str(some_ttl).collect_triples();

						let ex = Namespace::new("http://example.org/")?;
						let foaf = Namespace::new("http://xmlns.com/foaf/0.1/")?;
						graph.insert(
							&ex.get("bob")?,
							&foaf.get("knows")?,
							&ex.get("alice")?,
						)?;

						let mut nts = NtSerializer::new_stringifier();
						let example2 = nts.serialize_graph(&mut graph)?.as_str();
						println!("The resulting graph\n{}", example2);	
					

Sophia's generalized RDF model:

  • IRIs can be relative
  • Literals can be subjects*
  • Variables

* actually any term can occupy any role

load time
load rate
memory consumption
time for getting 1st result