38

Kotlin vs. Scala: Which is Right JVM for 2020?

 4 years ago
source link: https://www.tuicool.com/articles/Zjei2ea
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

zM7vueB.jpg!web

The slow evolution of the Java programming language has led to an increasing interest in the JVM programming languages. There are 50+ JVM languages (some implementations of existing languages, some high-profile, some new languages with the JVM implementation), even if you are quite familiar with a dozen of them or so, it’s likely that you’ll pick a new one for your next software development project.

The current development trend has been cast away from the dynamic scripting languages for app customization towards general-purpose statically-typed programming languages for app development. While some coders are born C programmers, whereas some coders have an innate connection to the Lisp and others swear by the Perl programming language. Developer’s predilections are not well defined and their language preferences vary.

Java.next ideates that no particular programming language will dominate the android mobile app development landscape, as there is no single perfect programming language for everyone.

Rise & Fall of Java

3y2aAvv.jpg!web

Java programming language has faced an uphill battle for the adoption. Being slower than compiled programming languages popular at that particular time, it is used to be memory hungry language and was not suitable for the then-predominant client or server style of app development.

The grace that saved the Java programming language was its applets & relative ease of use (via garbage collection). As the landscape turned dynamic in nature, Java survived. But, this query was still open-ended. With the steady growth of the WWW and its applicability with the Java programming language, several server-side deployment models minimized the ongoing cons of Java programming language. The combination of factors included hardware, web, and programming paradigm.

The Emergence of New JVM Languages

fUbYRfE.jpg!web

App developers were always in the requirement of new tools and technologies to program the web. Server-Side Java has alleviated the constraints of memory. Although Java programming language has become a dominant force in the software development industry, any attempts to identify the next JVM programming language with a similar impact as Java are distant and not likely to succeed in this domain. But, at the same time, we have entered a polyglot world of computer programming languages with an upward trend. Hence, predictions are blurry and it is unlikely that a series of circumstances will completely line-up well for another programming language.

Which programming paradigms are supported?

Java.next programming languages either support one or multiple coding paradigms (which might include meta-programming, object orientation, functional & procedural, etc.) Kotlin & Scala are multi-paradigm. They are both object-oriented and functional.

What is Kotlin:

Z7vQreE.jpg!web

It is an object-oriented programming language that connects object-oriented programming features like Extension Function, Range Expressions, Smart Casts, and Companion Object, etc.

This tool was developed by JetBrains and hit the market in Feb. 2012 as an open-source programming language. Up until now, Kotlin programming language has had two released versions, with Kotlin 1.3.50 being stable version , released on 22 August 2019.

This language grew in popularity on Android due to its perfect compatibility with Java 6, which is the present version of Java on Android. In addition to this, Kotlin provides some features that are only in Java 8, and are thus not available to the Android mobile app developers on Java 6.

In the closet full of ‘All that is good about Kotlin programming language,’ the two most important qualities of Kotlin entail flawless and seamless interoperability with Java. You can call Java code from Kotlin and vice versa without any frowns or hiccups, not to mention the in-built null safety feature. Not seeing a NullPointerException is the dream of every Android app programmer.

Android mobile app development is transformed completely into a blissful, non-NPE experience. If you need to know some details as to how the null safety concept works, check it out here . That is also one of the reasons for Google adopting Kotlin as an officially supported language of Android.

What is Scala:

RbmEfev.jpg!web

It is a functional and hybrid object-oriented programming language, with emphasis on functional programming preferences like laziness and immutability. Scala evolved to the general public in 2004. Created by Martin Odersky, Scala programming language was released on the Java platform for general-purpose. The Scala is not any whimsical notion, it’s an abbreviation of “ Scala ble”: a language that is scalable as per the needs of users.

The early release of Scala surely gave it the advantage of maturing more over the time and taking the spotlight from the Kotlin programming language.

The Scala programming language has some common features with the Kotlin like higher-order functions, conciseness of code, FP functionality with an OOP style, and interoperability with Java programming language (though not as good as Kotlin).

Programming languages with a multi-paradigm approach offer immense power to resolve problems with the same intensity. Both Scala and Kotlin provide many more facilities, including functional constructs and meta-programming. Although they are multi-paradigm & powerful languages require more app developer discipline on enterprise-grade projects. These support many different abstractions that are widely used by the developers to build different variants in the libraries. Have a look at interest over time of these two popular programming languages:

BrUjamV.jpg!web

Distinguishing Kotlin vs. Scala

Slant.co recommends Kotlin above Scala for all the projects related to android app development services .

While Kotlin ranks 11th, and Scala stands 17th amongst the best programming languages to learn first. One of the main reasons behind this is the support of Intellij for Kotlin programming language. Another reason to choose Kotlin as a programming language is that it works well with existing Java programming tools such as Maven, Eclipse, Gradle, Android Studio, to name a few.

Scala: Ranking & Applications

Scala rebounded in popularity following the Java 8 (that majorly supports stream and lambdas functions). A-List startups have already shown interest making it one of the most desired programming languages in the year 2019. Brands that are using Scala include: Twitter, Foursquare, LinkedIn, Tumblr, The Guardian, Netflix, Sony, Airbnb, precog, Klout, Uber, Verizon, Meetup.com, Apple, Remember The Milk, Gilt, New York Times, The Swiss bank UBS, SoundCloud, Huffington Post, Autodesk, Morgan Stanley, etc. Popular Scala frameworks include Akka, Play, and Spark is also helping companies adopt Scala for mobile app development and Big Data solutions.

