Live data from Hacker News

Kotlin for data analysis

kotlinlang.org

81–90 of 105 posts

Re: Kotlin for data analysis

#81
post #65

Earlier quoted context omitted.

Kotlin's standard library has ruined me for other languages, especially its collections library. The consistency and comprehensiveness of its approach to collections is unmatched in any language I've tried, including all the big name functional languages. It's hard to get across what's so great about the library in writing because it's not just one standard library function, it's how they all interact with each other…

Couldn't agree more if I tried. Scope functions are also great. And the syntactic sugar where `foo({ a -> a })` and `foo { a -> b }` are the same makes code so much more readable. I've done Python for a project at a previous job for a few months and it made me realize just how awful Python is, especially because you can't chain functions on collections as easily as you can in Kotlin. I also made me realize that I don…

> And the syntactic sugar where `foo({ a -> a })` and `foo { a -> b }` are the same makes code so much more readable.

That's 1-to-1 copied from Groovy by the way :)

Re: Kotlin for data analysis

#83

My issue with Kotlin is the same as my issue with Groovy. Both are interesting and definitely something new, but... under the hood it's JVM and come with the Java baggage. Some see it as an advantage, I see it as a burden. My clients are using mostly Python and Golang and I have grown to like simple toolchains and the results I am getting. Another point against Kotlin is the fact that my clients like to keep things s…

Same. I like Kotlin and used it for AOC, but I dislike the JVM. A great standalone Kotlin would be one of my most used languages.

Great languages don't exist in isolation.

Kotlin without its main platforms (JVM and Android) and the ecosystem of Java libraries doesn't stand a chance against the current landscape of modern hybrid languages. Unless something major happens on the WebAssembly front maybe, but even there I don't see how Kotlin would be particularly well positioned.

Re: Kotlin for data analysis

#84

Earlier quoted context omitted.

I work in a codebase that’s mostly kotlin and python and I’ve come to hate the python side. I used to love python, but I feel like the attempts to tack on typing have really undermined it. The “freedom” of being untyped is nice for quick little scripting things, but being typed is an absolute godsend in a real codebase. Instead of making python pseudo-typed with messy annotations, the scientific/research community sh…

Yes but it's reasonable that they didn't. For quick hacky scripts you really want a lightweight syntax that supports interactive REPL exploration. Kotlin is the first language that manages to combine a strict static type system with a Python-weight syntax, and there's a REPL too although I don't think it gets much use. These days notebooks are a better replacement for REPLs anyway when doing data analysis, but Kotlin…

Kotlin isn't the first language offering any of these features, not even remotely.

Even if you look only at the JVM: Scala is much older.

Re: Kotlin for data analysis

#85

Earlier quoted context omitted.

I think both languages have their strengths. I love Kotlin for its functional programming (map, filter, etc) and strong static typing. But Python has some nice features as well, such as list comprehension, the 'yield' keyword, and annotations are super simple to implement.

> the 'yield' keyword Am I missing something here? $ cat fib.kts fun fib() = sequence { var a = 1; var b = 1 while (true) { yield(a) a = b.also { b += a } } } println(fib().take(10).joinToString(" -> ")) println(fib().first { it >= 50 }) $ kotlin fib.kts 1 -> 1 -> 2 -> 3 -> 5 -> 8 -> 13 -> 21 -> 34 -> 55 55 Of course, yield() is a function in Kotlin, not a keyword, but the same functionality is there.

I had no idea Kotlin could do this. I never thought to check. I guess with Kotlin being a JVM language, I simply assumed it wasn't possible.

Thank you for providing an example because I was a little confused by a couple other comments mentioning yield...

Re: Kotlin for data analysis

#86

Earlier quoted context omitted.

Hmm, coroutines are definitely a bit of a mess, but in ways that aren't super relevant when you just want to use them and not implement a framework on top of them. They definitely sacrificed implementation simplicity in favor of interface simplicity. > don't even try to tell me that anyone uses sealed classes in practice I use sealed classes for errors all the time. > Nothing is concurrency safe. Yes, but I know of n…

