Skip to content

Data Types

Jule is designed strongly typed. Therefore, the data-types of all values must be specified during compilation. In this section we will look at the builtin types offered by the compiler.

Primitive Types

TypeTypical Bit WidthTypical Range
i81 byte-128 to 127
i162 bytes-32768 to 32767
i324 bytes-2147483648 to 2147483647
i648 bytes-9223372036854775808 to 9223372036854775807
intPlatform dependentPlatform dependent (signed)
u81 byte0 to 255
u162 bytes0 to 65535
u324 bytes0 to 4294967295
u648 bytes0 to 18446744073709551615
uintPlatform dependentPlatform dependent (unsigned)
uintptrPlatform dependentIt is a unsigned integer type that is big enough to hold a pointer.
f324 bytes-3.4028234663852886e+38 to 3.4028234663852886e+38
f648 bytes-1.797693134862315708e+308 to 1.797693134862315708e+308
bool1 bytetrue or false
str-UTF-8 byte encoded character string.
any-Any data.

Integer Literals

Decimal

jule
12345

Binary

jule
0b0001010101

Octal

jule
0455
jule
0o455

Hexadecimal

jule
0xDFF90

Floating-Point Literals

jule
3.14
jule
32.60
jule
032.60
jule
3.
jule
.3
jule
0.3
jule
1E2
jule
.12345E+6
jule
1.e+0
jule
0x1p-2
jule
0x2.p10
jule
0x1.Fp+0
jule
0X.8p-0
jule
0x1fffp-16

Underscore & Numeric Literals

You can use underscore to separate digits. This might be helpful for big numbers.
There are some conditions:

  • Literal cannot starts with underscore
  • Precision of floating-point literals are cannot starts with underscore
  • Format specifier of floating-point literals are cannot separated with underscore from following digits

Example to underscored literals:

jule
10_000_000
jule
0.5_000e+100
jule
.12_345E+6
jule
0b1100_1100_0110_1010

Byte and Rune Literals

A byte or rune literal is represented by a single character between single quotes. Since it is typically a string element, it supports the same escape sequences. Literal can be evaluated in two ways, these are byte literal and rune literal. If your character is small enough to be a byte (0 <= b <= 255) it is treated as a byte, otherwise it is treated as a rune.

For example:

jule
'a' // byte
jule
'ç' // rune

String

Jule strings are UTF-8 encoded byte-by-byte, and support Unicode. They are also immutable, means you can't modify them. For literals, strings will not heap allocated. Strings only performs heap allocation for runtime concats and other runtime stuffs. If string performs a heap allocation, it will use smart pointer to track allocation.

Strings support the + operator for concatenation, It's that easy to concatenate two strings. Additionally, using the == and != operators, you can easily determine whether two strings are the same or not.

In most cases, any concatenation will result as heap allocation which is might be expensive. For higly-repeated concatenations use string builder utilities instead.

It also supports the <, <=, >, and >= operators for comparing strings. But it is not case-sensitive, case-insensitive or like that. This operators just compares bytes/runes of strings.

String Literals

jule
"String literal of Jule."

String literals have a escape sequences.

EscapeDescription
\\Backslash
\aASCII Bell.
\bASCII Backspace.
\fASCII Formfeed.
\nASCII Linefeed.
\rCarriage return.
\tASCII Horizontal tab.
\vASCII Vertical tab.
\'Single quote.
\"Double quote.
\xhhThe byte whose numerical value is given by hh… interpreted as a hexadecimal number.
\uhhhhUnicode code point below 10000 hexadecimal.
\UhhhhhhhhUnicode code point where h is a hexadecimal digit.
\nnnThe byte whose numerical value is given by nnn interpreted as an octal number.

Raw String Literals

Raw strings do not contain escape sequences and are not required to be defined in a single line. They are represents with `.

jule
`Raw String literal of Jule.`
jule
`Raw String literal of Jule
with
new
    lines.`

Boolean

Jule defines two constant values for booleans.

For logical true:

jule
true

For logical false:

jule
false

Maps

See the Maps section for more information.

any

See the Any section for more information.

Nil

Zero value for pointers and function data typed defines.

jule
nil