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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions _overviews/scala3-book/scala-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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).


{% comment %}
In that list:
Expand Down Expand Up @@ -202,21 +202,23 @@ Scala is a functional programming (FP) language, meaning:
- Lambdas are built in
- Everything in Scala is an expression that returns a value
- Syntactically it’s easy to use immutable variables, and their use is encouraged
- It has a wealth of immutable collections classes in the standard library
- Those collections classes come with dozens of functional methods: they don’t mutate the collection, but instead return an updated copy of the data
- It has a wealth of immutable collection classes in the standard library
- Those collection classes come with dozens of functional methods: they don’t mutate the collection, but instead return an updated copy of the data


### A pure OOP language

Scala is a _pure_ object-oriented programming (OOP) language.
Every variable is an object, and every “operator” is a method.
Every variable is an object and every “operator” is a method.

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.

- probably not worth to mention (too advanced at this point) there is AnyKind
- Add the “types hierarchy” image here?
{% endcomment %}


Expand All @@ -226,7 +228,7 @@ Add the “types hierarchy” image here?
NOTE: This text in the first line comes from this slide: https://twitter.com/alexelcu/status/996408359514525696
{% endcomment %}

The essence of Scala is the fusion of functional programming and object-oriented programming in a typed settings:
The essence of Scala is the fusion of functional programming and object-oriented programming in a typed setting:

- Functions for the logic
- Objects for the modularity
Expand Down Expand Up @@ -330,7 +332,7 @@ At a “sea level” view of the details---i.e., the language features programme
- Export clauses provide a simple and general way to express aggregation, which can replace the previous facade pattern of package objects inheriting from classes
- The procedure syntax has been dropped, and the varargs syntax has been changed, both to make the language more consistent
- The `@infix` annotation makes it obvious how you want a method to be applied
- The `@alpha` method annotation defines an alternate name for the method, improving Java interoperability, and letting you provide aliases for symbolic operators
- The [`@targetName`]({{ site.scala3ref }}/other-new-features/targetName.html) method annotation defines an alternate name for the method, improving Java interoperability, and letting you provide aliases for symbolic operators

It would take too much space to demonstrate all of those features here, but follow the links in the items above to see those features in action.
All of these features are discussed in detail in the *New*, *Changed*, and *Dropped* features pages in the [Overview documentation][reference].
Expand Down Expand Up @@ -500,4 +502,3 @@ As this page shows, Scala has many terrific programming language features at a h