Skip to content

Differences Between C# and Java driver

bchavez edited this page Feb 13, 2016 · 28 revisions

There are very few differences between the official Java and C# driver. The minor differences are outlined here:

Naming Conventions

The C# driver follows .NET naming conventions when composing and running ReQL queries. The following example shows some casing differences:

//Java
r.table("marvel").getAll("man_of_steel").optArg("index", "code_name")
                 .run(conn);
//C#
R.Table("marvel").GetAll("man_of_steel").OptArg("index", "code_name")
                 .Run(conn);

Raw Format Options

The Java driver can accept format options in runOpts when calling .run(conn, runOpts). The Java driver supports the following format options:

  • time_format: 'raw'
  • binary_format: 'raw'
  • group_format: 'raw'

The format options bypass the Java Converter's $reql_type$ pseudo type to native type conversion. For example, specifying time_format: 'raw' leaves $reql_type$:TIME JSON objects as is.

Using raw types in C# driver

To bypass the C# JSON deserialization converters and leave $reql_type$ pseudo types as is, simply declare your expected types as JObjects. For example,

JObject result = R.Now().Run<JObject>(conn);
result["$reql_type$"].ToString().Should().Be("TIME");

Internal Architecture Differences

This section mostly only pertains to contributors and driver developers.

Serialization

The only major difference internally between the C# and Java driver is the serialization and deserialization process. The C# driver uses the industry standard Newtonsoft Json.NET library. The C# Converter class is mostly used as a configuration hub for the Newtonsoft serializer where as the Java Converter class is directly involved in converting ReQL pesudo types.

Networking

Most of the networking code relies on an async/await pattern for processing responses from the RethinkDb server. The Java driver doesn't have these constructs. The internal design notes for these details are outlined here in the Internal Design Notes section.

Clone this wiki locally