Hacker News new | past | comments | ask | show | jobs | submit login

I don't think it really works to think of Kotlin as a functional language. It's really more of a modern OO language that happens to have borrowed a couple more-or-less cosmetic things (default constructors, companion objects) from Scala.

Modern OO has adopted many things from FP, but I'm sure there's an old Smalltalker waiting in the wings, ready to come out and observe that a lot of this is equivalent to Renaissance Europeans rediscovering a lot of ancient Roman texts by reading their Arabic translations.




> I don't think it really works to think of Kotlin as a functional language. It's really more of a modern OO language that happens to have borrowed a couple more-or-less cosmetic things (default constructors, companion objects) from Scala.

My baseline for a "functional language" is ML; wikipedia's description of it opens "Features of ML include a call-by-value evaluation strategy, first-class functions, automatic memory management through garbage collection, parametric polymorphism, static typing, type inference, algebraic data types, pattern matching, and exception handling." Kotlin notably has all of those, and equally notably doesn't really have any other central, language-defining features (with the possible exception of delegation); in many ways the core languages is no more or less than ML.

> Modern OO has adopted many things from FP, but I'm sure there's an old Smalltalker waiting in the wings, ready to come out and observe that a lot of this is equivalent to Renaissance Europeans rediscovering a lot of ancient Roman texts by reading their Arabic translations.

Disagree; these ideas are not borrowed from Smalltalk, they were present in ML (ML and Smalltalk are contemporaries but quite independent of each other) which retains its own distinct lineage. Scala and Rust are openly of ML descent, and I think Swift also acknowledges an ML influence.


Is Kotlin's type inference and destructuring more powerful than what they describe in the tutorials? I have only spent a little time with it, but my take-away was that it had much weaker type inference (more similar to C#'s than ML's), and its version of pattern matching was rather limited compared to what you get in ML. And most of the rest of that feature list is also shared with Java.

Moreover, as far as language-defining features, it's hard to ignore how OO the type system is. Working with Kotlin, you won't be dealing exclusively with algebraic types and modules; you'll be dealing heavily in classes and interfaces and extension methods and all that.

For similar reasons, I hesitate to call Scala a true ML descendant. It takes a lot of obvious inspiration from ML, but the standard libraries are all intensely OO in their idiom, the type inference is still quite limited, etc. You can program in a very functional style in Scala if you want, but Odersky is pretty explicit about that not being what he was really about, and if you want to have a good time of it you'll want to be importing Scalaz or Cats rather than relying too much on the standard libraries.


Actually Odersky has been pretty explicit about Scala being related to OCaml, which is certainly a true ML descendant.

https://twitter.com/odersky/status/598224956636450816


Unless things have changed really recently, Kotlin does not have pattern matching, which definitely disqualifies it from being an ML-alike.

https://youtrack.jetbrains.com/issue/KT-20004#tab=Comments

https://discuss.kotlinlang.org/t/destructuring-in-when/2391/...

It's especially disappointing that the supposed reason was it was "too complex"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: