Menu
CoddyTech
Course

Kotlin for GDScript Developers

Move from GDScript to Kotlin through null safety, collection ownership, functions, properties and object contracts. Compare captures and accessors, build an order processor, and port a stock ledger.

GDScript and Kotlin side by side

The same program in GDScript and in Kotlin, from the lessons of this course.

  1. Strings and Templates

    GDScript print and prints differ in argument spacing, and percent formatting assembles strings explicitly. Kotlin string templates interpolate names or expressions and println adds a newline. GDScript String length counts code points, while Kotlin/JVM length…

    GDScript
    1extends Node2
    3
    4func _ready() -> void:5	var user_name: String = "Ada"6	prints("Hi "+user_name,"!")
    Kotlin
    1fun main(){2val ready=33println("Ready: $ready")4}
  2. Equality and Identity

    GDScript strings compare text and Array or Dictionary equality can compare contents. Kotlin == uses equals and === checks reference identity, but arrays need contentEquals when element equality is intended. Strings have content equality and ordinary classes…

    GDScript
    1extends Node2
    3
    4func _ready() -> void:5	var a: String = "ab"6	var b: String = "a"+"b"7	print(a==b)
    Kotlin
    1fun main(){2val a=String(charArrayOf('t','e','a'))3val b=String(charArrayOf('t','e','a'))4println(a==b)5}
  3. Arrays and IntArray

    GDScript Array grows dynamically and supports negative indexes. Kotlin arrays instead have fixed size and checked nonnegative indexes. IntArray provides primitive integer storage, while Array<Int> has a different JVM representation. Use last or lastIndex for…

    GDScript
    1extends Node2
    3
    4func _ready() -> void:5	var values: Array[int] = [2,4,6]6	print(values[-1])
    Kotlin
    1fun main(){2val a=intArrayOf(4,8,12)3println(a.last())4}
  4. While, Break, and Continue

    GDScript and Kotlin both support while, break and continue, but Kotlin requires a Boolean condition. Advance manual indexes on every continuing path and recognize a stop marker before normal processing. Kotlin string == checks content. Keep skipping an empty…

    GDScript
    1extends Node2
    3
    4func _ready() -> void:5	var n: int = 36	while n>1:7		n-=18	print(n)
    Kotlin
    1fun main(){2val kept=mutableListOf<String>()3for(word in listOf("tea","","STOP","coffee")){if(word=="STOP")break;if(word.isEmpty())continue;kept.add(word)}4println(kept.joinToString(","))5}
  5. Top-level Functions

    GDScript functions belong to scripts or objects, while Kotlin permits top-level functions in the supplied files. Kotlin parameters are read-only bindings, expression bodies may infer their result type, and non-Unit block bodies need explicit returns.…

    GDScript
    1extends Node2
    3static func hours(total: int) -> int:4	return total/605func _ready() -> void:6	print(hours(125))
    Kotlin
    1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}
  6. Input and String Formatting

    GDScript console input can use OS.read_string_from_stdin, while these Kotlin tasks supply a locked line-reading driver. Kotlin readlnOrNull exposes EOF as null and toInt requires valid complete numeric text. Trim only when allowed and format exact returned…

    GDScript
    1extends Node2
    3
    4func _ready() -> void:5	var cents: int = 3056	print("tea: %d.%02d" % [cents/100,cents%100])
    Kotlin
    1fun main(){2println("  tea  ".trim().uppercase(java.util.Locale.ROOT))3}

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Challenges

2 lessons

More courses for GDScript developers

Learn Kotlin from another language

Frequently asked questions

Who is Kotlin for GDScript Developers for?

For people who already write GDScript and want to learn Kotlin. Each lesson starts from GDScript you know and shows how Kotlin does the same thing, so you skip the beginner basics.

Do I need to know Kotlin already?

No. The course starts with your first Kotlin program. You need GDScript basics: variables, conditions, loops, functions and collections.

How many lessons does Kotlin for GDScript Developers have?

Kotlin for GDScript Developers contains 48 interactive lessons you can complete at your own pace.

What does Kotlin for GDScript Developers cover?

The course is organized into chapters covering: Starting Kotlin, Values and Decisions, Collections and Ownership, Iteration and Transformations, and more.

Is Kotlin for GDScript Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Kotlin for GDScript Developers for free

Get started