Languages Features Creators CSV Resources Challenges Add Language
GitHub icon


Ion - Interface design language

< >

Ion is an interface design language created in 2016.

#417on PLDB 7Years Old 1Books

Amazon Ion is a richly-typed, self-describing, hierarchical data serialization format offering interchangeable binary and text representations. The text format (a superset of JSON) is easy to read and author, supporting rapid prototyping. The binary representation is efficient to store, transmit, and skip-scan parse.

Example from the web:
/* Ion supports comments. */ // Here is a struct, which is similar to a JSON object { // Field names don't always have to be quoted name: "Fido", // This is an integer with a 'years' annotation age: years::4, // This is a timestamp with day precision birthday: 2012-03-01T, // Here is a list, which is like a JSON array toys: [ // These are symbol values, which are like strings, // but get encoded as integers in binary ball, rope, ], // This is a decimal -- a base-10 floating point value weight: pounds::41.2, // Here is a blob -- binary data, which is // base64-encoded in Ion text encoding buzz: {{VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE=}}, }

Language features

Feature Supported Token Example
MultiLine Comments βœ“ /* */
/* A comment
Line Comments βœ“ //
// A comment
hasSExpressions βœ“
null.sexp         // A null S-expression value
()                // An empty expression value
(cons 1 2)        // S-expression of three values
([hello][there])  // S-expression containing two lists

(a+-b)  ( 'a' '+-' 'b' )    // Equivalent; three symbols
(a.b;)  ( 'a' '.' 'b' ';')  // Equivalent; four symbols
Lists βœ“
null.list         // A null list value
[]                // An empty list value
[1, 2, 3]         // List of three ints
[ 1 , two ]       // List of an int and a symbol
[a , [b]]         // Nested list
[ 1.2, ]          // Trailing comma is legal in Ion (unlike JSON)
[ 1, , 2 ]        // ERROR: missing element between commas
Type Annotations βœ“
int32::12                                // Suggests 32 bits as end-user type
'my.custom.type' :: { x : 12 , y : -1 }  // Gives a struct a user-defined type

{ field: something::'another thing'::value }  // Field's name must precede annotations of its value

jpeg :: {{ ... }}                        // Indicates the blob contains jpeg data
bool ::                         // A very misleading annotation on the integer null
'' :: 1                                  // An empty annotation
null.symbol :: 1                         // ERROR: type annotation cannot be null 
hasSymbols βœ“
myvar2       // A different symbol
'hi ho'      // Symbol requiring quotes
hasDecimals βœ“
null.decimal      // A null decimal value
0.123             // Type is decimal
-0.12d4           // Type is decimal
123_456.789_012   // Decimal with underscores
-0d-1             // Decimal maintains precision: -0. != -0.0
-0d0              // Negative zero decimal (distinct from positive zero)
hasTimestamps βœ“
// Timestamps represent a specific moment in time, always include a local offset, and are capable of arbitrary precision.
2007-02-23T12:14Z                // Seconds are optional, but local offset is not
2007-01-01T00:00-00:00           // Happy New Year in UTC, unknown local offset
hasClobs βœ“
// The clob type is similar to blob in that it holds uninterpreted binary data. The difference is that the content is expected to be text, so we use a text notation that’s more readable than Base64.
// An Ion clob type is similar to the blob type except that the denotation in the Ion text format uses an ASCII-based string notation rather than a base64 encoding to denote its binary value. It is important to make the distinction that clob is a sequence of raw octets and string is a sequence of Unicode code points.
// The string may only contain legal 7-bit ASCII character
hasBlobs βœ“
// In the text format, blob values are denoted as RFC 4648-compliant Base64 text within two pairs of curly braces.
// A valid blob value with one required padding character.
{{ VG8gaW5maW5pdHkuLi4gYW5kIGJleW9uZCE= }}
Strings βœ“
"hello world"
Null βœ“
Multiline Strings βœ“
( '''hello '''     // Sexp with one element
  '''world!'''  )

("hello world!")   // The exact same sexp value

// This Ion value is a string containing three newlines. The serialized
// form's first newline is escaped into nothingness.
The first line of the string.
This is the second line of the string,
and this is the third line.
Integers βœ“
//   // A null int value
0          // Zero.  Surprise!
-0         //   ...the same value with a minus sign
123        // A normal int
-123       // Another negative int
0xBeef     // An int denoted in hexadecimal
0b0101     // An int denoted in binary
1_2_3      // An int with underscores
0xFA_CE    // An int denoted in hexadecimal with underscores
0b10_10_10 // An int denoted in binary with underscores
Assignment βœ“
// A subset of symbols called identifiers can be denoted in text without single-quotes. 
Floats βœ“
-0.12e4           // Type is float
Structs βœ“
{ first : "Tom" , last: "Riddle" }  // Structure with two fields
{"first":"Tom","last":"Riddle"}     // The same value with confusing style
{center:{x:1.0, y:12.5}, radius:3}  // Nested struct
Comments βœ“
Booleans βœ“
Maps βœ“
{"name": "Mary"}
Semantic Indentation X
Case Insensitive Identifiers X
File Imports X
Ternary operators X
Conditionals X
Macros X
Disk Output X

Books about Ion from ISBNdb

title authors year publisher
Pumps, Transporters, and Ion Channels (Lecture Notes in Computer Science) 2008 Springer
shakespeare.html Β· ion.html Β· treesheets.html

View source

- Build the next great programming language Β· Search Β· Day 213 Β· About Β· Blog Β· Acknowledgements Β· Traffic Β· Traffic Today Β· GitHub Β·