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

Adds Kotlin language tab for AWS-Lambda documentation #37494

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vanny96
Copy link

@vanny96 vanny96 commented Dec 4, 2023

Description

As Quarkus aims to offer first class support for Kotlin, it would be nice if the documentation was updated to offer code snippets for both Java and Kotlin.

Quite often, in fact, the Kotlin approach to do something is not a 1 to 1 translation from Java. For example, a Checked Template would look like this in Java

@CheckedTemplate
public static class Templates {
    public static native TemplateInstance hello(String name); 
}

While in Kotlin it would require an extra annotation

@CheckedTemplate
object Templates {
    @JvmStatic
    external fun hello(name: String?): TemplateInstance
}

Changes

The most "invasive" change of this PR is the move from coderay to rouge as source-highlighter, as the first doesn't support Kotlin's syntax

Preview

To offer this code snippets, I thought about reusing the "Asciidoctor Tabs" already used for Cli | Maven | Gradle in various pages. Here is how it would look like:
image
image

Going forwards

If the idea is well liked by the team, I'll try to create more PRs to update more of the existing documentation so that it would easier than ever to pick Kotlin as a language for Quarkus!

Copy link

github-actions bot commented Dec 4, 2023

🎊 PR Preview 7cdfd74 has been successfully built and deployed to https://quarkus-pr-main-37494-preview.surge.sh/version/main/guides/

@vanny96 vanny96 marked this pull request as ready for review December 4, 2023 16:55
@gsmet
Copy link
Member

gsmet commented Dec 5, 2023

Hey,

Thanks for this work. I agree it would be nice. My fear is that, as most of the team is not familiar with Kotlin, it's going to be extremely hard to keep these samples up to date. And if we have to ping someone familiar with Kotlin every time we change some Java code in the doc, it's going to be a bit problematic.

Not sure exactly what would be best.

@maxandersen @cescoffier @geoand @gastaldi WDYT?

@geoand
Copy link
Contributor

geoand commented Dec 5, 2023

Very nice indeed!

As to Guillaume's point, since I am likely the person that will often be called upon to review these, I'd be unhappy if that burden fell mostly on me.

@gastaldi
Copy link
Contributor

gastaldi commented Dec 5, 2023

I agree with Guillaume here. Maybe I dreamed about it, but I remember seeing IntelliJ performing translation when pasting a Java code in a Kotlin file already

@maxandersen
Copy link
Member

@gastaldi The translation wouldn't catch the missing annotation would it ?

@maxandersen
Copy link
Member

I like the idea but as others stated - the maintainance and lacking testing of it is not going to be a good look over time.

@gastaldi
Copy link
Contributor

gastaldi commented Dec 5, 2023

@gastaldi The translation wouldn't catch the missing annotation would it ?

I just tested and can confirm that the same code is produced, missing the annotation. Maybe we can simply add a note in this case for Kotlin users? I know it's a PITA but it's better than maintaining several Kotlin snippets in the docs

@vanny96
Copy link
Author

vanny96 commented Dec 6, 2023

Thank you for the appreciation!

I agree with your concerns to one extent, having outdated documentation that nobody feels comfortable mainteining is for sure worse than not having this documentation at all.

On the other hand, I do think it is a bit of a shame though that many of the code snippets provided in the docs wouldn't work when directly translated to Kotlin, and there is nowhere in the documentation that explains the classic "gotchas" of working with this different language (the usual solution is either trial and error or StackOverflow)

Maybe a good compromise, for now, could be to expand the "Using Kotlin" page to include some of the common solutions to try?

We could describe how to handle static methods with the @JvmStatic annotation and other common issues as we discover them

It would be nice if we kept the door open to have code snippets in both languages in the future though, as Kotlin is of course growing in popularity and many developers might be scared away from the lack of "first class" documentation support

@geoand
Copy link
Contributor

geoand commented Dec 6, 2023

I believe that would be a good compromise. We can add stuff we have found over the years that users stumble upon

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

Successfully merging this pull request may close these issues.

5 participants