Skip to content

[doc] improve strong typing sentence #1981

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 8 commits into from
May 10, 2021
Merged

[doc] improve strong typing sentence #1981

merged 8 commits into from
May 10, 2021

Conversation

robstoll
Copy link
Contributor

@robstoll robstoll commented Apr 9, 2021

My go at improving the sentence about strong types which has an open TODO

@robstoll
Copy link
Contributor Author

robstoll commented Apr 9, 2021

The build failure looks foreign to my change

@joroKr21
Copy link
Member

joroKr21 commented Apr 9, 2021

The build failure looks foreign to my change

The fix was merged: #1980

@robstoll
Copy link
Contributor Author

robstoll commented Apr 9, 2021

@joroKr21 thanks, now I need a rebase-feature on github so that I can rebase my branch via web-gui :D

@robstoll
Copy link
Contributor Author

robstoll commented Apr 9, 2021

please let me know in case a rebase of the branch is necessary. I would prefer if I don't have to checkout the project (do everything from the web-gui)

@joroKr21
Copy link
Member

joroKr21 commented Apr 9, 2021

please let me know in case a rebase of the branch is necessary.

I would assume so. I've also found myself often enough wishing GitHub would provide this UI.
I wonder if Codespaces would work in this project.

@SethTisue
Copy link
Member

It's fine to merge this without worrying about the CI failure, since it's clearly unrelated.

However before we merge let's (hereby) ask @alvinj for a review, since this is an especially prominent part of the book.

Also there is one wording here I'm not really comfortable with: "where the compiler kind of writes code for you" — we don't require super-formal language on the site, but I think that's too loose a wording. perhaps "the compiler supplies method arguments for you"?

@robstoll
Copy link
Contributor Author

@SethTisue I see your point but speaking only about method arguments is too narrowed IMO as the compiler does more e.g. in case of typeclass derivation. How about I change it to:
where the compiler synthesizes code for you (e.g. supplying method arguments in case of implicit parameters)

@martijnhoekstra
Copy link
Contributor

Emphasizing what the programmer doesn't have to do, rather than what the compiler does, makes more sense to me for user-facing documentation.

In this case, that's omitting terms that can be inferred from their type and the context.

@robstoll
Copy link
Contributor Author

@martijnhoekstra do you have a concrete idea how to phrase it?

@martijnhoekstra
Copy link
Contributor

Maybe "Strong types allows you to omit things that the language can infer from the type and the context, like given parameters or the availability of extension methods"?

@martijnhoekstra
Copy link
Contributor

using totally should have been called context. Let me quickly make a contributors thread for that.

@alvinj
Copy link
Contributor

alvinj commented Apr 11, 2021

Hi @SethTisue, I’m a little swamped with a project deadline coming up this Tuesday, but I’ll be glad to look at this on Wednesday. Or, feel free to go with whatever you all think is good. 👍

@SethTisue
Copy link
Member

no rush

… typing

...in combination with type inference
Copy link
Contributor

@b-studios b-studios left a comment

Choose a reason for hiding this comment

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

LGTM I would just break down this sentence, since it became quite long :)

Co-authored-by: Jonathan <jonathan@b-studios.de>
@@ -136,7 +136,7 @@ Because Scala is considered to be a [strong, statically-typed language](https://
- Method type declarations tell readers what the method does, and help serve as documentation
- Types make your code easier to maintain
- Scalability: types help ensure correctness across arbitrarily large applications and development teams
- Strong types enable Scala features like implicits (TODO: I need help on this wording and description)
- Strong typing in combination with excellent inference enables mechanisms like [contextual abstraction]({{ site.scala3ref }}/contextual/motivation.html) that allows you to omit boilerplate code. Often, this boilerplate code can be inferred by the compiler, based on type definitions and a given context (e.g. method arguments for implicit parameters).
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, maybe you can use {% link _overviews/scala3-book/ca-contextual-abstractions-intro.md %} to point to the book chapter? This has the advantage of being a checked link that is easier to maintain.


In Scala, all types inherit from a top-level class `Any`, whose immediate children are `AnyVal` (_value types_, such as `Int` and `Boolean`) and `AnyRef` (_reference types_, as in Java).
This means that the Java distinction between primitive types and boxed types (e.g. `int` vs. `Integer`) isn’t present in Scala.
Boxing and unboxing is completely transparent to the user.

{% comment %}
Add the “types hierarchy” image here?
- AnyRef above is wrong in case of strict null checking, no? On the other hand, maybe too much information to state this here
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it is too much info here.

@@ -136,7 +136,7 @@ Because Scala is considered to be a [strong, statically-typed language](https://
- Method type declarations tell readers what the method does, and help serve as documentation
- Types make your code easier to maintain
- Scalability: types help ensure correctness across arbitrarily large applications and development teams
- Strong types enable Scala features like implicits (TODO: I need help on this wording and description)
- Strong typing in combination with excellent inference enables mechanisms like [contextual abstraction]({{ site.scala3ref }}/contextual/motivation.html) that allows you to omit boilerplate code. Often, this boilerplate code can be inferred by the compiler, based on type definitions and a given context (e.g. method arguments for implicit parameters).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Strong typing in combination with excellent inference enables mechanisms like [contextual abstraction]({{ site.scala3ref }}/contextual/motivation.html) that allows you to omit boilerplate code. Often, this boilerplate code can be inferred by the compiler, based on type definitions and a given context (e.g. method arguments for implicit parameters).
- Strong typing in combination with excellent inference enables mechanisms like [contextual abstraction]({% link _overviews/scala3-book/ca-contextual-abstractions-intro.md %}) that allows you to omit boilerplate code. Often, this boilerplate code can be inferred by the compiler, based on type definitions and a given context (e.g. method arguments for implicit parameters).

@b-studios
Copy link
Contributor

This PR is lying around already quite some time and I apologize. Let me just merge it and let's open new PRs for further improvements.

@b-studios b-studios merged commit b90e960 into scala:main May 10, 2021
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.

6 participants