C-style structs on the JVM!

ZERO garbage, ZERO reflection, ZERO maps. EASY to use, and with INCREDIBLE performance.

Build Status license

New! Now fully supported across all JVM languages!


compile group: 'org.jire.strukt', name: 'strukt', version: '1.2.0'



Declaring a Strukt

The declaration syntax is very similar to regular classes, except:

  • You should declare as an object, rather than class
  • Members should be delegated by a subclass of StruktMember
  • You must extend Strukt

For example, a Strukt for representing a coordinate might look like:

object Point : Strukt() {
	var x by int()
	var y by int()

There are member delegates built in for all primitives besides char.

You can also specify a default value for your member, like so:

var x by int(3) // 3 is the default value
var y by int(defaultValue = 5) // 5 is the default value, shown with named arguments

Allocating a reference

The syntax for allocation is a bit different than regular object construction. Instead, you use the invoke operator to set values.

For the above Point example, this might look like:

val example = Point { x = 3; y = 5 }

If you wanted to make use of default arguments, you can omit the sets.

val example = Point {}

Allocating a reference automatically sets the reference pointer. (More on this in the following section.)

Accessing members

Accessing members is the farthest deviation from regular object syntax.

It is important to understand under the hood, Strukt uses something called a reference pointer to keep track of what reference is currently being worked on.

Switching to a reference pointer is done through the get operator on the Strukt’s type.

This might look like this:


In full effect, the Point example might be used like this:

Point[example].y = 20
println("x: ${Point[example].x}, y: ${Point[example].y}") // prints "x: 3, y: 20"

Since the switch (get) operator switches the reference pointer, you can write a shorthand version by referring to the type (Point in our example) directly.

This might look like:

Point[example].x = 123 // `Point[example]` sets the reference pointer...
println("x: ${Point.x}, y: ${Point.y}") // so `Point.x` and `Point.y` can be referred to directly
compile "org.jire.strukt:strukt:1.2.0"

Related Libraries


Kotlin extensions for Java 8 java.time API

Last updated 3 mins ago


Vavr integration for Kotlin

Last updated 3 mins ago


Minimalist dependency injection library for Kotlin.

Last updated 3 mins ago


Simple unit conversion library for Kotlin

Last updated 3 mins ago


Simple parser combinator library for Kotlin

Last updated 3 mins ago