> I don't like how the default for the collection combinators is to be eager. Isn't this solved by using Sequences instead?

Yes, but I took their use of "default" to mean that there's slightly more friction to a sequence. It does seem a bit petty given how little friction there is, though.

Re: Kotlin for data analysis

#87
post #41

I do both Kotlin and Python. More Kotlin than Python to be honest. But I'm pragmatic. Python is where all the action is when it comes to data science, llms, and all the rest. So it's the path of the least resistance. And there's a great argument to not challenge that and just do what everybody else does and put your head down and not criticize any of that. Which is why I use it on a few projects. The library ecosyste…

> The interpreter is not that fast, the language is not that expressive, what passes for package management is a bad joke, etc. I can work with it but I'm not necessarily loving it. These are rather disingenuous criticisms of python. The utility of any language is measured by its use as a means to some end. It's clear that Python's ecosystem has prospered not just because it's a fad, but because it's actually useful.…

Python in data is similar to C in systems: it's not the best language for the job, but it was good enough at a critical point in history that it became the standard by happenstance—there weren't enough things wrong with it to repel the Brownian motion of developers from seeding the ecosystem—and now it's the best language for the job because it's the standard.

> These are rather disingenuous criticisms of python. The utility of any language is measured by its use as a means to some end. It's clear that Python's ecosystem has prospered not just because it's a fad, but because it's actually useful. Not perfect, but useful.

Your criticisms of OP's argument are more disingenuous than OP: no one said Python was a fad or that the ecosystem wasn't useful. See here:

> Python is where all the action is when it comes to data science, llms, and all the rest. So it's the path of the least resistance. And there's a great argument to not challenge that and just do what everybody else does and put your head down and not criticize any of that. Which is why I use it on a few projects. The library ecosystem is great.

They're just saying that Python-the-language isn't their favorite (largely subjective but with a lot of agreement from much of the community) and they mention offhand that Python's package management is a disaster (which is 100% accurate).

Re: Kotlin for data analysis

#88

I do both Kotlin and Python. More Kotlin than Python to be honest. But I'm pragmatic. Python is where all the action is when it comes to data science, llms, and all the rest. So it's the path of the least resistance. And there's a great argument to not challenge that and just do what everybody else does and put your head down and not criticize any of that. Which is why I use it on a few projects. The library ecosyste…

What about position, with kotlin language support: https://i.imgur.com/SjbtX2z.png https://www.andrewheiss.com/blog/2024/07/08/fun-with-positro...

The vs code support for Kotlin is pretty bare-bones compared to the IDE. And I'm guessing positron reuses the extension for that; so not that interesting to me.

Part of the appeal of Kotlin is Intellij offering an enormous amount of smart features that other IDEs simply don't have at all for any language.

Re: Kotlin for data analysis

#89

Earlier quoted context omitted.

Same. I like Kotlin and used it for AOC, but I dislike the JVM. A great standalone Kotlin would be one of my most used languages.

Great languages don't exist in isolation. Kotlin without its main platforms (JVM and Android) and the ecosystem of Java libraries doesn't stand a chance against the current landscape of modern hybrid languages. Unless something major happens on the WebAssembly front maybe, but even there I don't see how Kotlin would be particularly well positioned.

True, but the JVM is so cumbersome that I will use something else instead.

Re: Kotlin for data analysis

#90

Earlier quoted context omitted.

Yes but it's reasonable that they didn't. For quick hacky scripts you really want a lightweight syntax that supports interactive REPL exploration. Kotlin is the first language that manages to combine a strict static type system with a Python-weight syntax, and there's a REPL too although I don't think it gets much use. These days notebooks are a better replacement for REPLs anyway when doing data analysis, but Kotlin…

Kotlin isn't the first language offering any of these features, not even remotely. Even if you look only at the JVM: Scala is much older.

I think the point is Kotlin incorporated great stuff from a few languages, Scala being one of them.
Post reply on HN