Menu
CoddyTech
Course

Kotlin for Rust Developers

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

Rust and Kotlin side by side

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

  1. Strings and Templates

    Rust println! formats values through macros and formatting traits. Kotlin println takes a completed value, with string templates interpolating names or braced expressions. Kotlin/JVM strings use UTF-16 code units while Rust String stores UTF-8 bytes. Build…

    Rust
    1
    2fn main() {3let name="Ada";println!("Hi {} !",name);4}
    Kotlin
    1fun main(){2val ready=33println("Ready: $ready")4}
  2. Equality and Identity

    Rust value equality uses PartialEq, with Eq expressing a stronger equality contract; pointer identity is a separate operation. Kotlin == invokes null-safe equals and === tests identity. Strings compare contents, but ordinary classes default to identity and…

    Rust
    1
    2fn main() {3let a=String::from("ab");let b=["a","b"].concat();println!("{}",a==b);4}
    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

    Rust fixed arrays have their length in the type and slices provide borrowed views. Kotlin arrays are fixed-size objects but their lengths are not ordinary type parameters. IntArray stores primitive integers on the JVM and indexes are checked. Kotlin array…

    Rust
    1
    2fn main() {3let values=[2,4,6];println!("{}",values[values.len()-1]);4}
    Kotlin
    1fun main(){2val a=intArrayOf(4,8,12)3println(a.last())4}
  4. While, Break, and Continue

    Rust and Kotlin provide while, break and continue with Boolean conditions. Their labels and value-producing loop facilities differ, so preserve the control-flow intent rather than the exact syntax. Update manual cursors before continuing and check stop…

    Rust
    1
    2fn main() {3let mut n=3;while n>1 {n-=1;}println!("{}",n);4}
    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

    Rust and Kotlin both allow top-level functions with typed parameters. Rust mutable references can change caller-owned values under borrowing rules; ordinary Kotlin parameters cannot rebind a caller’s scalar variable. Return an updated result or mutate an…

    Rust
    1fn hours(total:i32)->i32 {total/60}2fn main() {3println!("{}",hours(125));4}
    Kotlin
    1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}
  6. Input and String Formatting

    Rust buffered line iteration and parsing return Results that need explicit handling. Kotlin readlnOrNull returns null at EOF and toInt parses a complete integer string; toIntOrNull represents failure as null. The task driver owns console I/O, so helpers…

    Rust
    1
    2fn main() {3let cents=305;println!("tea: {}.{:02}",cents/100,cents%100);4}
    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 Rust developers

Learn Kotlin from another language

Frequently asked questions

Who is Kotlin for Rust Developers for?

For people who already write Rust and want to learn Kotlin. Each lesson starts from Rust 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 Rust basics: variables, conditions, loops, functions and collections.

How many lessons does Kotlin for Rust Developers have?

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

What does Kotlin for Rust 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 Rust 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 Rust Developers for free

Get started