I too +1 My experience porting a Java project to Kotlin was specific to Android in the past (re: years ago). I recall my general impression of Kotlin to have some extraneous and unnecessary syntactic sugar (What's up with the for/loop keywords?), but it was an overall solid language. I appreciate the terseness and brevity of things like variable declarations w/ implicit data types and `data classes`, which addresses a long standing complaint about Java's overly verbose syntax. Language aside, the automated porting back then wasn't exactly perfect, but a few things have changed since then; 1) the language specification has solidified over the years, 2) tooling has matured, and 3) is manageable to manually intervene if necessary.
> As a side note, because of Oracle's aggressive legal practices, and because they really do want you to think that they own Java (see: Google LLC v. Oracle America, Inc.), using Java in Apache Traffic Control is not really in the spirit of free software. Kotlin is an Apache 2.0-licensed project, so switching to Kotlin would be a true FOSS win for the ATC community. I think the true benefit is moving away from the Java API, which is under such contention, without changing underlying implementation (such as a transition to another, non-JVM, language might incur). On Tue, Jun 22, 2021 at 11:42 AM Chatterjee, Srijeet <srijeet_chatter...@comcast.com.invalid> wrote: > +1 > Sounds like a fun project! > > --Srijeet > > On 6/21/21, 8:43 PM, "Zach Hoffman" <zrhoff...@apache.org> wrote: > > Hi Traffic Control! > > As you all may know, the current implementation of Traffic Router runs > on > Java 8. While coding directly in Java is still done, there are some > reasons > to be critical of Java. > > Java often has very verbose syntax when trying to accomplish simple > things. > This has made the Traffic Router codebase grow larger over time, > leading to > maintainability issues. Also, Java suffers from lack of compile-time > safety > in some ways that more modern languages do not. For these reasons, and > because Java is a very old language, some developers who may otherwise > be > interested in contributing to Apache Traffic Control may be > disinterested > contributing to Traffic Router in particular, simply because they want > to > work with more modern languages that do not have the issues that Java > does. > > Kotlin, a JVM language devised by Jetbrains with the goal of tackling > these > problems, has exploded in popularity in recent years, and Kotlin is > becoming a standard way to use the JVM, with Google choosing it as the > preferred language to for developing Android apps. More importantly, > as the > Intellij IDEA Kotlin plugin lets you convert Java sources to Kotlin > (either > at the file level or an entire project, or anywhere in between), > Kotlin has > become a low-effort way to decrease tech debt across large Java > projects. > > Back to Traffic Router: In order to gauge how we would benefit from > converting Traffic Router to Kotlin (it really is a matter of > *converting*, > not rewriting), I converted all of the tests in the Traffic Router > "Core" > module to Kotlin. You can see the result here (as you can see from > GitHub > Actions, the TR tests all pass): < > > https://urldefense.com/v3/__https://github.com/zrhoffman/trafficcontrol/commits/tr-kotlin__;!!CQl3mcHX2A!UCz457i9stX5A-AP8jvvWo21Rqa43JRsC1jQt_fo5nb07raZxByUR9gAGVPZTI4tGhalAel2$ > > > > Some observations: > - Without any putting any effort into optimizing the existing code, > lines > of code shrunk from 10572 in Java to 10217 in Kotlin. See: < > > https://urldefense.com/v3/__https://github.com/zrhoffman/trafficcontrol/commit/5add06bccc__;!!CQl3mcHX2A!UCz457i9stX5A-AP8jvvWo21Rqa43JRsC1jQt_fo5nb07raZxByUR9gAGVPZTI4tGqGQTevX$ > > > - Because it now includes the Kotlin standard library, the Traffic > Router > RPM size increases from 48MB to 58MB. > - The converted sources benefit from Kotlin's null safety and type > safety > (avoiding wildcard types). See < > > https://urldefense.com/v3/__https://github.com/zrhoffman/trafficcontrol/commit/0c2eec39d9__;!!CQl3mcHX2A!UCz457i9stX5A-AP8jvvWo21Rqa43JRsC1jQt_fo5nb07raZxByUR9gAGVPZTI4tGjjMNj-F$ > > (Kotlin > error resolution) and < > > https://urldefense.com/v3/__https://github.com/zrhoffman/trafficcontrol/commit/d8a0fd3bca__;!!CQl3mcHX2A!UCz457i9stX5A-AP8jvvWo21Rqa43JRsC1jQt_fo5nb07raZxByUR9gAGVPZTI4tGoysImMb$ > > (Kotlin > warning resolution) for the changes involved. > > As a side note, because of Oracle's aggressive legal practices, and > because > they really do want you to think that they own Java (see: Google LLC v. > Oracle America, Inc.), using Java in Apache Traffic Control is not > really > in the spirit of free software. Kotlin is an Apache 2.0-licensed > project, > so switching to Kotlin would be a true FOSS win for the ATC community. > > So, converting the rest of Traffic Router would be relatively fast and > easy, would result in *no* functionality gained or lost, would leave TR > usage totally unchanged, would make development more enjoyable for > current > TR devs, and would maybe catch the interest of additional devs who > otherwise may not be interested in Traffic Router. > > How does this sound? > > -Zach > >