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 mutable. So you don't need to use String Builder to compensate for the inefficiency of immutable strings as in some other languages, string concatenations are less of a performance concern.

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.

It also supports the <, <=, >, and >= operators for comparing strings. But it is not case-sensitive, case-insensitive or like that. This operators just compares 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.`

Nil

Zero value for pointers and function data typed defines.

jule
nil

any

It can be hold any data type and nil. Only supports equals (==) and not equals (!=) operators.

x == nil: true if any is nil, not checks whether data is nil
x == y: true if x and y is nil
x == y: true if x and y has same data type and returns true of equals operator of data type for two value

Supports casting to any type. You can get type-safe value of any with casting. For example:

jule
let my_any: any = 10
let x = (int)(my_any)

any type protects itself against mutability if necessary. For example, you have slice value holds by any-typed variable. And your variable is immutable. So, if you cast your value to slice for assign to mutable variable, you will get error. Because of slice is mutable type, so it's breaking immutability.

WARNING

This is is very unsafe, also blocks deriving Clone. Avoid using any whenever possible.