Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Use Kotlin #26

Open
oleersoy opened this issue Oct 24, 2017 · 9 comments
Open

[Feature Request] Use Kotlin #26

oleersoy opened this issue Oct 24, 2017 · 9 comments

Comments

@oleersoy
Copy link
Contributor

oleersoy commented Oct 24, 2017

Kotlin has a lot of slick features, like eliminating the need for builders, etc. through named arguments, that I think would be useful for Hipparchus. Also you can compile to both Javascript and various versions of JVMs. See:

https://stackoverflow.com/questions/46858270/does-there-exist-a-babel-like-compiler-for-java
https://stackoverflow.com/questions/46892929/are-number-operations-using-kotlin-as-fast-as-the-equivalent-with-java-primitive

General info:
https://medium.com/@magnus.chatt/why-you-should-totally-switch-to-kotlin-c7bbde9e10d5

The val property (Non modifiable properties) will be really helpful in thread safe designs ...

Could compile to Javascript / Typescript and publish on NPM - which should bring more contributors into the fold.

@maisonobe
Copy link
Contributor

I didn't know about Kotlin.
The one thing I would love is its operator overloading feature. It would really help using our RealField implementations (I do use DerivativeStructure a lot). It seems powerful (it even has things like +=), but still seem to lack infix functions without parameters (i.e. you can't replace x.cos() with cos(x)).

@oleersoy
Copy link
Contributor Author

oleersoy commented Nov 4, 2017

Yeah I just came across it a week ago catching up on some Reactive programming with Spring. It looks like a lot of fun to program with. All the latest Java goodies, but far less verbose, and great support from IntelliJIdea (The creators). And as I mentioned you can choose to compile to any Java runtime, so kiss the "Should we move to Java ... discussion" goodbye. Should help a lot with the fluid API stuff too, as constructors support named arguments. Also IntelliJ lets you auto convert java files to Kotlin. Just cut past convert.

@oleersoy
Copy link
Contributor Author

oleersoy commented Nov 4, 2017

Compiling to Javascript could add a lot of value as well. For example searching for linear programming on https://www.npmjs.com/ leads to packages / modules like:

https://www.npmjs.com/package/javascript-lp-solver

This has very good documentation and ( I just found it) looks like its very easy to use and play around with. So if Hipparchus compiles to javascript and releases to NPM it gets a whole new set of testers / users.

@oleersoy
Copy link
Contributor Author

oleersoy commented Nov 5, 2017

Incidentally I created a hipparchus-math organization on NPM just so that no one else grabs it. It enables packages to live under @hipparchus-math instead of the global package namespace.

So for example the package.json (similar to maven pom.xml) file for a module would have a name field set to "name": "@hipparchus-math/optimization" and to publish the module the publisher would just type npm publish and the package is now available on NPM.

@wardev
Copy link
Contributor

wardev commented Nov 6, 2017

At this point I'm not for or against the proposal, but I think there are a couple more points to consider.

Using Kotlin would add a runtime dependency for Hipparchus because Kotlin comes with its own standard library. This would be Hipparchus' first external dependency.

As far as I can tell the only IDE with good support for Kotlin is IDEA, which means all Hipparchus developers would be forced to use IDEA. I don't mind because I already use it, but we should make sure the other developers are OK with it.

We currently have extensive tooling that works well for Java, i.e. Javadoc, JXR, Findbugs, Jacoco, and Checkstyle. Are there equivalents for Kotlin? Or do our existing maven plugins support Kotlin?

@oleersoy
Copy link
Contributor Author

oleersoy commented Nov 6, 2017

Wow - I did not know it created a runtime dependency - thanks for pointing that out.

There is an eclipse plugin for kotlin - although it looks fairly new. Atom also has a syntax highlighter (lightweight tasks).

When I looked up static code analysis for Kotlin I came across detekt which looks interesting.

There's also Dokka for documentation. Once you start getting into the Javascript / Typescript world there are some crazy good tools - like compodoc for Angularjs. Kotlin looks a lot like Typescript so I suspect we'll see a lot more goodness like that arriving in the Kotlin ecosystem.

Kotlin has ktlint for linting.

@oleersoy
Copy link
Contributor Author

oleersoy commented Nov 6, 2017

Another thing to consider is that it's really easy to prototype and play with code in Typescript and Javascript. For example checkout this How to make a blockchain in 15 minutes video. So with these types of capabilities there's a lot more ways to triangulate on / tool up code creation, testing, distribution, and maintenance activities.

Having the code base in two different format allows CI to run different tool sets against the code bases. On commit Kotlin could automatically compile to Javascript / Typescript and tools that are built for these domains could be automatically run by Travis.

@shiMusa
Copy link

shiMusa commented Apr 20, 2020

Hi all,
I'm using (until now, changing that now) the Apache Math library in Kotlin for my research and really, Kotlin makes so many things so much easier, especially higher-order functions would be awesome for this kind of math (instead of using classes for everything e.g.). Another feature is the very easy to use coroutine system for parallel execution.
In addition to JS, there is also the thought of using Kotlin-Multiplatform such that the math can be run natively.
I don't suggest rewriting the whole library in Kotlin, but some Kotlin wrappers would already be amazing ;)

Hope this project keeps growing! Good luck :)

@HankG
Copy link
Contributor

HankG commented Apr 27, 2020

@shiMusa I'm a huge fan of Kotlin and use it on JVM projects when I have the choice. Is there something that the standard Java bridge in Kotlin isn't doing well or you are saying adding some Kotlin specific decorators could make it even better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants