r/javahelp • u/ThreeDots3 • Jan 24 '22
Codeless Is it worth rewriting large Java project into Kotlin?
I am working on a web app with backend in Java. The project information are:
~2000 java files
almost 200k lines of code (excluding empty lines)
multimodule maven project and few microservices
currently using Java 11, Spring Boot, Hibernate
It was decided that current code should migrate to Kotlin over time, I am trying to get an opinion on this, but from what I learned so far I think it's not worth the effort to go through migration of this scale. The project has a lot of code and design issues itself, developers (4 total) don't have a lot of experience with Kotlin, some none at all.
My questions are:
Do you think the migration effort would be worth it?
What would be the biggest advantage of having whole code base in Kotlin?
What would be the biggest disadvantage of the migration?
51
u/SuperHolySheep Jan 24 '22 edited Jan 24 '22
No, don't do it. This is gonna take a long time and if the experience levels of other developers is low it's (immo) not worth the risk. And like you said yourself. If the issue is code and design issues, Kotlin isn't gonna magicaly fix all of this.
42
u/abermea Jan 24 '22
6
6
15
u/fletku_mato Jan 24 '22
Do you think the migration effort would be worth it?
No.
What would be the biggest advantage of having whole code base in Kotlin?
Having everything written in same language.
What would be the biggest disadvantage of the migration?
Instead of having a lot of code and design issues, you'll probably have even more of them. It's also likely that your application behaves a bit differenty after the rewrite, unless you have a lot of good unit- & integration-tests.
Just write all new code in Kotlin and don't try to migrate everything at once.
5
u/khmarbaise Jan 24 '22
The question is: Why was it decided to migrate to Kotlin?
What is the advantage you will get? Does it really give you an ROI ?
If it has design issues than invest the time to change the design in small steps ...Hopefully having a lot of unit- integration and end-to-end tests... if you don't have them yet... Really start to write them...
It's much better invested time than migration to a different language in particular with very low experience levels... which will cost more than estimate...
I would in contradiction prepare for migrating to Spring Boot 3.0.0 with JDK17 ... (Spring Boot 3.0.0-M1 already there)...I would check that every dependency/plugin/spring boot version is up-to-date... that is a better plan for the future...
4
u/Fenxis Jan 24 '22 edited Jan 24 '22
It's not a terrible idea in that you will be able to migrate iteratively and you will be able to use the current system as a prototype.
On the downside I don't think you clearly shown why a rewrite would be better; is there a new technology stack that is compeling, is there an epiphany about the architecture, or is there a change in staff/expertise? I'm seeing a solid no across the board.
This smells of RDD: resume driven development.
2
u/sungurse Jan 24 '22
A good rule I follow is that if you never have to touch a working code again, you should not waste time with it.
But from what I understand you guys have to implement new features or fix bugs in this codebase. Thus you can try the Java to Kotlin feature IntelliJ by JetBrains offers. Pretty good converter IMO. There will be parts here and there which can't be converted automatically, but I think the plus side of having to work with Kotlin is way better.
If you don't have experience with Kotlin that would be a good way of gaining that experience. And if it was even decided (probably by management) then you guys should get according time for it. Advantage of working with Kotlin are foundable on the web.
We have all our stuff going with Kotlin and I would never work with Java again if I'm not forced to do so.
Just my two cents
1
u/steave435 Jan 24 '22
The experience will be gained after changing all the code, probably creating issues due to the lack of experience while doing so.
If they want to do this, they should write new code in Kotlin while leaving the old Java alone until they know what they're doing.
1
u/caboosetp Private Java/Code Tutor Jan 24 '22
We have all our stuff going with Kotlin and I would never work with Java again if I'm not forced to do so.
I've never touched kotlin, but I'm with you on the second half. I only use c# for backend now at work.
My only remaining encounters with java are tutoring.
1
1
1
u/loudchopper33 Jan 26 '22
Not sure what you mean by migrate, but from my experience, you can easily copy over Java code into a Kotlin project and the IDE will automatically translate it for you.
-6
u/OhanaUchiha Jan 24 '22
Question. How long have you been coding for because I’m stuck on writing a custom string class -_-
•
u/AutoModerator Jan 24 '22
Please ensure that:
Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
You include any and all error messages in full
You ask clear questions
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.