-
Notifications
You must be signed in to change notification settings - Fork 1k
[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
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e324add
[doc] improve strong typing sentence
robstoll 15d8daa
[doc] use site.scala3ref for the link
robstoll a652ef4
[doc] fix typo collections classes
robstoll ee45e43
[doc] typo and comments
robstoll 6b5fac9
[doc] @alpha is now called @targetName
robstoll ff17b9b
[doc] link @targetName
robstoll 018a861
[doc] put more focus on what a user does not have to do due to strong…
robstoll 2549abf
Update _overviews/scala3-book/scala-features.md
robstoll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 which 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: | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 %} | ||
|
||
|
||
|
@@ -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 | ||
|
@@ -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]. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.