How To Install Kotlin on Fedora 38

install Kotlin on Fedora 38

In this short article we will learn how to install Kotlin on Fedora 38 operating system using Snap store.

Introduction

In the ever-evolving landscape of programming languages, Kotlin has emerged as a versatile and powerful player. Developed by JetBrains, Kotlin is designed to be fully interoperable with Java and offers a wealth of features that make it a popular choice for developers across various domains. In this article, we will delve into the world of Kotlin, exploring its history, key features, and why it has gained such widespread adoption.

Key Features of Kotlin

  • Concise Syntax: Kotlin boasts a concise and expressive syntax, allowing developers to write code that is both more readable and less verbose than Java. This makes it a favorite among developers who appreciate clean, elegant code.
  • Null Safety: Kotlin offers built-in null safety, which helps prevent null pointer exceptions, a common source of bugs in many programming languages. This feature is a game-changer for software reliability and quality.
  • Interoperability with Java: Kotlin’s seamless interoperability with Java means that you can use existing Java libraries and frameworks, making it easy to transition from Java to Kotlin in your projects.
  • Extension Functions: Kotlin enables the creation of extension functions, which allow developers to add new functionality to existing classes without modifying their source code. This promotes a more modular and maintainable codebase.
  • Smart Casts: Kotlin’s smart casts allow for safe and automatic casting of types, reducing the need for explicit type casting and improving code clarity.
  • Coroutines: Kotlin includes native support for coroutines, making it easier to write asynchronous and concurrent code without the complexities of callbacks or traditional multithreading.
  • Data Classes: Data classes in Kotlin streamline the creation of classes for storing data by automatically generating essential methods like equals(), hashCode(), and toString().
  • Immutability: Kotlin encourages the use of immutable data structures and promotes functional programming concepts, making code more predictable and less error-prone.

Why Choose Kotlin?

  • Android Development: Kotlin’s official endorsement by Google has made it the go-to language for Android app development. Its modern features and excellent tooling make it a top choice for building high-quality, robust Android applications.
  • Web Development: Kotlin is not just limited to mobile development. It can be used on the server-side, and frameworks like Ktor have gained popularity for building web applications and microservices.
  • Versatility: Kotlin can be applied in a wide range of domains, including data analysis, backend development, game development, and more. Its versatility and compatibility with Java have broadened its appeal.
  • Strong Community and Ecosystem: Kotlin has a growing and supportive community of developers, providing a wealth of resources, libraries, and tools that further enrich its ecosystem.

How To Install Kotlin on Fedora 38

To install Kotlin by using snap is a simple process. Before we begin we must prepare our system to meet the requirements. The requirements are as follow :

  1. A system which is running Fedora
  2. An account with sudo privilege
  3. Good internet connection

We will do Kotlin installation by running several tasks as described below :

  1. Update Fedora System
  2. Install Java Development Kit
  3. Installing Kotlin on Fedora 38
  4. Creating Kotlin simple program

Step 1 : Update Fedora System

$ sudo dnf clean all
$ sudo dnf update

Step 2 : Install Java Development Kit

Kotlin is running based on JDK, JDK is used to compile Kotlin programs. At this step we will verity if our system has already Java installed on the system.

$ java --version

Output :

ramansah@bckinfo ~]$ java --version
openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment (Red_Hat-17.0.8.0.7-1.fc38) (build 17.0.8+7)
OpenJDK 64-Bit Server VM (Red_Hat-17.0.8.0.7-1.fc38) (build 17.0.8+7, mixed mode, sharing)

If our system is not installed Java yet, then we need to install it first by submitting command line :

$ sudo dnf install java

Step 3 : Installing Kotlin on Fedora 38

On this tutorial, we will install Kotlin by using snap, then we need to install snapd on our Fedora. Snapd installation has been covered on ‘How to install snap on Fedora 38‘ tutorial.

Then we will install Kotlin on Fedora 38 operating system by submitting command line :

$ sudo snap install kotlin --classic
$ kotlin -version

Output :

ramansah@bckinfo ~]$ sudo snap install kotlin --classic
2023-11-08T04:55:57+01:00 INFO Waiting for automatic snapd restart...
kotlin 1.7.21 from jetbrainsâś“ installed
[ramansah@bckinfo ~]$ kotlin -version
Kotlin version 1.7.21-release-272 (JRE 17.0.8+7)

Step 4 : Creating Simple Kotlin Program

After we have installed Kotlin on our system, we will create a simple program to test if our installation is succesfull. We will create a file which is displaying ‘Hello world’.

$ vi kotlinc helloworld.kt 
// hello world, Kotlin simple program

fun main() {
    println("Hello, World ! Free Palestine !")
}
~                                                                                                            
~                                       

Then compile it by submitting command line :

$ kotlinc helloworld.kt -include-runtime -d helloworld.jar

Then run the program by submitting command line :

$ java -jar helloworld.jar 

The output will be as shown below :

Hello, World ! Free Palestine !

It is looks good and application is running properly.

Conclusion

In this tutorial we have installed Kotlin application on Fedora 38 operating system successfully.

(Visited 29 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *