Content deleted Content added
→Development: minor refactoring |
mNo edit summary |
||
(33 intermediate revisions by 21 users not shown) | |||
Line 3:
{{Infobox programming language
| name = Kotlin
| logo = Kotlin logo (2021-present).svg
| logo size = 230px
| paradigm = [[Multi-paradigm programming language|Multi-paradigm]]: [[Object-oriented programming|object-oriented]], [[Functional programming|functional]], [[Imperative programming|imperative]], [[Block (programming)|block structured]], [[Declarative programming|declarative]], [[Generic programming|generic]], [[Reflective programming|reflective]], [[Concurrent computing|concurrent]]
Line 51:
==History==
[[File:
[[File:
=== Name ===
Line 62:
In July 2011, [[JetBrains]] unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.<ref name="announce">{{cite news |last1=Krill |first1=Paul |date=22 July 2011 |url=https://www.infoworld.com/d/application-development/jetbrains-readies-jvm-based-language-167875 |title=JetBrains readies JVM language Kotlin |work=[[InfoWorld]] |access-date=2 February 2014 |archive-url=https://web.archive.org/web/20190907161741/https://www.infoworld.com/article/2622405/jetbrains-readies-jvm-based-language.html |archive-date=7 September 2019 |url-status=live}}</ref> JetBrains lead Dmitry Jemerov said that most languages did not have the features they were looking for, with the exception of [[Scala (programming language)|Scala]]. However, he cited the slow [[compiler|compilation]] time of Scala as a deficiency.<ref name="announce" /> One of the stated goals of Kotlin is to compile as quickly as Java. In February 2012, JetBrains open sourced the project under the [[Apache License#Apache License 2.0|Apache 2 license]].<ref name="open source">{{cite news |last1=Waters |first1=John |date=22 February 2012 |url=https://adtmag.com/articles/2012/02/22/kotlin-goes-open-source.aspx |title=Kotlin Goes Open Source |website=ADTmag.com |publisher=1105 Enterprise Computing Group |url-status=live |archive-url=https://web.archive.org/web/20140218225151/https://adtmag.com/articles/2012/02/22/kotlin-goes-open-source.aspx |archive-date=18 February 2014 |access-date=2 February 2014}}</ref>
JetBrains expected
Kotlin 1.0 was released on February 15, 2016.<ref>{{cite web |url=https://blog.jetbrains.com/kotlin/2016/02/kotlin-1-0-released-pragmatic-language-for-jvm-and-android/ |title=Kotlin 1.0 Released: Pragmatic Language for JVM and Android | Kotlin Blog |website=Blog.jetbrains.com |date=15 February 2016 |access-date=11 April 2017 |archive-date=24 January 2018 |archive-url=https://web.archive.org/web/20180124194203/https://blog.jetbrains.com/kotlin/2016/02/kotlin-1-0-released-pragmatic-language-for-jvm-and-android/ |url-status=live}}</ref> This is considered to be the first officially stable release and JetBrains has committed to long-term backwards compatibility starting with this version.
At [[Google I/O]] 2017, Google announced first-class support for Kotlin on [[Android (operating system)|Android]].<ref name="kotlin-android">{{cite news |last1=Shafirov |first1=Maxim |date=17 May 2017 |url=https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/ |title=Kotlin on Android. Now official |quote=Today, at the Google I/O keynote, the Android team announced first-class support for Kotlin. |access-date=18 May 2017 |url-status=live |archive-url=https://web.archive.org/web/20230529180054/https://blog.jetbrains.com/kotlin/2017/05/kotlin-on-android-now-official/ |archive-date=29 May 2023}}</ref> On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers.<ref name="auto"/>
==Design==
Line 131 ⟶ 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 413 ⟶ 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 461 ⟶ 410:
* JetBrains also provides a plugin for [[Eclipse (software)|Eclipse]].<ref>{{cite web |url=https://kotlinlang.org/docs/tutorials/getting-started-eclipse.html |title=Getting Started with Eclipse Neon – Kotlin Programming Language |website=Kotlinlang.org |date=10 November 2016 |access-date=11 April 2017 |archive-date=18 May 2023 |archive-url=https://web.archive.org/web/20230518022923/https://kotlinlang.org/docs/tutorials/getting-started-eclipse.html |url-status=live}}</ref><ref>{{cite web |url=https://github.com/JetBrains/kotlin-eclipse |title=JetBrains/kotlin-eclipse: Kotlin Plugin for Eclipse |publisher=GitHub |access-date=11 April 2017 |archive-date=16 February 2016 |archive-url=https://web.archive.org/web/20160216150931/https://github.com/JetBrains/kotlin-eclipse |url-status=live}}</ref>
* [[IntelliJ IDEA]] has plug-in support for Kotlin.<ref>{{cite web |url=https://plugins.jetbrains.com/plugin/6954-kotlin |title=Kotlin :: JetBrains Plugin Repository |website=Plugins.jetbrains.com |date=31 March 2017 |access-date=11 April 2017 |archive-date=25 June 2023 |archive-url=https://web.archive.org/web/20230625051612/https://plugins.jetbrains.com/plugin/6954-kotlin |url-status=live}}</ref> IntelliJ IDEA 15 was the first version to bundle the Kotlin plugin in the IntelliJ Installer, and to provide Kotlin support out of the box.<ref>{{cite web |url=https://www.jetbrains.com/idea/whatsnew/ |title=What's New in IntelliJ IDEA 2017.1 |website=Jetbrains.com |access-date=11 April 2017 |archive-date=3 October 2023 |archive-url=https://web.archive.org/web/20231003212723/https://www.jetbrains.com/idea/whatsnew/ |url-status=live}}</ref>
* [[Gradle]]: Kotlin has seamless integration with Gradle,
==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.
==Applications==
When Kotlin was announced as an official Android development language at [[Google I/O]] in May 2017, it became the third language fully supported for Android, after Java and C++.<ref>{{Cite news |last1=Lardinois|first1=Frederic |url=https://techcrunch.com/2017/05/17/google-makes-kotlin-a-first-class-language-for-writing-android-apps/ |title=Google makes Kotlin a first-class language for writing Android apps |website=techcrunch.com |language=en-US |date=17 May 2017 |access-date=28 June 2018 |url-status=live |archive-url=https://web.archive.org/web/20170522065631/https://techcrunch.com/2017/05/17/google-makes-kotlin-a-first-class-language-for-writing-android-apps/ |archive-date=22 May 2017}}</ref> {{As of|2020}}, Kotlin
In 2020, JetBrains found in a survey of developers who use Kotlin that 56% were using Kotlin for mobile apps, while 47% were using it for a web back-end. Just over a third of all Kotlin developers said that they were migrating to Kotlin from another language. Most Kotlin users were targeting Android (or otherwise on the JVM), with only 6% using Kotlin Native.<ref>{{cite web |title=Kotlin Programming - The State of Developer Ecosystem 2020 |url=https://www.jetbrains.com/lp/devecosystem-2020/kotlin/ |website=JetBrains |access-date=29 September 2020 |language=en |archive-date=5 April 2023 |archive-url=https://web.archive.org/web/20230405081654/https://www.jetbrains.com/lp/devecosystem-2020/kotlin/ |url-status=live}}</ref>
Line 502 ⟶ 456:
* [[Basecamp (software)|Basecamp]]<ref>{{Cite news |url=https://m.signalvnoise.com/how-we-made-basecamp-3s-android-app-100-kotlin-35e4e1c0ef12 |archive-url=https://wayback.archive-it.org/all/20180801160548/https://m.signalvnoise.com/how-we-made-basecamp-3s-android-app-100-kotlin-35e4e1c0ef12?gi=e9a4b3c9bf9f |url-status=dead |archive-date=1 August 2018 |title=How we made Basecamp 3's Android app 100% Kotlin – Signal v. Noise |date=29 April 2017 |work=Signal v. Noise |access-date=1 May 2017}}</ref>
* Corda, a distributed ledger developed by a consortium of well-known banks (such as [[Goldman Sachs]], [[Wells Fargo]], [[JPMorgan Chase|J.P. Morgan]], [[Deutsche Bank]], [[UBS]], [[HSBC]], [[BNP Paribas]], and [[Société Générale]]), has over 90% Kotlin code in its codebase.{{Citation needed|date=July 2025|reason=Making a big claim and naming a lot of names here, so where's the source?}}
* [[Coursera]]<ref>{{cite web |url=https://medium.com/coursera-engineering/becoming-bilingual-coursera-d8048dce73e3 |title=Becoming bilingual@coursera |date=26 April 2018 |access-date=24 July 2019 |archive-date=15 January 2023 |archive-url=https://web.archive.org/web/20230115223242/https://medium.com/coursera-engineering/becoming-bilingual-coursera-d8048dce73e3 |url-status=live}}</ref>
* DripStat<ref>{{cite web |url=https://blog.dripstat.com/kotlin-in-production-the-good-the-bad-and-the-ugly-2/ |title=Kotlin in Production – What works, Whats broken |website=Blog.dripstat.com |date=24 September 2016 |access-date=11 April 2017 |archive-date=1 July 2019 |archive-url=https://web.archive.org/web/20190701030659/https://blog.dripstat.com/kotlin-in-production-the-good-the-bad-and-the-ugly-2/ |url-status=dead}}</ref>
* [[Duolingo]]<ref>{{cite web |last1=Chaidarun |first1=Art |title=Migrating Duolingo's Android app to 100% Kotlin |url=https://blog.duolingo.com/migrating-duolingos-android-app-to-100-kotlin/ |website=Duolingo Blog |language=en |date=6 April 2020}}</ref>
* [[Meta Platforms|Meta]]<ref>{{cite web |url=https://www.infoq.com/news/2022/11/meta-port-java-kotlin/ |title=Porting Million Lines of Code from Java to Kotlin at Meta }}</ref>
* [[Netflix]]<ref>{{cite web |url=https://twitter.com/robspieldenner/status/708355228832178176 |title=Rob Spieldenner on twitter |access-date=24 July 2019 |archive-date=25 December 2022 |archive-url=https://web.archive.org/web/20221225132754/https://twitter.com/robspieldenner/status/708355228832178176 |url-status=live}}</ref> * [[Pinterest]]<ref>{{cite web |url=https://www.youtube.com/watch?v=mDpnc45WwlI |title=Droidcon NYC 2016 - Kotlin in Production |website=[[YouTube]] |date=3 November 2016 |access-date=24 July 2019 |archive-date=14 April 2023 |archive-url=https://web.archive.org/web/20230414150938/https://www.youtube.com/watch?v=mDpnc45WwlI |url-status=live}}</ref>
* [[Trello]]<ref>{{cite web |url=https://twitter.com/danlew42/status/809065097339564032 |title=Dan Lew on Twitter |access-date=24 July 2019 |archive-date=2 May 2023 |archive-url=https://web.archive.org/web/20230502024553/https://twitter.com/danlew42/status/809065097339564032 |url-status=live}}</ref>
* [[Uber]]<ref>{{cite web |date=30 April 2019 |title=Measuring Kotlin Build Performance at Uber |url=https://www.uber.com/blog/measuring-kotlin-build-performance/ |access-date=6 March 2024 |archive-date=5 June 2023 |archive-url=https://web.archive.org/web/20230605173159/https://www.uber.com/blog/measuring-kotlin-build-performance/ |url-status=live}}</ref>
==See also==
|