Kotlin (programming language): Difference between revisions

Content deleted Content added
Applications: add ref for ktor
Kylras (talk | contribs)
Link suggestions feature: 3 links added.
Line 80:
* functions and methods support [[default argument]]s, [[variadic function|variable-length argument]] lists and [[Named parameter|named argument]]s
 
Kotlin 1.3 added support for contracts,<ref>{{Cite web|url=https://kotlinlang.org/docs/reference/whatsnew13.html|title=What's New in Kotlin 1.3 - Kotlin Programming Language|website=Kotlin|access-date=4 April 2020|archive-date=22 August 2023|archive-url=https://web.archive.org/web/20230822164600/https://kotlinlang.org/docs/reference/whatsnew13.html|url-status=live}}</ref> which are stable for the standard library declarations, but still experimental for user-defined declarations. Contracts are inspired by [[Eiffel (programming language)|Eiffel's]] [[design by contract]]<ref>{{Cite web|url=https://discuss.kotlinlang.org/t/design-by-contract-dbc-design-considerations/1321|title=Design by Contract (DbC) design considerations|quote=Implement the full semantics of Eiffel DbC and improve upon it.|date=16 August 2012|website=Kotlin Discussions|language=en-US|access-date=4 April 2020|archive-date=5 April 2023|archive-url=https://web.archive.org/web/20230405081654/https://discuss.kotlinlang.org/t/design-by-contract-dbc-design-considerations/1321|url-status=live}}</ref> [[programming paradigm]].
 
Following [https://www.scala-js.org/ ScalaJS], Kotlin code may be [[Source-to-source compiler|transpiled]] to [[JavaScript]], allowing for interoperability between code written in the two languages. This can be used either to write full web applications in Kotlin, or to share code between a Kotlin backend and a JavaScript frontend.<ref>{{Cite web|title=Kotlin for JavaScript {{!}} Kotlin|url=https://kotlinlang.org/docs/js-overview.html#use-cases-for-kotlin-js|date=21 January 2021<!-- 11 February 2021 -->|access-date=2021-03-19|website=Kotlin Help|language=en-US|archive-date=14 July 2023|archive-url=https://web.archive.org/web/20230714143003/https://kotlinlang.org/docs/js-overview.html#use-cases-for-kotlin-js|url-status=live}}</ref>
Line 362:
}}
 
* {{mono|?:}} (the [[null coalescing operator]]) is a binary operator that returns the first operand, if non-null, else the second operand. It is often referred to as the [[Elvis operator]], due to its resemblance to an [[emoticon]] representation of Elvis Presley.
 
{{blockquote |
Line 413:
 
==Kotlin Multiplatform==
Kotlin Multiplatform allows a single [[codebase]] to target multiple platforms such as [[Microsoft Windows|Windows]], [[Linux]], web, Android and [[iOS]].<ref>{{Cite web |title=Kotlin Multiplatform Overview |url=https://developer.android.com/kotlin/multiplatform |access-date=2025-06-14 |website=Android Developers |language=en}}</ref><ref>{{Cite web |title=Kotlin Multiplatform – Build Cross-Platform Apps |url=https://www.jetbrains.com/kotlin-multiplatform/ |access-date=2025-06-14 |website=JetBrains |language=en}}</ref>
 
Compose Multiplatform is a multi-platform UI framework based on [[Jetpack Compose]]. It is Jetpack Compose for Android ported to Windows, [[macOS]], Linux, web, and iOS.<ref>{{Cite web |title=Compose Multiplatform – Beautiful UIs Everywhere |url=https://www.jetbrains.com/compose-multiplatform/ |access-date=2025-06-14 |website=JetBrains |language=en}}</ref><ref>{{Cite web |title=What's new in Compose Multiplatform 1.8.1 {{!}} Kotlin Multiplatform |url=https://www.jetbrains.com/help/kotlin-multiplatform-dev/whats-new-compose-180.html |access-date=2025-06-14 |website=Kotlin Multiplatform Help |language=en-US}}</ref><ref>{{Cite web |title=Compatibility and versions {{!}} Kotlin Multiplatform |url=https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compatibility-and-versioning.html |access-date=2025-06-14 |website=Kotlin Multiplatform Help |language=en-US}}</ref> Jetpack Compose uses a Kotlin compiler plugin to transform composable functions into UI elements.<ref>{{Citation |last=Panjuta |first=Denis |title=Basic Jetpack Compose Elements |date=2023-12-12 |work=Tiny Android Projects Using Kotlin |pages=233–257 |url=https://doi.org/10.1201/9781032622538-9 |access-date=2025-06-14 |place=Boca Raton |publisher=Chapman and Hall/CRC |isbn=978-1-032-62253-8 |last2=Nwokike |first2=Loveth}}</ref> For example, the Text composable function displays a text label on the screen.