Live data from Hacker News

Kotlin for data analysis

kotlinlang.org

51–60 of 105 posts

Re: Kotlin for data analysis

#51

Earlier quoted context omitted.

I'm not sure how someone could see Kotlin as more expressive than Python, unless I am misinterpreting what expressive means. Python has a good language features and helpful abstractions like list comprehensions. What makes Kotlin more expressive? I understand it has some functional features but I've never seen anything dramatically flexible.

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…

> Python refuses to implement proper lambdas

Python has lambdas. What do you mean by "proper" lambdas?

Re: Kotlin for data analysis

#52

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…

> Python refuses to implement proper lambdas Python has lambdas. What do you mean by "proper" lambdas?

Lambdas in Python are intentionally second class citizens in that they cannot be full blocks, only a single expression. Technically there's a workaround in that you can define a named function and then refer to it later, but that's enough of a hassle that using lambdas in method calls is much less common in Python than it is in Kotlin.

In Kotlin, much of what would normally be special syntax structures are just function calls that get passed a lambda. That's not possible with Python's single-expression lambda functions, so you get special syntax instead for things like comprehensions.

Re: Kotlin for data analysis

#53

Earlier quoted context omitted.

That's interesting. I've heard complaints about Kotlins standard library in comments like this[1]. I understand they may be nitpicks but they seem annoying in practice. [1] https://www.reddit.com/r/Kotlin/comments/mh2z5u/comment/gt2n...

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…

Thanks for your insight!

Re: Kotlin for data analysis

#54

Earlier quoted context omitted.

I'm not sure how someone could see Kotlin as more expressive than Python, unless I am misinterpreting what expressive means. Python has a good language features and helpful abstractions like list comprehensions. What makes Kotlin more expressive? I understand it has some functional features but I've never seen anything dramatically flexible.

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…

> Kotlin's standard library has ruined me for other languages, especially its collections library

Scala has it beaten by a long shot, in my opinion, and is hands down the best of any language around collections.

Re: Kotlin for data analysis

#56
post #38

Earlier quoted context omitted.

As someone who uses Kotlin for work and Python for side projects (and loved Python years ago in college), Python's list comprehension feature is one of the things I hate the most about the language now. As a simple example using only two collection functions I find it much easier to read val hundredOrLessEvenSeconds = (1..1000) .toList() .filter { it than hundred_or_less_even_seconds = [timedelta(seconds=it) for it i…

import datetime import pandas as pd hundred_or_less_even_seconds = ( pd.Series(range(1, 1000)) .loc[lambda x: x

Frankly much less clearer/less readability than the Kotlin code.

Re: Kotlin for data analysis

#57

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.

The mechanism in Kotlin that allows them to limit yield() to a sequence{} block , without introducing a new keyword, is pretty dang cool.

Re: Kotlin for data analysis

#58
post #49
post #7

I find it odd that kotlin-jupyter notebooks still use the `.ipynb` file extension.

Maybe a little odd, but it did start with Python. I mean, Jupyter stands for Julia, Python, and R already - so it's not too weird they just keep using the same file format.

Jupyterk ;)

Re: Kotlin for data analysis

#59

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…

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…

What kind of codebase would be mostly a Kotlin/Python combo?

Re: Kotlin for data analysis

#60
post #59

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…

What kind of codebase would be mostly a Kotlin/Python combo?

Kotlin Android app with a Python backend for ML stuff, maybe?

Or maybe they're in one of those places that use microservices with a variety of languages

Post reply on HN