Can someone tell me the status of multidimensional array in Kotlin?


#1

Hello everyone,

Kotlin has been very nice, but it has never been without some short-comings, one of which is the support for a multidimensional array. The simplest use case is the 2-dimensional array which can be used for many purposes. For example, we can use it to store the pixel matrix of a picture, to represent a graph, to simulate a chess board or most popularly is its use for matrix operation in mathematics which can be used for Machine Learning. A feature with so many use cases, why have Kotlin not supported it yet?

And more importantly, this has been the fundamental feature of many programming languages, C/C++, Pascal, C#, and even Java, the language that Kotlin aims to be better. Or even in Python, numpy allows us to easily work with 2D array, and the sames applied for Matlab, Julia. It is a very basic feature that one could expect from a programming language.

It seemed that this question was already asked in 2014, and 4 years later, we still have heard nothing about it. If possible, can someone tell me Jetbrains’ reason for not supporting it and if they have planned it already, what is the current status?

Thank you.


#2

Kotlin does not have multi-dimensional array (if you do not count Array<Array<>> notation which works fine but looks ugly) and I do not think that wrapping Java multi-dimensional array with some special syntax is a good solution. At least not for mathematics and scientific purposes. Kotlin has a nice tradition of implementing such features on a library level, and I think we should honor it.
I’ve started a project for some mathematical features here. And it has some starting infrastructure for numpy-like NDArrays. Sadly, I am very short on free time right now, so feel free to join the discussion or introduce new ideas. I am hoping to make some progress with the library on summer.


#3

@darksnake Is it possible to become a contributor? I am also short in time, but since I am really really really really really really really really really really really really really really… (repeating infinite times) frustrated with this issue, so I want to help implement it also. And have you put it to Maven yet?


#4

Contribution is indeed needed. Especially in design. Current design idea for NDArray is here. But we need to understand what operations we need on those arrays. Do we need special class fro 2d arrays? I intended to wrap commons math linear algebra, but it is rather heavyweight and maybe we do not need it for many things.

Further discussion could be done in the repository.