How Can Any Programming Language Be More Environmentally Friendly, Especially Kotlin?

Ahmed Samir
3 min readDec 23, 2022

--

Photo by Federico Beccari on Unsplash

Kotlin as a programming language has a moderate effect on the environment, as it is not naturally environmentally friendly or harmful. In general, how a particular programming language can possibly affect the environment depends on the approaches and the usage of the language, and the resources it consumes in addition to the systems it was involved in its development process. However, Kotlin has been designed to be more concise and expressive than other programming languages, as writing code in Kotlin is more efficient and requires fewer resources. Below, are some ways and examples to show how we can use Kotlin in a manner that is related to environment conservation.

Kotlin has multiplatform capabilities like Kotlin Multiplatform (KMP) which refers to Kotlin’s ability to build cross-platform systems among desktop, web, and mobile, and Kotlin Multiplatform Mobile (KMM) that allows the developer to create mobile applications on Android and IOS by sharing a big portion of the codebase and finally this code base is compiled natively to Swift (IOS programming language). It was found that KMM can potentially provide nearly the same performance as a native app on both platforms according to a survey conducted by JetBrains (the creators of Kotlin programming language) about KMM [1]. Furthermore, JetBrains has been continuously improving KMM technology in terms of performance and energy consumption, as they have released a new memory manager [2] that works for Kotlin Native which is used for cross-platform development. Plenty of companies are satisfied with KMM as a cross-platform solution [3], most notably the famous cloud provider VMware and Memrise which has a language learning app holding the same name. VMware and Memrise found that cross-platform frameworks like React Native and Flutter did not fit with their requirements and needs. Finally, they chose Kotlin as the beneficial solution for their products [4][5]. With the help of KMM, Kotlin could be environmentally friendly as it can help reduce the energy consumption associated with running separate systems for each platform as well as optimize the app’s performance, usage of resources, and hardware accessibility.

Another way to make software development more environmentally friendly, is to design systems that use resources and energy efficiently, which can be achieved by focusing on efficient and well-designed systems, we can minimize resource usage and energy consumption, ultimately making a positive impact on the environment and reducing individuals carbon footprint. Along with efficiency, mostly any programming language can be used to build environmentally friendly systems, such as carpooling and public transit systems to significantly reduce the possible emission of carbon. Additionally, developing software that helps organizations or individuals reduce the usage of energy and conserve resources by giving them tips and information and potentially tracking their usage of energy and resources. Additionally, helping farmers to reduce the use of synthetic materials by giving them natural replacements.

Finally, programming languages generally should be used with caution while building applications by applying efficient algorithms and using a corresponding data structure to reduce the time and memory usage of software, therefore reducing the overall energy consumption of the software system. Along with that choosing the right framework to complete a particular job and creating environmentally friendly software such as the ones mentioned.

References

[1] Petrova, E. (2021) Results of the Kotlin multiplatform survey Q1-Q2 2021: The kotlin blog, The JetBrains Blog. Available from <https://blog.jetbrains.com/kotlin/2021/10/multiplatform-survey-q1-q2-2021/#Who_uses_KMM_and_why> (20/12/2022).

[2] Petrova, E. (2021) Try the New Kotlin/Native Memory Manager Development Preview: The kotlin blog, The JetBrains Blog. Available from < https://blog.jetbrains.com/kotlin/2021/08/try-the-new-kotlin-native-memory-manager-development-preview/#Why_do_we_need_a_new_memory_manager> (20/12/2022).

[3] Case Study — Kotlin — URL: https://kotlinlang.org/lp/mobile/case-studies/

[4] Memrise — Kotlin — URL: https://kotlinlang.org/lp/mobile/case-studies/memrise

[5] VMware — Kotlin — URL: https://kotlinlang.org/lp/mobile/case-studies/vmware/

--

--