PitchHut
Log in / Sign up
Xfer
46 views
A flexible and strictly-typed alternative to JSON.
Pitch

Xfer is an experimental data-transfer language designed to be a more flexible and strictly-typed alternative to JSON. With features like nested elements, comments, and strict typing, Xfer aims to improve data serialization while remaining open to community contributions and enhancements.

Description

Xfer is an innovative data-serialization language designed to provide a more flexible and strictly-typed alternative to JSON. Currently in its experimental phase, Xfer aims to enhance the way we manage data structure and type definition with several advanced features, including:

  • Nested Elements: Xfer employs a unique syntax using angle brackets and specific marker characters for nested elements, allowing for clear organization within the data structure.

    <//This is how a comment </can contain another comment/>, //>
    <"""and a string can contain <""another string which <"contains another string">"">.""">
    
  • Comment Support: Xfer documents can include comments that the parser will ignore, ensuring that developers can provide clear documentation without affecting the actual data.

    </ This is a comment. />
    
  • Strict Typing: Unlike the loose typing of JSON, Xfer enforces strict data types, enhancing reliability and reducing errors in data handling.

    </ String element />
    <"Hello, World!">  
    
  • Metadata Inclusion: Xfer allows the integration of metadata, providing context and additional information about the document itself, such as its version or message identification.

    <@
        <: version <"1.0"> :>
        <: message_id <"5D3208CB-77EC-4BC4-A256-97AD296BBEF7"> :>
        <: ttl <#3600#> :>
        <: description <"This is a sample document."> :>
    @>
    
  • Placeholder Substitution: Provides the ability to include placeholders that can be dynamically replaced with values during runtime.

    <: message <"Hello, <|USER|>!"> :>
    

Xfer vs JSON

For comparison, consider the following JSON document:

{
    "name": "Alice",
    "age": 30,
    "isMember": true,
    "scores": [85, 90, 78.5],
    "profile": {
        "email": "alice@example.com",
        "joinedDate": "2023-01-15T12:00:00"
    }
}

The equivalent Xfer document showcases its explicit type definitions, leading to improved clarity and structure:

<{
    <: name <"Alice"> :>
    <: age <#30#> :>
    <: isMember <~true~> :>
    <: scores <[<*85*> <*90*> <*78.5*>]> :>
    <: profile <{
            <: email <"alice@example.com"> :>
            <: joinedDate <@2023-01-15T12:00:00@> :>
        }> 
    :>
}>  

Join us on this journey as we evolve Xfer into a professional-grade data-transfer language, with plans to extend its implementations to other programming languages like Rust, C++, JavaScript, and TypeScript. Contributions and feedback are highly encouraged, as we welcome the collaboration of fellow developers!