Skip to content

Compare Scala 2 vs Scala 3 with tabs in Tour of Scala / Basics #2458

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

Merged
merged 1 commit into from
Jul 14, 2022

Conversation

bishabosha
Copy link
Member

use scala 2 vs scala 3 tabs for tour/basics

_tour/basics.md Outdated
Comment on lines 170 to 182
{% scalafiddle %}
{% tabs get-square-string class=tabs-scala-version %}

{% tab 'Scala 2' for=get-square-string %}
```scala mdoc
def getSquareString(input: Double): String = {
val square = input * input
square.toString
}
println(getSquareString(2.5)) // 6.25
```
{% endscalafiddle %}
{% endtab %}

{% tab 'Scala 3' for=get-square-string %}
```scala
def getSquareString(input: Double): String =
val square = input * input
square.toString

println(getSquareString(2.5)) // 6.25
```
{% endtab %}

{% endtabs %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a discussion about whether it is worth showing two tabs for a difference of a couple of braces. I wonder if the other website maintainers have an opinion about that? Should we keep showing just one code example (with braces, so that it compiles with both Scala 2 and Scala 3), or should we highlight this difference between Scala 2 and Scala 3 by showing those separate tabs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @SethTisue you have an opinion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I believe we need some solution here. I don't think it's acceptable for it to be unclear to the reader whether some code is Scala 2 code, or Scala 3 code, or some code that has been carefully made to work on either.

The two basic possible solutions are:

  • have separate Scala 2 and 3 versions of some pages
  • have a single version, but use code tabs

It sounds like in this case it's already decided that we don't want to have separate 2 and 3 versions of the entire page. In that case, I think we should do the tabs.

There is some value in the freedom this gives us to, for example, omit braces from the Scala 3 version. But as I see it, the primary value, the main reason we ought to do this, is to be clear with the reader whether the code is Scala 2 or 3 or both. That's important to do even if the Scala 2 and 3 versions of the code are identical!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback! We decided to not create tabs when the code snippets are identical, to remove some work. I hope this is fine too?

Copy link
Member

@SethTisue SethTisue Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it not have tabs, but still say something like "Scala 2 or 3"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add some banner to the code block to say it works in both?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I'm suggesting, yeah.

@bishabosha bishabosha requested a review from SethTisue July 5, 2022 15:11
@bishabosha bishabosha force-pushed the update-tour-basics-examples branch from 30f18d5 to 69ab6e2 Compare July 6, 2022 09:24
@bishabosha bishabosha changed the title use code tabs for tour/basics Compare Scala 2 vs Scala 3 with tabs in Tour of Scala / Basics Jul 6, 2022
@bishabosha
Copy link
Member Author

I have also replaced some examples where the only difference is dropping the new keyword, and then some paragraph mentions to use case classes to avoid new - so some rethinking should be done there

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

Successfully merging this pull request may close these issues.

3 participants