Pros:

  • Full Support for Macros, Pattern Matching, and Higher-Kindred Types
  • Write Once, Run Everywhere
  • Operator Overloading
  • Bigger Community Support

Cons:

  • Slow Compilation
  • Less Efficient in the Management of Null Safety
  • Binary Compilation Is Challenging

Kotlin: Ranking & Applications

Kotlin, which has partially succeeded Java in functional and object-oriented paradigm, inherited most of the basics and adding to its versatility, the Stack Overflow Survey 2018 made it the second most-liked language and one of the fastest-growing programming languages ​​in the world. Google bets best on Kotlin for upcoming enterprise support. But this previous one is still a byword for the Android mobile app development community.

Companies using Kotlin include Gradle, Uber, Atlassian, Evernote, Corda, Pinterest, Coursera and Pivotal, etc. Popular Kotlin frameworks include Spek, Kanary, Klaxon, Query, Kotlin NoSQL, Kotlin-Core, etc. are also helping mobile app development companies adopt Kotlin for web development.

Pros:

  • Write expressible, concise, and efficient code.
  • It provides all the features of the functional and object-oriented paradigm.
  • Java and Kotlin codes are inter-convertible, which makes this language succeed Java efficiently.
  • Kotlin code looks similar to Java and behaves like C/C++, which makes it endure all the features of object-oriented.

Cons:

  • Extra Runtime Size
  • It does not support pattern matching.
  • Initial Readability of Code
  • Lack of official support (Google doesn’t support it, although it has joined hands with Jet-brains in order to support Kotlin)
  • The absence of proper function types (SAM Conversions)
  • The absence of raw types
  • Lack of invariant arrays

ARvQzuY.png!web

Strengths of Scala:

1. Bigger Community

Being around for 15 years made Scala a familiar face in the JVM technology landscape. Many app developers either work with this framework or work with it, either on their own mobile app or with others. This means more tutorials, more resources, and more (useful) answers on Reddit and StackOverflow.

2. Pattern Matching & Big Math

Calling itself “Java’s switch on steroids”, Scala’s match statement lets you match with any type of data, including your own types. In addition to this, it offers full support for higher-kind and macros types, making Scala ideal for big data processing tasks.

3. Flexible Syntax

Scala was creatively designed to successfully marry OOP and functional paradigms and does so well. Arriving on JVM’s paradigm promise of “write once, run anywhere”, and combine it with a functional coding, Scala lets you build the best of both worlds in your code.

Weaknesses of Scala:

1. Slow Compilation Speed

According to a scala developer, “Scala has all the right features, but its main drawback is the very slow compilation.” And this app developer is not the only one. When it comes to complex programs, it can take a Scala framework long minutes to compile that Java and Kotlin handle in just a few seconds.

2. Inferior Java Compatibility

If you are planning to move back and forth between legacy Java programming language code and advanced Scala programming language code, you may run into some trouble. While Kotlin was carefully designed for compatibility, Scala provides functional programming and classes that you will probably need to run into errors when calling from Java.

3. Null Safety Management Inefficiency

One main argument in favor of JVM programming languages as an alternative to Java programming language is how they handle hate-bound NPEs. When it is compared to Kotlin, many find Scala’s approach naïve and incompetent. In order to deal with NPE, Scala substitutes null values with the option, which adds some major complexity to the code as it requires to be used explicitly.

Strengths of Kotlin:

1. Corporate Backing

Say what you would say about the cooperation power in the academic field, it can’t be compared to the corporate support strength. Supporting the Kotlin ecosystem with JetBrains and Google (which brought you the Intellij IDE) has undeniable advantages.

2. Superior Java Interoperability

As it is mentioned in the introduction, one of the main strengths of Kotlin is its complete compatibility with Java code. You can say Kotlin code from Java programming language and vice versa there is no problem or error.

3. Concise Coding

One of the major pain points of Java programming language is that Kotlin addresses are boilerplate code. Kotlin simply has a lesser part of it. With fewer code lines, there is less space for the bugs that also makes the code easier to read.

Weaknesses of Kotlin:

1. Inferior Pattern Matching

Pattern matching is not supported fully in the Kotlin platform and is clearly nuanced from the Scala in this regard. When it’s possible to achieve similar results with Clauses’ smart mobile application, Scala’s ease of use and matching capabilities are far ahead.

2. Smaller Community

While it is growing quite quickly, the Kotlin community still has some catching up with that of Scala. Although Google’s support of Kotlin as the language for Android greatly boosted its popularity among developers and businesses, a new community may mean fewer tools, tutorials, and experts can lend a hand when required.

3. Limited Usability

Kotlin is king when it comes to Android mobile app development. Its entire ecosystem is geared towards Android mobile apps. But what about other mobile applications? It is not so great outside of the Android world, and it is still not as useful or applicable as Scala.

Let’s Wrap Up:

I hope this blog gives you a clear idea about these two popular JVM languages and helps you choose the right tool for your next app development project. If you want to have your own app created using these JVM languages, you should go for a trusted mobile app development company or you can hire a mobile app developer for your project. But, you should keep in mind to have a trusted company or skilled developer to have the best app development services.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK