-4

Apart from object oriented can it support procedural and functional programming styles?

I want to develop an android app using Android Studio so I could explore various programming styles kotlin has to offer which would really help me explore this new language.

Thanks for taking your time read/answer this question and sorry if I sound noob as I'm a beginner to the world of programming!

Ruby
  • 131
  • 1
  • 7

3 Answers3

3

From Kotlin FAQ:

Is Kotlin an object-oriented language or a functional one?

Kotlin has both object-oriented and functional constructs. You can use it in both OO and FP styles, or mix elements of the two. With first-class support for features such as higher-order functions, function types and lambdas, Kotlin is a great choice if you’re doing or exploring functional programming.

Community
  • 1
  • 1
hotkey
  • 140,743
  • 39
  • 371
  • 326
  • Thanks for your response. Also any idea how do I implement procedural programming? – Ruby Oct 20 '17 at 13:35
  • I'm not sure I understand what exactly you want to achieve. For an overview of the Kotlin language features, see the language reference. The feature that is typical for procedural style is [top-level-declarations](https://kotlinlang.org/docs/reference/visibility-modifiers.html#packages). – hotkey Oct 20 '17 at 14:44
  • Actually I'm trying to implement procedural, functional and object oriented paradigms – Ruby Oct 20 '17 at 14:45
2

I have to agree that the question is a little confusing. Here is what I'm seeing as I study Kotlin in Android:

  • The vast majority of actions appear to be triggered by listeners

  • The listeners are (usually) contained within classes and the majority of things are done using classes (OOP)

  • There are a lot of functions that aren't contained within classes and they get called frequently (Procedural)

  • There is an aversion to using variables that are outside the scope of a given function or class, trying to remain true to a functional approach

Other than that, I'm not really sure what you're asking.

scottstoll2017
  • 1,077
  • 10
  • 14
1
  1. Most anything you can do with Java (OO, Proc) is possible with Kotlin.

  2. Kotlin supports High-Order, Lambdas and Closures, so while it might not be considered a functional language in a strict sense, you can use a lot of functional concepts to get your coding done. See Higher-Order Functions (https://kotlinlang.org/docs/reference/lambdas.html)and Lambdas in the Kotlin doc.

Vrushali Raut
  • 1,130
  • 1
  • 10
  • 20