diff --git a/Gemfile.lock b/Gemfile.lock index 55d8b82a72..4f956e6336 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -279,7 +279,7 @@ GEM concurrent-ruby (~> 1.0) unicode-display_width (1.8.0) uri (0.13.0) - webrick (1.9.0) + webrick (1.9.1) yell (2.2.2) zeitwerk (2.6.7) diff --git a/_config.yml b/_config.yml index aed90af2e1..b27d1b387d 100644 --- a/_config.yml +++ b/_config.yml @@ -15,9 +15,9 @@ keywords: - Document - Guide -scala-version: 2.13.15 +scala-version: 2.13.16 scala-212-version: 2.12.20 -scala-3-version: 3.5.2 +scala-3-version: 3.6.3 collections: style: diff --git a/_data/doc-nav-header.yml b/_data/doc-nav-header.yml index 4f2bbd82cf..772da79703 100644 --- a/_data/doc-nav-header.yml +++ b/_data/doc-nav-header.yml @@ -5,17 +5,6 @@ url: "/getting-started/install-scala.html" - title: Scala IDEs url: "/getting-started/scala-ides.html" -- title: Scala 3 - url: "#" - submenu: - - title: What's New? - url: "/scala3/new-in-scala3.html" - - title: Migrating From Scala 2 - url: "/scala3/guides/migration/compatibility-intro.html" - - title: New Features for Scaladoc - url: "/scala3/scaladoc.html" - - title: Videos and Talks - url: "/scala3/talks.html" - title: Learn url: "#" submenu: @@ -27,8 +16,17 @@ url: "/overviews/scala-book/introduction.html" - title: Online Courses url: "/online-courses.html" - - title: Online Resources - url: "/learn.html" +- title: Scala 3 Migration + url: "#" + submenu: + - title: What's New? + url: "/scala3/new-in-scala3.html" + - title: Migrating From Scala 2 + url: "/scala3/guides/migration/compatibility-intro.html" + - title: New Features for Scaladoc + url: "/scala3/scaladoc.html" + - title: Videos and Talks + url: "/scala3/talks.html" - title: Tutorials url: "#" submenu: diff --git a/_data/footer.yml b/_data/footer.yml index 5e24e08b6d..789017f8b9 100644 --- a/_data/footer.yml +++ b/_data/footer.yml @@ -57,9 +57,11 @@ - title: GitHub url: "https://github.com/scala/scala" - title: Mastodon - url: https://fosstodon.org/@scala_lang - - title: Twitter - url: "https://twitter.com/scala_lang" + url: "https://fosstodon.org/@scala_lang" + - title: Bluesky + url: "https://bsky.app/profile/scala-lang.org" + - title: X + url: "https://x.com/scala_lang" - title: Discord url: "https://discord.com/invite/scala" - title: LinkedIn diff --git a/_fr/getting-started/install-scala.md b/_fr/getting-started/install-scala.md index a94b708cb0..76f7c537f9 100644 --- a/_fr/getting-started/install-scala.md +++ b/_fr/getting-started/install-scala.md @@ -188,7 +188,7 @@ Une fois que vous avez terminé le tutoriel ce dessus, vous pouvez consulter : * [The Scala Book](/scala3/book/introduction.html) ([Lien](/overviews/scala-book/introduction.html) vers la version Scala 2), qui fournit un ensemble de courtes leçons et introduit les fonctionnalités principales de Scala. * [The Tour of Scala](/tour/tour-of-scala.html) pour une introduction des fonctionnalités Scala. -* [Learning Resources](/learn.html), qui contient des tutoriels et des cours interactifs. +* [Learning Courses](/online-courses.html), qui contient des tutoriels et des cours interactifs. * [Our list of some popular Scala books](/books.html). * [The migration guide](/scala3/guides/migration/compatibility-intro.html) pour vous aider à migrer votre code Scala 2 vers Scala 3. diff --git a/_fr/tour/tour-of-scala.md b/_fr/tour/tour-of-scala.md index cb9fb2fcc6..f5d0f5d20a 100644 --- a/_fr/tour/tour-of-scala.md +++ b/_fr/tour/tour-of-scala.md @@ -14,8 +14,8 @@ Ce tour contient une introduction morceaux par morceaux aux fonctionnalités les utilisées en Scala. Il est adressé aux novices de Scala. Ceci est un bref tour du language, non pas un tutoriel complet. -Si vous recherchez un guide plus détaillé, il est préférable d'opter pour [un livre](/books.html) ou de consulter -[d'autres ressources](/learn.html). +Si vous recherchez un guide plus détaillé, il est préférable d'opter pour [un livre](/books.html) ou de suivre +[un cours en ligne](/online-courses.html). ## Qu'est-ce que le Scala ? Scala est un langage de programmation à multiples paradigmes désigné pour exprimer des motifs de programmation communs de diff --git a/_includes/_markdown/courses-coursera.md b/_includes/_markdown/courses-coursera.md new file mode 100644 index 0000000000..403c5e3100 --- /dev/null +++ b/_includes/_markdown/courses-coursera.md @@ -0,0 +1,18 @@ +## Scala Courses on Coursera by EPFL + +The [Scala Center](https://scala.epfl.ch) at EPFL offers free online courses of various levels, from beginner to advanced. + +For beginners: + +- [Effective Programming in Scala](https://www.coursera.org/learn/effective-scala): a practical introduction to Scala for professional developers +- [Functional Programming Principles in Scala](https://www.coursera.org/learn/scala-functional-programming): the foundational course by Martin Odersky, Scala's creator + +More advanced topics: + +- [Functional Program Design in Scala](https://www.coursera.org/learn/scala-functional-program-design): builds on functional principles with more advanced concepts +- [Parallel Programming](https://www.coursera.org/learn/scala-parallel-programming) +- [Big Data Analysis with Scala and Spark](https://www.coursera.org/learn/scala-spark-big-data) +- [Programming Reactive Systems](https://www.coursera.org/learn/scala-akka-reactive): introduces Akka, actors and reactive streams + +All courses are free to audit, with an option to pay for a certificate, to showcase your skills on your resume or LinkedIn. +For more on Scala Center's online courses, visit [this page](https://docs.scala-lang.org/online-courses.html#learning-platforms). diff --git a/_includes/_markdown/courses-extension-school.md b/_includes/_markdown/courses-extension-school.md new file mode 100644 index 0000000000..003c42a4f2 --- /dev/null +++ b/_includes/_markdown/courses-extension-school.md @@ -0,0 +1,9 @@ +## EPFL Extension School: Effective Programming in Scala + +Subscribing to [Effective programming in Scala](https://www.epfl.ch/education/continuing-education/effective-programming-in-scala/) on the EPFL Extension School offers: + +- Regular Q&A sessions and code reviews with experts from the Scala team +- An [Extension School certificate](https://www.epfl.ch/education/continuing-education/certifications/) upon completion + +This course combines video lessons, written content and hands-on exercise focused on practical aspects, including business domain modeling, error handling, data manipulation, and task parallelization. +For more on Scala Center's online courses, visit [this page](https://docs.scala-lang.org/online-courses.html#learning-platforms). diff --git a/_includes/_markdown/courses-rock-the-jvm.md b/_includes/_markdown/courses-rock-the-jvm.md new file mode 100644 index 0000000000..5c08cefd40 --- /dev/null +++ b/_includes/_markdown/courses-rock-the-jvm.md @@ -0,0 +1,13 @@ +## Rock the JVM Courses + +[Rock the JVM](https://rockthejvm.com) is a learning platform with free and premium courses on the Scala language, and all major libraries and tools in the Scala ecosystem: Typelevel, Zio, Akka/Pekko, Spark, and others. +Its main Scala courses are: + +- [Scala at Light Speed](https://rockthejvm.com/courses/scala-at-light-speed) (free) +- [Scala & Functional Programming Essentials](https://rockthejvm.com/courses/scala-essentials) (premium) +- [Advanced Scala and Functional Programming](https://rockthejvm.com/courses/advanced-scala) (premium) +- [Scala Macros & Metaprogramming](https://rockthejvm.com/courses/scala-macros-and-metaprogramming) (premium) + +Other courses teach how to build full-stack Scala application, using [Typelevel](https://rockthejvm.com/courses/typelevel-rite-of-passage) or [ZIO](https://rockthejvm.com/courses/zio-rite-of-passage) ecosystems. + +Explore more premium [courses](https://rockthejvm.com/courses) or check out [free video tutorials](https://youtube.com/rockthejvm) and [articles](https://rockthejvm.com/articles). diff --git a/_includes/_markdown/install-cask.md b/_includes/_markdown/install-cask.md index afb2754321..0424ce4ae6 100644 --- a/_includes/_markdown/install-cask.md +++ b/_includes/_markdown/install-cask.md @@ -5,7 +5,7 @@ {% tab 'Scala CLI' %} You can declare a dependency on Cask with the following `using` directive: ```scala -//> using dep "com.lihaoyi::cask::0.9.2" +//> using dep com.lihaoyi::cask::0.9.2 ``` {% endtab %} @@ -25,7 +25,7 @@ lazy val example = project.in(file("example")) In your `build.sc`, you can add a dependency on Cask: ```scala object example extends RootModule with ScalaModule { - def scalaVersion = "3.3.3" + def scalaVersion = "3.3.4" def ivyDeps = Agg( ivy"com.lihaoyi::cask::0.9.2" ) diff --git a/_includes/_markdown/install-munit.md b/_includes/_markdown/install-munit.md index 853d18e230..e1ebf130c9 100644 --- a/_includes/_markdown/install-munit.md +++ b/_includes/_markdown/install-munit.md @@ -10,7 +10,7 @@ MUnit, being a testing framework, is only available in test files: files in a `t Alternatively, you can require just a specific version of MUnit: ```scala -//> using dep org.scalameta::munit:1.0.0-M7 +//> using dep org.scalameta::munit:1.0.3 ``` {% endtab %} {% tab 'sbt' %} @@ -18,7 +18,7 @@ In your build.sbt file, you can add the dependency on toolkit-test: ```scala lazy val example = project.in(file(".")) .settings( - scalaVersion := "3.3.3", + scalaVersion := "3.3.4", libraryDependencies += "org.scala-lang" %% "toolkit-test" % "0.1.7" % Test ) ``` @@ -27,14 +27,14 @@ Here the `Test` configuration means that the dependency is only used by the sour Alternatively, you can require just a specific version of MUnit: ```scala -libraryDependencies += "org.scalameta" %% "munit" % "1.0.0-M7" % Test +libraryDependencies += "org.scalameta" %% "munit" % "1.0.3" % Test ``` {% endtab %} {% tab 'Mill' %} In your build.sc file, you can add a `test` object extending `Tests` and `TestModule.Munit`: ```scala object example extends ScalaModule { - def scalaVersion = "3.3.3" + def scalaVersion = "3.3.4" object test extends Tests with TestModule.Munit { def ivyDeps = Agg( @@ -46,7 +46,7 @@ object example extends ScalaModule { Alternatively, you can require just a specific version of MUnit: ```scala -ivy"org.scalameta::munit:1.0.0-M7" +ivy"org.scalameta::munit:1.0.3" ``` {% endtab %} {% endtabs %} diff --git a/_includes/_markdown/install-os-lib.md b/_includes/_markdown/install-os-lib.md index c35388e0a3..b62c5ce102 100644 --- a/_includes/_markdown/install-os-lib.md +++ b/_includes/_markdown/install-os-lib.md @@ -17,7 +17,7 @@ In your `build.sbt`, you can add a dependency on the toolkit: ```scala lazy val example = project.in(file(".")) .settings( - scalaVersion := "3.3.3", + scalaVersion := "3.3.4", libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7" ) ``` @@ -30,7 +30,7 @@ libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.9.1" In your `build.sc` file, you can add a dependency on the Toolkit: ```scala object example extends ScalaModule { - def scalaVersion = "3.3.3" + def scalaVersion = "3.3.4" def ivyDeps = Agg( ivy"org.scala-lang::toolkit:0.1.7" diff --git a/_includes/_markdown/install-sttp.md b/_includes/_markdown/install-sttp.md index 43ad70f7d9..d23cf1c09a 100644 --- a/_includes/_markdown/install-sttp.md +++ b/_includes/_markdown/install-sttp.md @@ -17,7 +17,7 @@ In your build.sbt file, you can add a dependency on the Toolkit: ```scala lazy val example = project.in(file(".")) .settings( - scalaVersion := "3.3.3", + scalaVersion := "3.3.4", libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7" ) ``` @@ -31,7 +31,7 @@ libraryDependencies += "com.softwaremill.sttp.client4" %% "core" % "4.0.0-M6" In your build.sc file, you can add a dependency on the Toolkit: ```scala object example extends ScalaModule { - def scalaVersion = "3.3.3" + def scalaVersion = "3.3.4" def ivyDeps = Agg( ivy"org.scala-lang::toolkit:0.1.7" diff --git a/_includes/_markdown/install-upickle.md b/_includes/_markdown/install-upickle.md index 58f3e23c9c..5ae9fb9024 100644 --- a/_includes/_markdown/install-upickle.md +++ b/_includes/_markdown/install-upickle.md @@ -17,7 +17,7 @@ In your build.sbt file, you can add the dependency on the Toolkit: ```scala lazy val example = project.in(file(".")) .settings( - scalaVersion := "3.3.3", + scalaVersion := "3.3.4", libraryDependencies += "org.scala-lang" %% "toolkit" % "0.1.7" ) ``` @@ -30,7 +30,7 @@ libraryDependencies += "com.lihaoyi" %% "upickle" % "3.1.0" In your build.sc file, you can add the dependency to the upickle library: ```scala object example extends ScalaModule { - def scalaVersion = "3.3.3" + def scalaVersion = "3.3.4" def ivyDeps = Agg( ivy"org.scala-lang::toolkit:0.1.7" diff --git a/_includes/markdown.html b/_includes/markdown.html index cd79243a41..886b1560cd 100644 --- a/_includes/markdown.html +++ b/_includes/markdown.html @@ -1,3 +1 @@ -{%if include.selector%}<{{include.selector}} {%if include.classes%}class="{{include.classes}}"{%endif%} {%if include.id%}id="{{include.id}}{%endif%}">{%endif%} - {% capture markdown %}{% include {{include.path}} %}{% endcapture %}{{ markdown | markdownify }} -{%if include.selector%}{%endif%} +{% capture markdown %}{% include {{include.path}} %}{% endcapture %}{{ markdown | markdownify }} diff --git a/_includes/online-courses-box.html b/_includes/online-courses-box.html new file mode 100644 index 0000000000..ef06306b9b --- /dev/null +++ b/_includes/online-courses-box.html @@ -0,0 +1,12 @@ +
+
+
+ + + +
+
+ {% include markdown.html path=include.path %} +
+
+
diff --git a/_includes/online-courses.html b/_includes/online-courses.html deleted file mode 100644 index 73fba6a50c..0000000000 --- a/_includes/online-courses.html +++ /dev/null @@ -1,91 +0,0 @@ - -
-
-

Online Courses

-
- - {% comment %} - We're going to follow the next ordering for the online courses: - 1- First we'll show those items that belong to an specific specialization (i.e.: Scala's progfun in Coursera). Those will be ordered alphabetically by title and each item under the specialization by the `specialization-order` tag in each one. - 2- After those, courses that don't belong to any specific specialization. - We'll only show those courses that are not finished yet. - {% endcomment %} - - {% assign specializations = '' | split: ',' %} - {% assign courses = '' | split: ',' %} - {% assign upcomingCourses = '' | split: ',' %} - {% capture now %}{{site.time | date: '%s' | plus: 0}}{% endcapture %} - - {% for course in site.online_courses %} - {% unless specializations contains course.specialization %} - {% assign specializations = specializations | push: course.specialization %} - {% endunless %} - - {% capture endDate %}{{course.end-date | date: '%s' | plus: 86400}}{% endcapture %} - {% if now <= endDate %} - {% assign upcomingCourses = upcomingCourses | push: course %} - {% endif %} - {% endfor %} - - {% for specialization in specializations %} - {% assign specCourses = '' | split: ',' %} - - {% for course in upcomingCourses %} - {% if course.specialization %} - {% if course.specialization == specialization %} - {% assign specCourses = specCourses | push: course %} - {% endif %} - - {% assign sortedSpecCourses = specCourses | sort: 'specialization-order' %} - {% endif %} - {% endfor %} - {% for sortedCourse in sortedSpecCourses %} - {% assign courses = courses | push: sortedCourse %} - {% endfor %} - {% endfor %} - - {% for course in upcomingCourses %} - {% unless course.specialization %} - {% assign courses = courses | push: course %} - {% endunless %} - {% endfor %} - -
- {% for course in courses %} - - -
-

{{course.title}}

-
    -
  • - {% if course.paid == true %} - {{site.data.common.texts.onlineCoursesPaid}} - {% else %} - {{site.data.common.texts.onlineCoursesFree}} - {% endif %} -
  • -
  • -
  • - {% if course.showDate == true %} - {{course.date | date_to_string}} - {% else %} - {{site.data.common.texts.courseraLaunchPeriod}} - {% endif %} -
  • -
-
-
- {% endfor %} -
-
-

Visit all the Online Courses courses

-
-
\ No newline at end of file diff --git a/_ja/getting-started/install-scala.md b/_ja/getting-started/install-scala.md index a72dab82b9..a85f87263c 100644 --- a/_ja/getting-started/install-scala.md +++ b/_ja/getting-started/install-scala.md @@ -170,7 +170,7 @@ IDE の使用に慣れている場合は、IDE から _Main.scala_ のコード * [The Scala Book](/scala3/book/introduction.html) (Scala 2版は[こちら](/overviews/scala-book/introduction.html))はScalaの主な機能を紹介する短いレッスンのセットを提供します。 * [The Tour of Scala](/tour/tour-of-scala.html) Scalaの機能を一口サイズで紹介します。 -* [Learning Resources](/learn.html) オンラインのインタラクティブなチュートリアルやコースです。 +* [Learning Courses](/online-courses.html) オンラインのインタラクティブなチュートリアルやコースです。 * [books](/books.html) 人気のある Scalaの 書籍を紹介します * [The migration guide](/scala3/guides/migration/compatibility-intro.html) 既存の Scala 2コードベースを Scala 3に移行する際に役立ちます。 diff --git a/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index 2af1906295..815760672c 100644 --- a/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_ja/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -16,7 +16,7 @@ Scala には複数のライブラリとテスト方法がありますが、こ 1. ScalaTest への依存を追加します。 1. `build.sbt` ファイルに ScalaTest への依存を追加します。 ``` - libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % Test + libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test ``` 1. `build.sbt was changed` という通知が出たら、**auto-import** を選択します。 1. これらの2つのアクションにより、`sbt` が ScalaTest ライブラリをダウンロードします。 diff --git a/_ja/overviews/scala3-book/scala-for-python-devs.md b/_ja/overviews/scala3-book/scala-for-python-devs.md new file mode 100644 index 0000000000..41b7fc9f38 --- /dev/null +++ b/_ja/overviews/scala3-book/scala-for-python-devs.md @@ -0,0 +1,1383 @@ +--- +title: Scala for Python Developers +type: chapter +description: This page is for Python developers who are interested in learning about Scala 3. +languages: [zh-cn, ja] +num: 76 +previous-page: scala-for-javascript-devs +next-page: where-next +--- + +{% include_relative scala4x.css %} + +
+ +{% comment %} + +NOTE: Hopefully someone with more Python experience can give this a thorough review. + +NOTE: On this page (https://contributors.scala-lang.org/t/feedback-sought-optional-braces/4702/10), Li Haoyi comments: “Python’s success also speaks for itself; beginners certainly don’t pick Python because of performance, ease of installation, packaging, IDE support, or simplicity of the language’s runtime semantics!” I’m not a Python expert, so these points are good to know, though I don’t want to go negative in any comparisons. +It’s more like thinking, “Python developers will appreciate Scala’s performance, ease of installation, packaging, IDE support, etc.” +{% endcomment %} + +{% comment %} +TODO: We should probably go through this document and add links to our other detail pages, when time permits. +{% endcomment %} + +このセクションでは、PythonとScalaのプログラミング言語を比較します。 +Pythonに詳しくて、Scalaについて学びたいと考えているプログラマーを対象としています。具体的には、Pythonの言語機能とScalaの比較例を挙げて説明します。 + +## はじめに + +例に入る前に、この最初のセクションでは、後に続くセクションの簡単な紹介と概要を提供します。 +まず、2つの言語の概要を高レベルで比較し、その後、実践的なプログラミングでの比較を行います。 + +### 高レベルでの類似点 + +高レベルで見ると、ScalaはPythonと以下のような *類似点* を共有しています。 + +- 高水準プログラミング言語であり、ポインタや手動でのメモリ管理といった低レベルの概念を気にする必要がありません。 +- 比較的シンプルで簡潔な構文を持ちます。 +- [関数型プログラミングスタイル][fp-intro]をサポートしています。 +- オブジェクト指向プログラミング(OOP)言語です。 +- 内包表記(comprehensions)をサポートしています。Pythonにはリスト内包表記があり、Scalaには`for`内包表記があります。 +- ラムダ式と[高階関数][hofs]をサポートしています。 +- [Apache Spark](https://spark.apache.org)を用いたビッグデータ処理に使用できます。 +- 優れたライブラリが豊富に使用できます。 + +### 高レベルでの相違点 + +高レベルで見ると、PythonとScalaの間には以下のような _相違点_ があります: + +- Python は動的型付け言語であり、Scala は静的型付け言語です。 + - Pythonは動的型付けですが、型ヒントによる「段階的型付け」をサポートしており、`mypy`のような静的型チェッカーで検証できます。 + - Scalaは静的型付けですが、型推論のような機能により動的言語のような感覚で書けます。 +- Pythonはインタプリタ型で実行され、Scalaのコードはコンパイルされて _.class_ ファイルになり、Java仮想マシン(JVM)上で動作します。 +- JVMでの実行に加えて、[Scala.js](https://www.scala-js.org)によりScalaをJavaScriptの代替として使用することもできます。 +- [Scala Native](https://scala-native.org/)では、「システムレベル」のコードを記述し、ネイティブ実行ファイルにコンパイルできます。 +- Scalaではすべてが _式_ である:`if`文、`for`ループ、`match`式、さらには`try`/`catch`式でさえも、戻り値を持ちます。 +- 慣用的に Scala では不変性を基本とする:不変変数や不変コレクションを使用することが推奨されています。 +- Scalaは[並行・並列プログラミング][concurrency]のサポートが優れています。 + +### プログラミングレベルでの類似点 + +このセクションでは、実際に Python と Scala でコードを書く際に見られる類似点を紹介します。 + +- Scalaの型推論により、動的型付け言語のような感覚でコーディングできます。 +- どちらの言語も式の末尾にセミコロンを使用しません。 +- 中括弧や括弧ではなく、インデントを重要視した記述がサポートされています。 +- メソッド定義の構文が似ています。 +- 両方ともリスト、辞書(マップ)、セット、タプルをサポートしています。 +- マッピングやフィルタリングに対応した内包表記を備えています。 +- 優れたIDEサポートがあります。 +- Scala 3の[トップレベル定義][toplevel]を利用することで、メソッドやフィールド、その他の定義をどこにでも記述できます。 + - 一方で、Pythonはメソッドを1つも宣言しなくても動作できますが、Scala 3ではトップレベルですべてを実現することはできません。たとえば、Scalaアプリケーションを開始するには[mainメソッド][main-method](`@main def`)が必要です。 + +### プログラミングレベルでの違い + +プログラミングレベルでも、コードを書く際に日常的に見られるいくつかの違いがあります: + +- Scalaでのプログラミングは非常に一貫性があります: + - フィールドやパラメータを定義する際に、`val`と`var`が一貫して使用されます + - リスト、マップ、セット、タプルはすべて同様に作成・アクセスされます。たとえば、他のScalaクラスを作成するのと同様に、すべてのタイプを作成するために括弧が使用されます---`List(1,2,3)`, `Set(1,2,3)`, `Map(1->"one")` + - [コレクションクラス][collections-classes] は一般的にほとんど同じ高階関数を持っています + - パターンマッチングは言語全体で一貫して使用されます + - メソッドに渡される関数を定義するために使用される構文は、匿名関数を定義するために使用される構文と同じです +- Scalaの変数やパラメータは`val`(不変)または `var`(可変)キーワードで定義されます +- 慣用的に、Scala では不変データ構造を使うことを良しとします。 +- コメント: Pythonはコメントに `#` を使用しますが、ScalaはC、C++、Javaスタイルの `//`、`/*...*/`、および `/**...*/` を使用します +- 命名規則: Pythonの標準は `my_list` のようにアンダースコアを使用しますが、Scalaは `myList` を使用します +- Scalaは静的型付けであるため、メソッドパラメータ、メソッドの戻り値、その他の場所で型を宣言します +- パターンマッチングと `match` 式はScalaで広範に使用されており、コードの書き方を変えるでしょう +- トレイト(Traits): Scalaではトレイトが多用され、Pythonではインターフェースや抽象クラスがあまり使用されません +- Scalaの[コンテキスト抽象][contextual]と _型推論_ は、さまざまな機能のコレクションを提供します: + - [拡張メソッド][extension-methods] により、明確な構文を使用してクラスに新しい機能を簡単に追加できます + - [多元的等価性][multiversal] により、コンパイル時に意味のある比較にのみ等価比較を制限できます +- Scalaには最先端のオープンソース関数型プログラミングライブラリがあります([“Awesome Scala”リスト](https://github.com/lauris/awesome-scala)を参照) +- オブジェクト、名前渡しパラメータ、中置表記、オプションの括弧、拡張メソッド、高階関数などの機能により、独自の「制御構造」やDSLを作成できます +- ScalaコードはJVM上で実行でき、[Scala Native](https://github.com/scala-native/scala-native)や[GraalVM](https://www.graalvm.org)を使用してネイティブイメージにコンパイルすることも可能で、高性能を実現します +- その他多くの機能:コンパニオンクラスとオブジェクト、マクロ、数値リテラル、複数のパラメータリスト、[交差型][intersection-types]、型レベルプログラミングなど + +### 機能の比較と例 + +この導入に基づき、以下のセクションではPythonとScalaのプログラミング言語機能を並べて比較します。 + +{% comment %} TODO: Pythonの例をスペース四つに更新します。開始しましたが、別のPRで行う方が良いと思いました。 {% endcomment %} + +## コメント + +Pythonはコメントに # を使用しますが、Scalaのコメント構文はC、C++、Javaなどの言語と同じです。 + + + + + + + + + + +
+ # a comment +
+ // a comment +
/* ... */ +
/** ... */
+
+ +## 変数の割り当て + +これらの例は、PythonとScalaで変数を作成する方法を示しています。 + +### 整数変数,文字列変数 + + + + + + + + + + +
+ x = 1 +
x = "Hi" +
y = """foo +
       bar +
       baz"""
+
+ val x = 1 +
val x = "Hi" +
val y = """foo +
           bar +
           baz"""
+
+ +### リスト + + + + + + + + + + +
+ x = [1,2,3] +
+ val x = List(1,2,3) +
+ +### 辞書/マップ + + + + + + + + + + +
+ x = { +
  "Toy Story": 8.3, +
  "Forrest Gump": 8.8, +
  "Cloud Atlas": 7.4 +
}
+
+ val x = Map( +
  "Toy Story" -> 8.3, +
  "Forrest Gump" -> 8.8, +
  "Cloud Atlas" -> 7.4 +
)
+
+ +### 集合 + + + + + + + + + + +
+ x = {1,2,3} +
+ val x = Set(1,2,3) +
+ +### タプル + + + + + + + + + + +
+ x = (11, "Eleven") +
+ val x = (11, "Eleven") +
+ +Scalaのフィールドが可変になる場合は、変数定義に `val` の代わりに `var` を使います。 + +```scala +var x = 1 +x += 1 +``` + +しかし、Scalaの慣習として、特に変数を変更する必要がない限り、常に`val`を使います。 + +## 関数型プログラミングスタイルのレコード + +Scalaのケース・クラスはPythonのフローズン・データクラスに似ています。 + +### 構造体の定義 + + + + + + + + + + +
+ from dataclasses import dataclass, replace +
+
@dataclass(frozen=True) +
class Person: +
  name: str +
  age: int
+
+ case class Person(name: String, age: Int) +
+ +### インスタンスを作成して使用する + + + + + + + + + + +
+ p = Person("Alice", 42) +
p.name   # Alice +
p2 = replace(p, age=43)
+
+ val p = Person("Alice", 42) +
p.name   // Alice +
val p2 = p.copy(age = 43)
+
+ +## オブジェクト指向プログラミングスタイルのクラスとメソッド + +このセクションでは、オブジェクト指向プログラミングスタイルのクラスとメソッドに関する機能の比較を行います。 + +### クラスとプライマリーコンストラクタ + + + + + + + + + + +
+ class Person(object): +
  def __init__(self, name): +
    self.name = name +
+
  def speak(self): +
    print(f'Hello, my name is {self.name}')
+
+ class Person (var name: String): +
  def speak() = println(s"Hello, my name is $name")
+
+ +### インスタンスを作成して使用する + + + + + + + + + + +
+ p = Person("John") +
p.name   # John +
p.name = 'Fred' +
p.name   # Fred +
p.speak()
+
+ val p = Person("John") +
p.name   // John +
p.name = "Fred" +
p.name   // Fred +
p.speak()
+
+ +### 1行メソッド + + + + + + + + + + +
+ def add(a, b): return a + b +
+ def add(a: Int, b: Int): Int = a + b +
+ +### 複数行のメソッド + + + + + + + + + + +
+ def walkThenRun(): +
  print('walk') +
  print('run')
+
+ def walkThenRun() = +
  println("walk") +
  println("run")
+
+ +## インターフェース、トレイト、継承 + +Java 8以降に慣れていれば、ScalaのtraitはJavaのインターフェースに良く似ていることに気づくと思います。 +Pythonのインターフェース(プロトコル)や抽象クラスがあまり使われないのに対して、Scalaではトレイトが常に使われています。 +したがって、この例では両者を比較するのではなく、Scalaのトレイトを使って数学のちょっとした問題を解く方法を紹介します: + +```scala +trait Adder: + def add(a: Int, b: Int) = a + b + +trait Multiplier: + def multiply(a: Int, b: Int) = a * b + +// create a class from the traits +class SimpleMath extends Adder, Multiplier +val sm = new SimpleMath +sm.add(1,1) // 2 +sm.multiply(2,2) // 4 +``` + +クラスやオブジェクトでtraitを使う方法は他にも[たくさんあります][modeling-intro]。 +しかし、これは概念を論理的な動作のグループに整理して、完全な解答を作成するために必要に応じてそれらを統合するために、どのように使うことができるかのちょっとしたアイデアを与えてくれます。 + +## 制御構文 + +ここではPythonとScalaの[制御構文][control-structures]を比較します。 +どちらの言語にも `if`/`else`, `while`, `for` ループ、 `try` といった構文があります。 +加えて、Scala には `match` 式があります。 + +### `if` 文, 1行 + + + + + + + + + + +
+ if x == 1: print(x) +
+ if x == 1 then println(x) +
+ +### `if` 文, 複数行 + + + + + + + + + + +
+ if x == 1: +
  print("x is 1, as you can see:") +
  print(x)
+
+ if x == 1 then +
  println("x is 1, as you can see:") +
  println(x)
+
+ +### if, else if, else: + + + + + + + + + + +
+ if x < 0: +
  print("negative") +
elif x == 0: +
  print("zero") +
else: +
  print("positive")
+
+ if x < 0 then +
  println("negative") +
else if x == 0 then +
  println("zero") +
else +
  println("positive")
+
+ +### `if` 文からの戻り値 + + + + + + + + + + +
+ min_val = a if a < b else b +
+ val minValue = if a < b then a else b +
+ +### メソッドの本体としての`if` + + + + + + + + + + +
+ def min(a, b): +
  return a if a < b else b
+
+ def min(a: Int, b: Int): Int = +
  if a < b then a else b
+
+ +### `while` ループ + + + + + + + + + + +
+ i = 1 +
while i < 3: +
  print(i) +
  i += 1
+
+ var i = 1 +
while i < 3 do +
  println(i) +
  i += 1
+
+ +### rangeを指定した`for` ループ + + + + + + + + + + +
+ for i in range(0,3): +
  print(i)
+
+ // preferred +
for i <- 0 until 3 do println(i) +
+
// also available +
for (i <- 0 until 3) println(i) +
+
// multiline syntax +
for +
  i <- 0 until 3 +
do +
  println(i)
+
+ +### リスト範囲内の`for` ループ + + + + + + + + + + +
+ for i in ints: print(i) +
+
for i in ints: +
  print(i)
+
+ for i <- ints do println(i) +
+ +### 複数行での`for` ループ + + + + + + + + + + +
+ for i in ints: +
  x = i * 2 +
  print(f"i = {i}, x = {x}")
+
+ for +
  i <- ints +
do +
  val x = i * 2 +
  println(s"i = $i, x = $x")
+
+ +### 複数の “range” ジェネレータ + + + + + + + + + + +
+ for i in range(1,3): +
  for j in range(4,6): +
    for k in range(1,10,3): +
      print(f"i = {i}, j = {j}, k = {k}")
+
+ for +
  i <- 1 to 2 +
  j <- 4 to 5 +
  k <- 1 until 10 by 3 +
do +
  println(s"i = $i, j = $j, k = $k")
+
+ +### ガード付きジェネレータ (`if` 式) + + + + + + + + + + +
+ for i in range(1,11): +
  if i % 2 == 0: +
    if i < 5: +
      print(i)
+
+ for +
  i <- 1 to 10 +
  if i % 2 == 0 +
  if i < 5 +
do +
  println(i)
+
+ +### 行ごとに複数の`if`条件 + + + + + + + + + + +
+ for i in range(1,11): +
  if i % 2 == 0 and i < 5: +
    print(i)
+
+ for +
  i <- 1 to 10 +
  if i % 2 == 0 && i < 5 +
do +
  println(i)
+
+ +### 内包表記 + + + + + + + + + + +
+ xs = [i * 10 for i in range(1, 4)] +
# xs: [10,20,30]
+
+ val xs = for i <- 1 to 3 yield i * 10 +
// xs: Vector(10, 20, 30)
+
+ +### `match` 条件式 + + + + + + + + + + +
+ # From 3.10, Python supports structural pattern matching +
# You can also use dictionaries for basic “switch” functionality +
match month: +
  case 1: +
    monthAsString = "January" +
  case 2: +
    monthAsString = "February" +
  case _: +
    monthAsString = "Other"
+
+ val monthAsString = month match +
  case 1 => "January" +
  case 2 => "February" +
  _ => "Other"
+
+ +### switch/match + + + + + + + + + + +
+ # Only from Python 3.10 +
match i: +
  case 1 | 3 | 5 | 7 | 9: +
    numAsString = "odd" +
  case 2 | 4 | 6 | 8 | 10: +
    numAsString = "even" +
  case _: +
    numAsString = "too big"
+
+ val numAsString = i match +
  case 1 | 3 | 5 | 7 | 9 => "odd" +
  case 2 | 4 | 6 | 8 | 10 => "even" +
  case _ => "too big"
+
+ +### try, catch, finally + + + + + + + + + + +
+ try: +
  print(a) +
except NameError: +
  print("NameError") +
except: +
  print("Other") +
finally: +
  print("Finally")
+
+ try +
  writeTextToFile(text) +
catch +
  case ioe: IOException => +
    println(ioe.getMessage) +
  case fnf: FileNotFoundException => +
    println(fnf.getMessage) +
finally +
  println("Finally")
+
+ +マッチ式とパターンマッチは、Scalaプログラミングの大きな要素ですが、ここで紹介しているのは、マッチ式の機能の一部だけです。より多くの例については、[制御構造][control-structures]のページをご覧ください。 + +## コレクションクラス + +このセクションでは、PythonとScalaで利用可能なコレクションクラス[collections classes][collections-classes]を比較します。リスト、辞書/マップ、セット、タプルなどです。 + +### リスト + +Pythonにはリストがあるように、Scalaにはニーズに応じて、可変および不可変な列(Seq)のクラスがいくつか用意されています。 +Pythonのリストは変更可能であるため、Scalaの `ArrayBuffer` によく似ています。 + +### Pythonリスト & Scalaの列(Seq) + + + + + + + + + + +
+ a = [1,2,3] +
+ // use different sequence classes +
// as needed +
val a = List(1,2,3) +
val a = Vector(1,2,3) +
val a = ArrayBuffer(1,2,3)
+
+ +### リストの要素へのアクセス + + + + + + + + + + +
+ a[0]
a[1]
+
+ a(0)
a(1)
// just like all other method calls +
+ +### リストの要素の更新 + + + + + + + + + + +
+ a[0] = 10 +
a[1] = 20
+
+ // ArrayBuffer is mutable +
a(0) = 10 +
a(1) = 20
+
+ +### 2つのリストの結合 + + + + + + + + + + +
+ c = a + b +
+ val c = a ++ b +
+ +### リストの反復処理 + + + + + + + + + + +
+ for i in ints: print(i) +
+
for i in ints: +
  print(i)
+
+ // preferred +
for i <- ints do println(i) +
+
// also available +
for (i <- ints) println(i)
+
+ +Scala の主な列(Seq)クラスは `List`、`Vector`、`ArrayBuffer` です。 +`List` と `Vector` は不変な列が必要なときに使うメインクラスで、 `ArrayBuffer` は可変な列が必要なときに使うメインクラスです。 +(Scala における 「バッファ」 とは、大きくなったり小さくなったりする配列のことです。) + +### 辞書/マップ + +Python の辞書はScala の `Map` クラスのようなものです。 +しかし、Scala のデフォルトのマップは _immutable_ であり、新しいマップを簡単に作成するための変換メソッドを持っています。 + +#### 辞書/マップ の作成 + + + + + + + + + + +
+ my_dict = { +
  'a': 1, +
  'b': 2, +
  'c': 3 +
}
+
+ val myMap = Map( +
  "a" -> 1, +
  "b" -> 2, +
  "c" -> 3 +
)
+
+ +#### 辞書/マップの要素へのアクセス + + + + + + + + + + +
+ my_dict['a']   # 1 +
+ myMap("a")   // 1 +
+ +#### `for` ループでの辞書/マップ + + + + + + + + + + +
+ for key, value in my_dict.items(): +
  print(key) +
  print(value)
+
+ for (key,value) <- myMap do +
  println(key) +
  println(value)
+
+ +Scalaには、さまざまなニーズに対応する他の専門的な `Map` クラスがあります。 + +### 集合 + +Pythonの集合は、_mutable_ Scalaの`Set`クラスに似ています。 + +#### 集合の作成 + + + + + + + + + + +
+ set = {"a", "b", "c"} +
+ val set = Set(1,2,3) +
+ +#### 重複する要素 + + + + + + + + + + +
+ set = {1,2,1} +
# set: {1,2}
+
+ val set = Set(1,2,1) +
// set: Set(1,2)
+
+ +Scalaには、他にも様々なニーズに特化した`Set`クラスがあります。 + +### タプル + +PythonとScalaのタプルも似ています。 + +#### タプルの作成 + + + + + + + + + + +
+ t = (11, 11.0, "Eleven") +
+ val t = (11, 11.0, "Eleven") +
+ +#### タプルの要素へのアクセス + + + + + + + + + + +
+ t[0]   # 11 +
t[1]   # 11.0
+
+ t(0)   // 11 +
t(1)   // 11.0
+
+ +## コレクションクラスでのメソッド + +PythonとScalaには、同じ関数型メソッドがいくつかあります。 + +- `map` +- `filter` +- `reduce` + +Pythonのラムダ式でこれらのメソッドを使うのに慣れていれば、Scalaがコレクション・クラスのメソッドで同じようなアプローチを持っていることがわかると思います。 +この機能を実証するために、ここに2つのサンプルリストを示します。 + +```scala +numbers = [1,2,3] // python +val numbers = List(1,2,3) // scala +``` + +これらのリストは以下の表で使用され、マップ処理とフィルター処理のアルゴリズムを適用する方法を示しています。 + +### マップ処理の内包表記 + + + + + + + + + + +
+ x = [i * 10 for i in numbers] +
+ val x = for i <- numbers yield i * 10 +
+ +### フィルター処理の内包表記 + + + + + + + + + + +
+ evens = [i for i in numbers if i % 2 == 0] +
+ val evens = numbers.filter(_ % 2 == 0) +
// or +
val evens = for i <- numbers if i % 2 == 0 yield i
+
+ +### マップ、フィルター処理の内包表記 + + + + + + + + + + +
+ x = [i * 10 for i in numbers if i % 2 == 0] +
+ val x = numbers.filter(_ % 2 == 0).map(_ * 10) +
// or +
val x = for i <- numbers if i % 2 == 0 yield i * 10
+
+ +### マップ処理 + + + + + + + + + + +
+ x = map(lambda x: x * 10, numbers) +
+ val x = numbers.map(_ * 10) +
+ +### フィルター処理 + + + + + + + + + + +
+ f = lambda x: x > 1 +
x = filter(f, numbers)
+
+ val x = numbers.filter(_ > 1) +
+ + +### Scalaのコレクションメソッド + +Scalaのコレクションクラスには100以上の関数メソッドがあり、コードを簡単にすることができます。 +Python では、これらの関数の一部は `itertools` モジュールで利用できます。 +`map`、`filter`、`reduce` に加えて、Scala でよく使われるメソッドを以下に示します。 +これらのメソッドの例では + +- `c` はコレクションです。 +- `p` は述語です。 +- `f` は関数、無名関数、またはメソッドです。 +- `n` は整数値です。 + +これらは利用可能なフィルタリング方法の一部です。 + +|メソッド|説明| +| -------------- | ------------- | +| `c1.diff(c2)` | `c1` と `c2` の要素の差分を返します。| +| `c.distinct` | `c` の重複しない要素を返します。| +| `c.drop(n)` | 最初の `n` 要素を除くコレクションのすべての要素を返します。| +| `c.filter(p)` | コレクションから、その述語が `true` となるすべての要素を返します。| +| `c.head` | コレクションの最初の要素を返します。 (コレクションが空の場合は `NoSuchElementException` をスローします。)| +| `c.tail` | コレクションから最初の要素を除くすべての要素を返します。 (コレクションが空の場合は `UnsupportedOperationException` をスローします。)| +| `c.take(n)` | コレクション `c` の最初の `n` 個の要素を返します。 +以下に、いくつかのトランスフォーマメソッドを示します。| +|メソッド| 説明 | +| --------------- | ------------- +| `c.flatten` | コレクションのコレクション(リストのリストなど)を単一のコレクション(単一のリスト)に変換します。| +| `c.flatMap(f)` | コレクション `c` のすべての要素に `f` を適用し(`map` のような動作)、その結果のコレクションの要素を平坦化して、新しいコレクションを返します。| +| `c.map(f)` | コレクション `c` のすべての要素に `f` を適用して、新しいコレクションを作成します。| +| `c.reduce(f)` | 「リダクション」関数 `f` を `c` の連続する要素に適用し、単一の値を生成します。| +| `c.sortWith(f)` | 比較関数 `f` によってソートされた `c` のバージョンを返します。| +よく使われるグループ化メソッド: +| メソッド | 説明 | +| ---------------- | ------------- +| `c.groupBy(f)` | コレクションを `f` に従って分割し、コレクションの `Map` を作成します。| +| `c.partition(p)` | 述語 `p` に従って2つのコレクションを返します。| +| `c.span(p)` | 2つのコレクションからなるコレクションを返します。1つ目は `c.takeWhile(p)` によって作成され、2つ目は `c.dropWhile(p)` によって作成されます。| +| `c.splitAt(n)` | コレクション `c` を要素 `n` で分割して、2つのコレクションからなるコレクションを返します。| +情報および数学的なメソッド: +| メソッド | 説明 | +| -------------- | ------------- | +| `c1.containsSlice(c2)` | `c1` がシーケンス `c2` を含む場合に `true` を返します。| +| `c.count(p)` | `p` が `true` である `c` の要素数を数えます。| +| `c.distinct` | `c` の一意な要素を返します。| +| `c.exists(p)` | コレクション内のいずれかの要素に対して `p` が `true` であれば `true` を返します。| +| `c.find(p)` | `p` に一致する最初の要素を返します。 要素は `Option[A]` として返されます。| +| `c.min` | コレクションから最小の要素を返します。 (_java.lang.UnsupportedOperationException_例外が発生する場合があります。)| +| `c.max` | コレクションから最大の要素を返します。 (_java.lang.UnsupportedOperationException_例外が発生する場合があります。)| +| `c slice(from, to)` | 要素 `from` から始まり、要素 `to` で終わる要素の範囲を返します。| +| `c.sum` | コレクション内のすべての要素の合計を返しますw。 (コレクション内の要素に対して `Ordering` を定義する必要があります。)| + +以下に、これらのメソッドがリスト上でどのように機能するかを説明する例をいくつか示します。 + +```scala +val a = List(10, 20, 30, 40, 10) // List(10, 20, 30, 40, 10) +a.distinct // List(10, 20, 30, 40) +a.drop(2) // List(30, 40, 10) +a.dropRight(2) // List(10, 20, 30) +a.dropWhile(_ < 25) // List(30, 40, 10) +a.filter(_ < 25) // List(10, 20, 10) +a.filter(_ > 100) // List() +a.find(_ > 20) // Some(30) +a.head // 10 +a.headOption // Some(10) +a.init // List(10, 20, 30, 40) +a.intersect(List(19,20,21)) // List(20) +a.last // 10 +a.lastOption // Some(10) +a.slice(2,4) // List(30, 40) +a.tail // List(20, 30, 40, 10) +a.take(3) // List(10, 20, 30) +a.takeRight(2) // List(40, 10) +a.takeWhile(_ < 30) // List(10, 20) +``` + +これらのメソッドは、Scalaにおける共通のパターンを示しています。オブジェクト上で利用可能な機能メソッドです。 +これらの方法はいずれも、初期リスト `a` を変更しません。代わりに、コメントの後に示されているデータをすべて返します。 +利用可能なメソッドは他にもたくさんありますが、これらの説明と例が、組み込みのコレクションメソッドの持つ力を実感する一助となれば幸いです。 + +## 列挙 + +このセクションでは、PythonとScala 3の列挙型を比較します。 + +### 列挙型の作成 + + + + + + + + + + +
+ from enum import Enum, auto +
class Color(Enum): +
    RED = auto() +
    GREEN = auto() +
    BLUE = auto()
+
+ enum Color: +
  case Red, Green, Blue
+
+ +### 値とその比較 + + + + + + + + + + +
+ Color.RED == Color.BLUE  # False +
+ Color.Red == Color.Blue  // false +
+ +### パラメータ化された列挙型 + + + + + + + + + + +
+ N/A +
+ enum Color(val rgb: Int): +
  case Red   extends Color(0xFF0000) +
  case Green extends Color(0x00FF00) +
  case Blue  extends Color(0x0000FF)
+
+ +### ユーザー定義による列挙メンバー + + + + + + + + + + +
+ N/A +
+ enum Planet( +
    mass: Double, +
    radius: Double +
  ): +
  case Mercury extends +
    Planet(3.303e+23, 2.4397e6) +
  case Venus extends +
    Planet(4.869e+24, 6.0518e6) +
  case Earth extends +
    Planet(5.976e+24, 6.37814e6) +
  // more planets ... +
+
  // fields and methods +
  private final val G = 6.67300E-11 +
  def surfaceGravity = G * mass / +
    (radius * radius) +
  def surfaceWeight(otherMass: Double) +
    = otherMass * surfaceGravity
+
+ +## Scala 独自の概念 + +Scalaには、Pythonには現在同等の機能がない概念が他にもあります。 +詳細は以下のリンクを参照してください。 +- 拡張メソッド(extension methods)、型クラス(type classes)、暗黙的値(implicit values)など、文脈依存の抽象化(contextual abstractions)に関連するほとんどの概念 +- Scalaでは複数のパラメータリストを使用できるため、部分適用関数などの機能や独自のDSLを作成することが可能 +- 独自の制御構造や DSL を作成できる機能 +- [多様等価][多様等価]: どの等価比較が意味を持つかをコンパイル時に制御できる機能 +- インフィックスメソッド +- マクロ + +## Scala と仮想環境 + +Scalaでは、Pythonの仮想環境に相当するものを明示的に設定する必要はありません。デフォルトでは、Scalaのビルドツールがプロジェクトの依存関係を管理するため、ユーザーは手動でパッケージをインストールする必要がありません。例えば、`sbt`ビルドツールを使用する場合、`build.sbt`ファイルの`libraryDependencies`設定で依存関係を指定し、 + +``` +cd myapp +sbt compile +``` + +以上のコマンドを実行することで、その特定のプロジェクトに必要なすべての依存関係が自動的に解決されます。 +ダウンロードされた依存関係の場所は、主にビルドツールの実装の詳細であり、ユーザーはこれらのダウンロードされた依存関係と直接やりとりする必要はありません。 +例えば、sbtの依存関係キャッシュ全体を削除した場合、プロジェクトの次のコンパイル時には、sbtが自動的に必要な依存関係をすべて解決し、ダウンロードし直します。 +これはPythonとは異なります。Pythonではデフォルトで依存関係がシステム全体またはユーザー全体のディレクトリにインストールされるため、プロジェクトごとに独立した環境を取得するには、対応する仮想環境を作成する必要があります。 +例えば、`venv`モジュールを使用して、特定のプロジェクト用に次のように仮想環境を作成できます。 + +``` +cd myapp +python3 -m venv myapp-env +source myapp-env/bin/activate +pip install -r requirements.txt +``` + +これにより、プロジェクトの `myapp/myapp-env` ディレクトリにすべての依存関係がインストールされ、シェル環境変数 `PATH` が変更されて、依存関係が `myapp-env` から参照されるようになります。 +Scalaでは、このような手動での作業は一切必要ありません。 + +[collections-classes]: {% link _overviews/scala3-book/collections-classes.md %} +[concurrency]: {% link _overviews/scala3-book/concurrency.md %} +[contextual]: {% link _overviews/scala3-book/ca-contextual-abstractions-intro.md %} +[control-structures]: {% link _overviews/scala3-book/control-structures.md %} +[extension-methods]: {% link _overviews/scala3-book/ca-extension-methods.md %} +[fp-intro]: {% link _overviews/scala3-book/fp-intro.md %} +[hofs]: {% link _overviews/scala3-book/fun-hofs.md %} +[intersection-types]: {% link _overviews/scala3-book/types-intersection.md %} +[main-method]: {% link _overviews/scala3-book/methods-main-methods.md %} +[modeling-intro]: {% link _overviews/scala3-book/domain-modeling-intro.md %} +[multiversal]: {% link _overviews/scala3-book/ca-multiversal-equality.md %} +[toplevel]: {% link _overviews/scala3-book/taste-toplevel-definitions.md %} +[type-classes]: {% link _overviews/scala3-book/ca-type-classes.md %} +[union-types]: {% link _overviews/scala3-book/types-union.md %} +
diff --git a/_ja/overviews/scala3-book/scala4x.css b/_ja/overviews/scala3-book/scala4x.css new file mode 100644 index 0000000000..1772c03ac8 --- /dev/null +++ b/_ja/overviews/scala3-book/scala4x.css @@ -0,0 +1,54 @@ + + + diff --git a/_ja/tour/tour-of-scala.md b/_ja/tour/tour-of-scala.md index 9e5d2b9860..70c1e0f522 100644 --- a/_ja/tour/tour-of-scala.md +++ b/_ja/tour/tour-of-scala.md @@ -13,7 +13,7 @@ next-page: basics これはほんの短いツアーで、完全な言語のチュートリアルではありません。 もしそれを望むなら、[こちらの本](/books.html) を手に入れるか、 -[その他の解決手段](/learn.html) での相談を検討してください。 +[その他の解決手段](/online-courses.html) での相談を検討してください。 ## Scalaとは? Scalaは一般的なプログラミング方法を簡潔かつエレガントかつ型安全な方法で表現するために設計されたモダンなマルチパラダイム言語です。 diff --git a/_ko/tour/tour-of-scala.md b/_ko/tour/tour-of-scala.md index 0c83ea5e0c..0bf0b28232 100644 --- a/_ko/tour/tour-of-scala.md +++ b/_ko/tour/tour-of-scala.md @@ -12,7 +12,7 @@ next-page: basics ## 투어를 환영합니다 이 투어에서는 스칼라에서 가장 자주 사용되는 기능을 요약하여 소개하며, 스칼라 초보자를 대상으로 합니다. -언어 전체를 다루는 튜토리얼이 아닌 간단히 둘러보기입니다. 자세히 다루고 싶다면, [책](/books.html)을 구하거나 [다른 자료](/learn.html)를 찾아보세요. +언어 전체를 다루는 튜토리얼이 아닌 간단히 둘러보기입니다. 자세히 다루고 싶다면, [책](/books.html)을 구하거나 [다른 자료](/online-courses.html)를 찾아보세요. ## 스칼라란? 스칼라는 일반적인 프로그래밍 패턴을 간결하고 우아하며 타입-세이프한 방식으로 표현할 수 있게 설계된 최신 멀티-패러다임 프로그래밍 언어입니다. 객체지향과 함수형 언어의 특징을 자연스럽게 통합합니다. diff --git a/_layouts/online-courses.html b/_layouts/online-courses.html new file mode 100644 index 0000000000..45addb8dfa --- /dev/null +++ b/_layouts/online-courses.html @@ -0,0 +1,29 @@ +--- +layout: root-index-layout +--- + + +
+
+
+ {% include online-courses-box.html + path="_markdown/courses-coursera.md" + image="coursera.png" + link="https://www.coursera.org/learn/scala-functional-programming" + %} + {% include online-courses-box.html + path="_markdown/courses-rock-the-jvm.md" + image="rock-the-jvm.png" + link="https://rockthejvm.com" + %} + {% include online-courses-box.html + path="_markdown/courses-extension-school.md" + image="extension-school.png" + link="https://www.epfl.ch/education/continuing-education/effective-programming-in-scala/" + %} +
+ {{content}} +
+
+
+
diff --git a/_layouts/root-index-layout.html b/_layouts/root-index-layout.html index d83b64596f..c236bb7b2f 100644 --- a/_layouts/root-index-layout.html +++ b/_layouts/root-index-layout.html @@ -25,7 +25,8 @@

{{page.title}}

- {% comment %}Specific content from child layouts{% endcomment %} {{content}} + {% comment %}Specific content from child layouts{% endcomment %} + {{content}} diff --git a/_overviews/FAQ/index.md b/_overviews/FAQ/index.md index e731fbda9c..35b99ef0a0 100644 --- a/_overviews/FAQ/index.md +++ b/_overviews/FAQ/index.md @@ -124,11 +124,11 @@ with only minor supplements. That's why `versionString` and `versionNumberString` report that Scala 2 is in use: ``` -Welcome to Scala 3.3.3 (17.0.3, Java OpenJDK 64-Bit Server VM). +Welcome to Scala 3.3.4 (17.0.3, Java OpenJDK 64-Bit Server VM). Type in expressions for evaluation. Or try :help. scala> util.Properties.versionNumberString -val res0: String = 2.13.12 +val res0: String = 2.13.15 ``` Note that even the latest Scala 3 version might not use the very @@ -143,6 +143,8 @@ REPL, but won't work in typical Scala 3 application code. For an alternative way to detect the Scala 3 version, see [this gist](https://gist.github.com/romanowski/de14691cab7340134e197419bc48919a). +There is a proposal to provide something easier at [scala/scala3#22144](https://github.com/scala/scala3/issues/22144). + ### Why is my (abstract or overridden) `val` null? -We propose to extend eta-expansion to polymorphic methods. +We propose to extend eta-expansion to polymorphic methods. This means automatically transforming polymorphic methods into corresponding polymorphic functions when required, for example: ~~~ scala @@ -44,10 +44,10 @@ This section should clearly express the scope of the proposal. It should make it Regular eta-expansion is so ubiquitous that most users are not aware of it, for them it is intuitive and obvious that methods can be passed where functions are expected. -When manipulating polymorphic methods, we wager that most users find it confusing not to be able to do the same. +When manipulating polymorphic methods, we wager that most users find it confusing not to be able to do the same. This is the main motivation of this proposal. -It however remains to be demonstrated that such cases appear often enough for time and maintenance to be devoted to fixing it. +It however remains to be demonstrated that such cases appear often enough for time and maintenance to be devoted to fixing it. To this end, the remainder of this section will show a manufactured example with tuples, as well as real-world examples taken from the [Shapeless-3](https://index.scala-lang.org/typelevel/shapeless-3) and [kittens](https://index.scala-lang.org/typelevel/kittens) libraries. @@ -89,7 +89,7 @@ There is however the following case, where a function is very large: case (acc, Some(t)) => Some((t, acc._1)) } } -~~~ +~~~ By factoring out the function, it is possible to make the code more readable: @@ -113,7 +113,7 @@ By factoring out the function, it is possible to make the code more readable: case (acc, Some(t)) => Some((t, acc._1)) } } -~~~ +~~~ It is natural at this point to want to transform the function into a method, as the syntax for the latter is more familiar, and more readable: @@ -139,7 +139,7 @@ It is natural at this point to want to transform the function into a method, as } ~~~ -However, this does not compile. +However, this does not compile. Only monomorphic eta-expansion is applied, leading to the same issue as with our previous `Tuple.map` example. #### Kittens ([source](https://github.com/typelevel/kittens/blob/e10a03455ac3dd52096a1edf0fe6d4196a8e2cad/core/src/main/scala-3/cats/derived/DerivedTraverse.scala#L44-L48)) @@ -251,7 +251,7 @@ For example, if the syntax of the language is changed, this section should list Before we go on, it is important to clarify what we mean by "polymorphic method", we do not mean, as one would expect, "a method taking at least one type parameter clause", but rather "a (potentially partially applied) method whose next clause is a type clause", here is an example to illustrate: -~~~ scala +~~~ scala extension (x: Int) def poly[T](x: T): T = x // signature: (Int)[T](T): T @@ -279,15 +279,15 @@ Note: Polymorphic functions always take term parameters (but `k` can equal zero 1. Copies of `T_i`s are created, and replaced in `U_i`s, `L_i`s, `A_i`s and `R`, noted respectively `T'_i`, `U'_i`, `L'_i`, `A'_i` and `R'`. 2. Is the expected type a polymorphic context function ? -* 1. If yes then `m` is replaced by the following: +* 1. If yes then `m` is replaced by the following: ~~~ scala -[T'_1 <: U'_1 >: L'_1, ... , T'_n <: U'_n >: L'_n] +[T'_1 <: U'_1 >: L'_1, ... , T'_n <: U'_n >: L'_n] => (a_1: A'_1 ..., a_k: A'_k) ?=> m[T'_1, ..., T'_n] ~~~ -* 2. If no then `m` is replaced by the following: +* 2. If no then `m` is replaced by the following: ~~~ scala -[T'_1 <: U'_1 >: L'_1, ... , T'_n <: U'_n >: L'_n] +[T'_1 <: U'_1 >: L'_1, ... , T'_n <: U'_n >: L'_n] => (a_1: A'_1 ..., a_k: A'_k) => m[T'_1, ..., T'_n](a_1, ..., a_k) ~~~ @@ -321,7 +321,7 @@ extension [A](x: A) def foo[B](y: B) = (x, y) val voo: [T] => T => [U] => U => (T, U) = foo -// foo expands to: +// foo expands to: // [T'] => (t: T') => ( foo[T'](t) with expected type [U] => U => (T', U) ) // [T'] => (t: T') => [U'] => (u: U') => foo[T'](t)[U'](u) ~~~ @@ -384,7 +384,7 @@ Not included in this proposal are: * Polymorphic SAM conversion * Polymorphic functions from wildcard: `foo[_](_)` -While all of the above could be argued to be valuable, we deem they are out of the scope of this proposal. +While all of the above could be argued to be valuable, we deem they are out of the scope of this proposal. We encourage the creation of follow-up proposals to motivate their inclusion. diff --git a/_sips/sips/priority-based-infix-type-precedence.md b/_sips/sips/priority-based-infix-type-precedence.md index 71d32c1ce7..55c8af6566 100644 --- a/_sips/sips/priority-based-infix-type-precedence.md +++ b/_sips/sips/priority-based-infix-type-precedence.md @@ -121,9 +121,9 @@ A PR for this SIP is available at: [https://github.com/scala/scala/pull/6147](ht ### Interactions with other language features -#### Star `*` infix type interaction with repeated parameters -The [repeated argument symbol `*`](https://www.scala-lang.org/files/archive/spec/2.12/04-basic-declarations-and-definitions.html#repeated-parameters) may create confusion with the infix type `*`. -Please note that this feature interaction already exists within the current specification. +#### Star `*` infix type interaction with repeated parameters +The [repeated argument symbol `*`](https://www.scala-lang.org/files/archive/spec/2.12/04-basic-declarations-and-definitions.html#repeated-parameters) may create confusion with the infix type `*`. +Please note that this feature interaction already exists within the current specification. ```scala trait +[N1, N2] @@ -141,7 +141,7 @@ However, it is very unlikely that such interaction would occur. ## Backward Compatibility -Changing infix type associativity and precedence affects code that uses type operations and conforms to the current specification. +Changing infix type associativity and precedence affects code that uses type operations and conforms to the current specification. Note: changing the infix precedence didn't fail any scalac test. diff --git a/_sips/sips/scala-cli.md b/_sips/sips/scala-cli.md index f979104084..de9aaece39 100644 --- a/_sips/sips/scala-cli.md +++ b/_sips/sips/scala-cli.md @@ -2,7 +2,7 @@ layout: sip permalink: /sips/:title.html stage: completed -status: accepted +status: shipped title: SIP-46 - Scala CLI as default Scala command --- @@ -16,7 +16,7 @@ title: SIP-46 - Scala CLI as default Scala command ## Summary -We propose to replace current script that is installed as `scala` with Scala CLI - a batteries included tool to interact with Scala. Scala CLI brings all the features that the commands above provide and expand them with incremental compilation, dependency management, packaging and much more. +We propose to replace current script that is installed as `scala` with Scala CLI - a batteries included tool to interact with Scala. Scala CLI brings all the features that the commands above provide and expand them with incremental compilation, dependency management, packaging and much more. Even though Scala CLI could replace `scaladoc` and `scalac` commands as well for now, we do not propose to replace them. @@ -25,30 +25,30 @@ Even though Scala CLI could replace `scaladoc` and `scalac` commands as well for The current default `scala` script is quite limited since it can only start repl or run pre-compile Scala code. -The current script are lacking basic features such as support for resolving dependencies, incremental compilation or support for outputs other than JVM. This forces any user that wants to do anything more than just basic things to learn and use SBT, Mill or an other build tool and that adds to the complexity of learning Scala. +The current script are lacking basic features such as support for resolving dependencies, incremental compilation or support for outputs other than JVM. This forces any user that wants to do anything more than just basic things to learn and use SBT, Mill or an other build tool and that adds to the complexity of learning Scala. -We observe that the current state of tooling in Scala is limiting creativity, with quite a high cost to create e.g. an application or a script with some dependencies that target Node.js. Many Scala developers are not choosing Scala for their personal projects, scripts, or small applications and we believe that the complexity of setting up a build tool is one of the reasons. +We observe that the current state of tooling in Scala is limiting creativity, with quite a high cost to create e.g. an application or a script with some dependencies that target Node.js. Many Scala developers are not choosing Scala for their personal projects, scripts, or small applications and we believe that the complexity of setting up a build tool is one of the reasons. With this proposal our main goal is to turn Scala into a language with "batteries included" that will also respect the community-first aspect of our ecosystem. ### Why decided to work on Scala CLI rather then improve existing tools like sbt or Mill? Firstly, Scala CLI is in no way an actual replacement for SBT or Mill - nor was it ever meant to be. We do not call it a build tool, even though it does share some similarities with build tools. It doesn't aim at supporting multi-module -projects, nor to be extended via a task system. The main advantages of SBT and Mill: multi-module support and plugin ecosystem in the use cases for Scala CLI and scala command can often be disadvantages as it affects performance: configuration needs to be compiled, plugins resolved etc. +projects, nor to be extended via a task system. The main advantages of SBT and Mill: multi-module support and plugin ecosystem in the use cases for Scala CLI and scala command can often be disadvantages as it affects performance: configuration needs to be compiled, plugins resolved etc. Mill and SBT uses turing complete configuration for build so the complexity of build scripts in theory is unlimited. Scala CLI is configuration-only and that limits the complexity what put a hard cap how complex Scala CLI builds can be. -`scala` command should be first and foremost a command line tool. Requirements for a certain project structure or presence configuration files limit SBT and Mill usability certain use cases related to command line. +`scala` command should be first and foremost a command line tool. Requirements for a certain project structure or presence configuration files limit SBT and Mill usability certain use cases related to command line. -One of the main requirements for the new `scala` commands was speed, flexibility and focus on command-line use cases. Initially, we were considering improving SBT or Mill as well as building Scala CLI on top one. We have quickly realized that getting Mill or SBT to reply within Milliseconds (for cases where no hard work like compilation is require) would be pretty much out of reach. Mill and SBT's codebases are too big to compile them to native image using GraalVM, not to mention problems with dynamic loading and reflection. Adding flexibility when in comes to input sources (e.g. support for Gists) and making the tool that can accept most of the configuration using simple command-line parameters would involve writhing a lot of glue code. That is why we decided to build the tool from scratch based on existing components like coursier, bloop or scalafmt. +One of the main requirements for the new `scala` commands was speed, flexibility and focus on command-line use cases. Initially, we were considering improving SBT or Mill as well as building Scala CLI on top one. We have quickly realized that getting Mill or SBT to reply within Milliseconds (for cases where no hard work like compilation is require) would be pretty much out of reach. Mill and SBT's codebases are too big to compile them to native image using GraalVM, not to mention problems with dynamic loading and reflection. Adding flexibility when in comes to input sources (e.g. support for Gists) and making the tool that can accept most of the configuration using simple command-line parameters would involve writhing a lot of glue code. That is why we decided to build the tool from scratch based on existing components like coursier, bloop or scalafmt. ## Proposed solution -We propose to gradually replace the current `scala`, `scalac` and `scaladoc` commands by single `scala` command that under the hood will be `scala-cli`. We could also add wrapper scripts for `scalac` and `scaladoc` that will mimic the functionality that will use `scala-cli` under the hood. +We propose to gradually replace the current `scala`, `scalac` and `scaladoc` commands by single `scala` command that under the hood will be `scala-cli`. We could also add wrapper scripts for `scalac` and `scaladoc` that will mimic the functionality that will use `scala-cli` under the hood. The complete set of `scala-cli` features can be found in [its documentation](https://scala-cli.virtuslab.org/docs/overview). -Scala CLI brings many features like testing, packaging, exporting to sbt / Mill or upcoming support for publishing micro-libraries. Initially, we propose to limit the set of features available in the `scala` command by default. Scala CLI is a relatively new project and we should battle-proof some of its features before we commit to support them as part of the official `scala` command. +Scala CLI brings many features like testing, packaging, exporting to sbt / Mill or upcoming support for publishing micro-libraries. Initially, we propose to limit the set of features available in the `scala` command by default. Scala CLI is a relatively new project and we should battle-proof some of its features before we commit to support them as part of the official `scala` command. Scala CLI offers [multiple native ways to be installed](https://scala-cli.virtuslab.org/install#advanced-installation) so most users should find a suitable method. We propose that these packages to become the default `scala` package in most repositories, often replacing existing `scala` packages but the fact how new `scala` command would be installed is not intended to be a part of this SIP. @@ -58,7 +58,7 @@ Let us show a few examples where adopting Scala CLI as `scala` command would be **Using REPL with a 3rd-party dependency** -Currently, to start a Scala REPL with a dependency on the class path, users need to resolve this dependency with all its transitive dependencies (coursier can help here) and pass those to the `scala` command using the `--cp` option. Alternatively, one can create an sbt project including a single dependency and use the `sbt console` task. Ammonite gives a better experience with its magic imports. +Currently, to start a Scala REPL with a dependency on the class path, users need to resolve this dependency with all its transitive dependencies (coursier can help here) and pass those to the `scala` command using the `--cp` option. Alternatively, one can create an sbt project including a single dependency and use the `sbt console` task. Ammonite gives a better experience with its magic imports. With Scala CLI, starting a REPL with a given dependency is as simple as running: @@ -82,7 +82,7 @@ Currently, when reporting a bug in the compiler (or any other Scala-related) rep //> using platform "native" //> using "com.lihaoyi::os-lib:0.7.8" //> using options "-Xfatal-warnings" - + def foo = println("") ``` @@ -132,7 +132,7 @@ Last section of this proposal is the list of options that each sub-command MUST Scala CLI can also be configured with ["using directives"](https://scala-cli.virtuslab.org/docs/guides/introduction/using-directives) - a comment-based configuration syntax that should be placed at the top of Scala files. This allows for self-containing examples within one file since most of the configuration can be provided either from the command line or via using directives (command line has precedence). This is a game changer for use cases like scripting, reproduction, or within the academic scope. -We have described the motivation, syntax and implementation basis in the [dedicated pre-SIP](https://contributors.scala-lang.org/t/pre-sip-using-directives/5700). Currently, we recommend to write using directives as comments, so making them part of the language specification is not necessary at this stage. Moreover, the new `scala` command could ignore using directives in the initial version, however we strongly suggest to include comment-based using directives from the start. +We have described the motivation, syntax and implementation basis in the [dedicated pre-SIP](https://contributors.scala-lang.org/t/pre-sip-using-directives/5700). Currently, we recommend to write using directives as comments, so making them part of the language specification is not necessary at this stage. Moreover, the new `scala` command could ignore using directives in the initial version, however we strongly suggest to include comment-based using directives from the start. Last section of this proposal contains a sumamry of Using Directives syntax as well as list of directives that MUST and SHOULD be supported. @@ -158,7 +158,7 @@ The release cadence: should the new `scala` command follow the current release c ## Alternatives -Scala CLI has many alternatives. The most obvious ones are sbt, Mill, or other build tools. However, these are more complicated than Scala CLI, and what is more important they are not designed as command-line first tools. Ammonite, is another alternative, however it covers only part of the Scala CLI features (REPL and scripting), and lacks many of the Scala CLI features (incremental compilation, Scala version selection, support for Scala.js and Scala Native, just to name a few). +Scala CLI has many alternatives. The most obvious ones are sbt, Mill, or other build tools. However, these are more complicated than Scala CLI, and what is more important they are not designed as command-line first tools. Ammonite, is another alternative, however it covers only part of the Scala CLI features (REPL and scripting), and lacks many of the Scala CLI features (incremental compilation, Scala version selection, support for Scala.js and Scala Native, just to name a few). ## Related work @@ -196,7 +196,7 @@ Scala Runner MUST support following options from Scala Compiler directly: - `-X` - `-Y` -SHOULD be treated as be Scala compiler options and be propagated to Scala Compiler. This applies to all commands that uses compiler directly or indirectly. +SHOULD be treated as be Scala compiler options and be propagated to Scala Compiler. This applies to all commands that uses compiler directly or indirectly. # MUST have commands @@ -219,7 +219,7 @@ Compile Scala code - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -273,7 +273,7 @@ Generate Scaladoc documentation - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -328,7 +328,7 @@ Fire-up a Scala REPL - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -390,7 +390,7 @@ scala-cli MyApp.scala -- first-arg second-arg - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -470,7 +470,7 @@ println("Hello, world) - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -528,7 +528,7 @@ Format Scala code - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -581,7 +581,7 @@ Compile and test Scala code - `--js-version`: The Scala.js version - `--js-mode`: The Scala.js mode, either `dev` or `release` - `--js-module-kind`: The Scala.js module kind: commonjs/common, esmodule/es, nomodule/none -- `--js-check-ir`: +- `--js-check-ir`: - `--js-emit-source-maps`: Emit source maps - `--js-source-maps-path`: Set the destination path of source maps - `--js-dom`: Enable jsdom @@ -618,7 +618,7 @@ Compile and test Scala code # Using Directives -As a part of this SIP we propose to introduce Using Directives, a special comments containing configuration. Withing Scala CLI and by extension `scala` command, the command line arguments takes precedence over using directives. +As a part of this SIP we propose to introduce Using Directives, a special comments containing configuration. Withing Scala CLI and by extension `scala` command, the command line arguments takes precedence over using directives. Using directives can be place on only top of the file (above imports, package definition etx.) and can be proceed only by plain comments (e.g. to comment out an using directive) diff --git a/_sips/sips/typeclasses-syntax.md b/_sips/sips/typeclasses-syntax.md index 3fb3b807fd..38dcba9293 100644 --- a/_sips/sips/typeclasses-syntax.md +++ b/_sips/sips/typeclasses-syntax.md @@ -1,7 +1,7 @@ --- layout: sip -stage: implementation -status: under-review +stage: completed +status: shipped presip-thread: https://contributors.scala-lang.org/t/pre-sip-improve-syntax-for-context-bounds-and-givens/6576/97 title: SIP-64 - Improve Syntax for Context Bounds and Givens --- diff --git a/_sips/sips/unroll-default-arguments.md b/_sips/sips/unroll-default-arguments.md index eb646d3c64..6d90188b57 100644 --- a/_sips/sips/unroll-default-arguments.md +++ b/_sips/sips/unroll-default-arguments.md @@ -17,7 +17,7 @@ title: SIP-61 - Unroll Default Arguments for Binary Compatibility ## Summary This SIP proposes an `@unroll` annotation lets you add additional parameters -to method `def`s,`class` construtors, or `case class`es, without breaking binary +to method `def`s,`class` construtors, or `case class`es, without breaking binary compatibility. `@unroll` works by generating "unrolled" or "telescoping" forwarders: ```scala @@ -31,19 +31,19 @@ def foo(s: String, n: Int) = foo(s, n, true, 0) In contrast to most existing or proposed alternatives that require you to contort your code to become binary compatible (see [Major Alternatives](#major-alternatives)), -`@unroll` allows you to write Scala with vanilla `def`s/`class`es/`case class`es, add +`@unroll` allows you to write Scala with vanilla `def`s/`class`es/`case class`es, add a single annotation, and your code will maintain binary compatibility as new default -parameters and fields are added over time. +parameters and fields are added over time. -`@unroll`'s only constraints are that: +`@unroll`'s only constraints are that: -1. New parameters need to have a default value +1. New parameters need to have a default value 2. New parameters can only be added on the right 3. The `@unroll`ed methods must be abstract or final These are both existing industry-wide standard when dealing with data and schema evolution (e.g. [Schema evolution in Avro, Protocol Buffers and Thrift — Martin Kleppmann’s blog](https://martin.kleppmann.com/2012/12/05/schema-evolution-in-avro-protocol-buffers-thrift.html)), -and are also the way the new parameters interact with _source compatibility_ in +and are also the way the new parameters interact with _source compatibility_ in the Scala language. Thus these constraints should be immediately familiar to any experienced programmers, and would be easy to follow without confusion. @@ -53,38 +53,38 @@ Prior Discussion can be found [here](https://contributors.scala-lang.org/t/can-w Maintaining binary compatibility of Scala libraries as they evolve over time is difficult. Although tools like https://github.com/lightbend/mima help _surface_ -issues, actually _resolving_ those issues is a different challenge. +issues, actually _resolving_ those issues is a different challenge. -Some kinds of library changes are fundamentally impossible to make compatible, -e.g. removing methods or classes. But there is one big class of binary compatibility +Some kinds of library changes are fundamentally impossible to make compatible, +e.g. removing methods or classes. But there is one big class of binary compatibility issues that are "spurious": adding default parameters to methods, `class` constructors, or `case class`es. Adding a default parameter is source-compatible, but not binary compatible: a user -downstream of a library that adds a default parameter does not need to make any +downstream of a library that adds a default parameter does not need to make any changes to their code, but _does_ need to re-compile it. This is "spurious" because there is no _fundamental_ incompatibility here: semantically, a new default parameter is meant to be optional! Old code invoking that method without a new default parameter is exactly the user intent, and works just fine if the downstream code is re-compiled. -Other languages, such as Python, have the same default parameter language feature but face -no such compatibility issues with their use. Even Scala codebases compiled from source +Other languages, such as Python, have the same default parameter language feature but face +no such compatibility issues with their use. Even Scala codebases compiled from source do not suffer these restrictions: adding a default parameter to the right side of a parameter list is for all intents and purposes backwards compatible in a mono-repo setup. The fact that such addition is binary incompatible is purely an implementation restriction of Scala's binary artifact format and distribution strategy. **Binary compatibility is generally more important than Source compatibility**. When -you hit a source compatibility issue, you can always change the source code you are +you hit a source compatibility issue, you can always change the source code you are compiling, whether manually or via your build tool. In contrast, when you hit binary compatibility issues, it can come in the form of diamond dependencies that would require _re-compiling all of your transitive dependencies_, a task that is far more difficult and often impractical. -There are many approaches to resolving these "spurious" binary compatibility issues, -but most of them involve either tremendous amounts of boilerplate writing -binary-compatibility forwarders, giving up on core language features like Case Classes -or Default Parameters, or both. Consider the following code snippet +There are many approaches to resolving these "spurious" binary compatibility issues, +but most of them involve either tremendous amounts of boilerplate writing +binary-compatibility forwarders, giving up on core language features like Case Classes +or Default Parameters, or both. Consider the following code snippet ([link](https://github.com/com-lihaoyi/mainargs/blob/1d04a6bd19aaca401d11fe26da31615a8bc9213c/mainargs/src/Parser.scala)) from the [com-lihaoyi/mainargs](https://github.com/com-lihaoyi/mainargs) library, which duplicates the parameters of `def constructEither` no less than five times in @@ -159,13 +159,13 @@ parameters are added to `def constructEither`: Apart from being extremely verbose and full of boilerplate, like any boilerplate this is also extremely error-prone. Bugs like [com-lihaoyi/mainargs#106](https://github.com/com-lihaoyi/mainargs/issues/106) -slip through when a mistake is made in that boilerplate. These bugs are impossible to catch -using a normal test suite, as they only appear in the presence of version skew. The above code -snippet actually _does_ have such a bug, that the test suite _did not_ catch. See if you can -spot it! +slip through when a mistake is made in that boilerplate. These bugs are impossible to catch +using a normal test suite, as they only appear in the presence of version skew. The above code +snippet actually _does_ have such a bug, that the test suite _did not_ catch. See if you can +spot it! Sebastien Doraene's talk [Designing Libraries for Source and Binary Compatibility](https://www.youtube.com/watch?v=2wkEX6MCxJs) -explores some of the challenges, and discusses the workarounds. +explores some of the challenges, and discusses the workarounds. ## Requirements @@ -183,19 +183,19 @@ Given: * The behavior should be binary compatible and semantically indistinguishable from using a verion of **Downstream** compiled against the _newer_ version of **Upstream** -**Note:** we do not aim for _Forwards_ compatibility. Using an _older_ -version of **Upstream** with a _newer_ version of **Downstream** compiled against a +**Note:** we do not aim for _Forwards_ compatibility. Using an _older_ +version of **Upstream** with a _newer_ version of **Downstream** compiled against a _newer_ version of **Upstream** is not a use case we want to support. The vast majority of OSS software does not promise forwards compatibility, including software such as the JVM, so we should just follow suite ### All Overrides Are Equivalent -All versions of an `@unroll`ed method `def foo` should have the same semantics when called +All versions of an `@unroll`ed method `def foo` should have the same semantics when called with the same parameters. We must be careful to ensure: 1. All our different method overrides point at the same underlying implementation -2. Abstract methods are properly implemented, and no method would fail with an +2. Abstract methods are properly implemented, and no method would fail with an `AbstractMethodError` when called 3. We properly forward the necessary argument and default parameter values when calling the respective implementation. @@ -257,7 +257,7 @@ object Unrolled{ } ``` -This is a source-compatible change, but not binary-compatible: JVM bytecode compiled against an +This is a source-compatible change, but not binary-compatible: JVM bytecode compiled against an earlier version of the library would be expecting to call `def foo(String, Int)`, but will fail because the signature is now `def foo(String, Int, Boolean)` or `def foo(String, Int, Boolean, Long)`. On the JVM this will result in a `MethodNotFoundError` at runtime, a common experience for anyone @@ -265,7 +265,7 @@ who upgrading the versions of their dependencies. Similar concerns are present w Scala-Native, albeit the failure happens at link-time rather than run-time `@unroll` is an annotation that can be applied as follows, to the first "additional" default -parameter that was added in each published version of the library (in this case, +parameter that was added in each published version of the library (in this case, `b: Boolean = true` and `l: Long = 0`) @@ -292,11 +292,11 @@ object Unrolled{ ``` As a result, old callers who expect `def foo(String, Int, Boolean)` or `def foo(String, Int, Boolean, Long)` -can continue to work, even as new parameters are added to `def foo`. The only restriction is that +can continue to work, even as new parameters are added to `def foo`. The only restriction is that new parameters can only be added on the right, and they must be provided with a default value. If multiple default parameters are added at once (e.g. `b` and `l` below) you can also -choose to only `@unroll` the first default parameter of each batch, to avoid generating +choose to only `@unroll` the first default parameter of each batch, to avoid generating unnecessary forwarders: ```scala @@ -312,8 +312,8 @@ parameter list can be unrolled (though it does not need to be the first one). e. ```scala object Unrolled{ - def foo(s: String, - n: Int = 1, + def foo(s: String, + n: Int = 1, @unroll b: Boolean = true, @unroll l: Long = 0) (implicit blah: Blah) = s + n + b + l @@ -325,8 +325,8 @@ As does this ```scala object Unrolled{ def foo(blah: Blah) - (s: String, - n: Int = 1, + (s: String, + n: Int = 1, @unroll b: Boolean = true, @unroll l: Long = 0) = s + n + b + l } @@ -336,7 +336,7 @@ object Unrolled{ ### Unrolling `class`es -Class constructors and secondary constructors are treated by `@unroll` just like any +Class constructors and secondary constructors are treated by `@unroll` just like any other method: ```scala @@ -405,10 +405,10 @@ Unrolls to: case class Unrolled(s: String, n: Int = 1, @unroll b: Boolean = true, @unroll l: Long = 0L){ def this(s: String, n: Int) = this(s, n, true, 0L) def this(s: String, n: Int, b: Boolean) = this(s, n, b, 0L) - + def copy(s: String, n: Int) = copy(s, n, this.b, this.l) def copy(s: String, n: Int, b: Boolean) = copy(s, n, b, this.l) - + def foo = s + n + b } object Unrolled{ @@ -419,26 +419,26 @@ object Unrolled{ Notes: -1. `@unroll`ed `case class`es are fully binary and backwards compatible in Scala 3, but not in Scala 2 +1. `@unroll`ed `case class`es are fully binary and backwards compatible in Scala 3, but not in Scala 2 2. `.unapply` does not need to be duplicated in Scala 3.x, as its signature `def unapply(x: Unrolled): Unrolled` does not change when new `case class` fields are added. 3. Even in Scala 2.x, where `def unapply(x: Unrolled): Option[TupleN]` is not - binary compatible, pattern matching on `case class`es is already binary compatible - to addition of new fields due to + binary compatible, pattern matching on `case class`es is already binary compatible + to addition of new fields due to [Option-less Pattern Matching](https://docs.scala-lang.org/scala3/reference/changed-features/pattern-matching.html). - Thus, only calls to `.tupled` or `.curried` on the `case class` companion `object`, or direct calls + Thus, only calls to `.tupled` or `.curried` on the `case class` companion `object`, or direct calls to `.unapply` on an unrolled `case class` in Scala 2.x (shown below) - will cause a crash if additional fields were added: + will cause a crash if additional fields were added: ```scala def foo(t: (String, Int)) = println(t) Unrolled.unapply(unrolled).map(foo) ``` -In Scala 3, `@unroll`ing a `case class` also needs to generate a `fromProduct` +In Scala 3, `@unroll`ing a `case class` also needs to generate a `fromProduct` implementation in the companion object, as shown below: ```scala @@ -480,7 +480,7 @@ This is done in two different ways: ## Limitations -### Only the one parameter list of multi-parameter list methods can be `@unroll`ed. +### Only the one parameter list of multi-parameter list methods can be `@unroll`ed. Unrolling multiple parameter lists would generate a number of forwarder methods exponential with regard to the number of parameter lists unrolled, @@ -499,11 +499,11 @@ compatibility on the JVM works. ### `@unroll`ed case classes are only fully binary compatible in Scala 3 -They are _almost_ binary compatible in Scala 2. Direct calls to `unapply` are binary -incompatible, but most common pattern matching of `case class`es goes through a different +They are _almost_ binary compatible in Scala 2. Direct calls to `unapply` are binary +incompatible, but most common pattern matching of `case class`es goes through a different code path that _is_ binary compatible. There are also the `AbstractFunctionN` traits, from which the companion object inherits `.curried` and `.tupled` members. Luckily, `unapply` -was made binary compatible in Scala 3, and `AbstractFunctionN`, `.curried`, and `.tupled` +was made binary compatible in Scala 3, and `AbstractFunctionN`, `.curried`, and `.tupled` were removed ### While `@unroll`ed `case class`es are *not* fully _source_ compatible @@ -539,15 +539,15 @@ default parameters over time. In such extreme scenarios, some kind of builder pa `object` methods and constructors are naturally final, but `class` or `trait` methods that are `@unroll`ed need to be explicitly marked `final`. -It has proved difficult to implement the semantics of `@unroll` in the presence of downstream -overrides, `super`, etc. where the downstream overrides can be compiled against by different +It has proved difficult to implement the semantics of `@unroll` in the presence of downstream +overrides, `super`, etc. where the downstream overrides can be compiled against by different versions of the upstream code. If we can come up with some implementation that works, we can lift this restriction later, but for now I have not managed to do so and so this restriction stays. ### Challenges of Non-Final Methods and Overriding -To elaborate a bit on the issues with non-final methods and overriding, consider the following +To elaborate a bit on the issues with non-final methods and overriding, consider the following case with four classes, `Upstream`, `Downstream`, `Main1` and `Main2`, each of which is compiled against different versions of each other (hence the varying number of parameters for `foo`): @@ -581,14 +581,14 @@ object Main2 { // compiled against Upstream V1 The challenge here is: how do we make sure that `Main1` and `Main2`, who call -`new Downstream().foo`, correctly pick up the version of `def foo` that is -provided by `Downstream`? +`new Downstream().foo`, correctly pick up the version of `def foo` that is +provided by `Downstream`? With the current implementation, the `override def foo` inside `Downstream` would only override one of `Upstream`'s synthetic forwarders, but would not override the actual primary implementation. As a result, we would see `Main1` calling the implementation -of `foo` from `Upstream`, while `Main2` calls the implementation of `foo` from -`Downstream`. So even though both `Main1` and `Main2` have the same +of `foo` from `Upstream`, while `Main2` calls the implementation of `foo` from +`Downstream`. So even though both `Main1` and `Main2` have the same `Upstream` and `Downstream` code on the classpath, they end up calling different implementations based on what they were compiled against. @@ -605,7 +605,7 @@ happen according to what version combinations are supported by our definition of concern due to the requirement that [All Overrides Are Equivalent](#all-overrides-are-equivalent). It may be possible to loosen this restriction to also allow abstract methods that -are implemented only once by a final method. See the section about +are implemented only once by a final method. See the section about [Abstract Methods](#abstract-methods) for details. ## Major Alternatives @@ -626,11 +626,11 @@ takes: The first major difference between `@unroll` and the above alternatives is that these alternatives all introduce something new: some kind of _not-a-case-class_ `class` that is to be used -when binary compatibility is desired. This _not-a-case-class_ has different syntax from +when binary compatibility is desired. This _not-a-case-class_ has different syntax from `case class`es, different semantics, different methods, and so on. In contrast, `@unroll` does not introduce any new language-level or library-level constructs. -The `@unroll` annotation is purely a compiler-backend concern for maintaining binary +The `@unroll` annotation is purely a compiler-backend concern for maintaining binary compatibility. At a language level, `@unroll` allows you to keep using normal method `def`s, `class`es and `case class`es with exactly the same syntax and semantics you have been using all along. @@ -644,10 +644,10 @@ designing their data types, is inferior to simply using `case class`es all the t The alternatives linked above all build a Java-esque "[inner platform](https://en.wikipedia.org/wiki/Inner-platform_effect)" -on top of the Scala language, with its own conventions like `.withFoo` methods. +on top of the Scala language, with its own conventions like `.withFoo` methods. In contrast, `@unroll` makes use of the existing Scala language's default parameters -to achieve the same effect. +to achieve the same effect. If we think Scala is nicer to write then Java due to its language features, then `@unroll`'s approach of leveraging those language features is nicer @@ -662,7 +662,7 @@ things that do not affect typechecking, and `@unroll` fits the bill perfectly. ### Evolving Any Class v.s. Evolving Pre-determined Classes The alternatives given require that the developer has to decide _up front_ whether their -data type needs to be evolved while maintaining binary compatibility. +data type needs to be evolved while maintaining binary compatibility. In contrast, `@unroll` allows you to evolve any existing `class` or `case class`. @@ -680,7 +680,7 @@ Binary compatility is not just a problem for `case class`es adding new fields: n `class` constructors, instance method `def`s, static method `def`s, etc. have default parameters added all the time as well. -In contrast, `@unroll` allows the evolution of `def`s and normal `class`es, in addition +In contrast, `@unroll` allows the evolution of `def`s and normal `class`es, in addition to `case class`es, all using the same approach: 1. `@unroll`ing `case class`es is about _schema evolution_ @@ -690,7 +690,7 @@ to `case class`es, all using the same approach: All three cases above have analogous best practices in the broader software engineering world: whether you are adding an optional column to a database table, adding an optional flag to a command-line tool, are extending an existing protocol with optional -fields that may need handling by both clients and servers implementing that protocol. +fields that may need handling by both clients and servers implementing that protocol. `@unroll` solves all three problems at once - schema evolution, API evolution, and protocol evolution. It does so with the same Scala-level syntax and semantics, with the same requirements @@ -699,7 +699,7 @@ software engineering community. ### Abstract Methods -Apart from `final` methods, `@unroll` also supports purely abstract methods. Consider +Apart from `final` methods, `@unroll` also supports purely abstract methods. Consider the following example with a trait `Unrolled` and an implementation `UnrolledObj`: ```scala @@ -729,7 +729,7 @@ object UnrolledObj extends Unrolled{ // version 3 } ``` -Note that both the abstract methods from `trait Unrolled` and the concrete methods +Note that both the abstract methods from `trait Unrolled` and the concrete methods from `object UnrolledObj` generate forwarders when `@unroll`ed, but the forwarders are generated _in opposite directions_! Unrolled concrete methods forward from longer parameter lists to shorter parameter lists, while unrolled abstract methods forward @@ -753,7 +753,7 @@ UnrolledObj.foo(String, Int, Boolean) UnrolledObj.foo(String, Int, Boolean, Long) ``` -Because such downstream code cannot know which version of `Unrolled` that `UnrolledObj` +Because such downstream code cannot know which version of `Unrolled` that `UnrolledObj` was compiled against, we need to ensure all such calls find their way to the correct implementation of `def foo`, which may be at any of the above signatures. This "double forwarding" strategy ensures that regardless of _which_ version of `.foo` gets called, @@ -761,20 +761,20 @@ it ends up eventually forwarding to the actual implementation of `foo`, with the correct combination of passed arguments and default arguments ```scala -UnrolledObj.foo(String, Int) // forwards to UnrolledObj.foo(String, Int, Boolean) -UnrolledObj.foo(String, Int, Boolean) // actual implementation +UnrolledObj.foo(String, Int) // forwards to UnrolledObj.foo(String, Int, Boolean) +UnrolledObj.foo(String, Int, Boolean) // actual implementation UnrolledObj.foo(String, Int, Boolean, Long) // forwards to UnrolledObj.foo(String, Int, Boolean) ``` -As is the case for `@unroll`ed methods on `trait`s and `class`es, `@unroll`ed +As is the case for `@unroll`ed methods on `trait`s and `class`es, `@unroll`ed implementations of an abtract method must be final. #### Are Reverse Forwarders Really Necessary? -This "double forwarding" strategy is not strictly necessary to support +This "double forwarding" strategy is not strictly necessary to support [Backwards Compatibility](#backwards-compatibility): the "reverse" forwarders generated for abstract methods are only necessary when a downstream callsite -of `UnrolledObj.foo` is compiled against a newer version of the original +of `UnrolledObj.foo` is compiled against a newer version of the original `trait Unrolled` than the `object UnrolledObj` was, as shown below: ```scala @@ -802,14 +802,14 @@ If we did not have the reverse forwarder from `foo(String, Int, Boolean, Long)` It also will get caught by MiMa as a `ReversedMissingMethodProblem`. This configuration of version is not allowed given our definition of backwards compatibility: -that definition assumes that `Unrolled` must be of a greater or equal version than `UnrolledObj`, +that definition assumes that `Unrolled` must be of a greater or equal version than `UnrolledObj`, which itself must be of a greater or equal version than the final call to `UnrolledObj.foo`. However, -the reverse forwarders are needed to fulfill our requirement +the reverse forwarders are needed to fulfill our requirement [All Overrides Are Equivalent](#all-overrides-are-equivalent): looking at `trait Unrolled // version 3` and `object UnrolledObj // version 2` in isolation, we find that without the reverse forwarders the signature `foo(String, Int, Boolean, Long)` is defined but not implemented. Such an un-implemented abstract method is something -we want to avoid, even if our artifact version constraints mean it should technically +we want to avoid, even if our artifact version constraints mean it should technically never get called. ## Minor Alternatives: @@ -819,7 +819,7 @@ never get called. Currently, `@unroll` generates a forwarder only for the annotated default parameter; if you want to generate multiple forwarders, you need to `@unroll` each one. In the -vast majority of scenarios, we want to unroll every default parameters we add, and in +vast majority of scenarios, we want to unroll every default parameters we add, and in many cases default parameters are added one at a time. In this case, an `@unrollAll` annotation may be useful, a shorthand for applying `@unroll` to the annotated default parameter and every parameter to the right of it: @@ -858,9 +858,9 @@ def foo(s: Object, n: Int = 1, b: Boolean = true) = s.toString + n + b + l def foo(s: String, n: Int = 1, b: Boolean = true) = foo(s, n, b) ``` -This would follow the precedence of how Java's and Scala's covariant method return -type overrides are implemented: when a class overrides a method with a new -implementation with a narrower return type, a forwarder method is generated to +This would follow the precedence of how Java's and Scala's covariant method return +type overrides are implemented: when a class overrides a method with a new +implementation with a narrower return type, a forwarder method is generated to allow anyone calling the original signature \to be forwarded to the narrower signature. This is not currently implemented in `@unroll`, but would be a straightforward addition. @@ -893,7 +893,7 @@ The first option results in shorter stack traces, while the second option result roughly half as much generated bytecode in the method bodies (though it's still `O(n^2)`). In order to allow `@unroll`ing of [Abstract Methods](#abstract-methods), we had to go with -the second option. This is because when an abstract method is overriden, it is not necessarily +the second option. This is because when an abstract method is overriden, it is not necessarily true that the longest override that contains the implementation. Thus we need to forward between the different `def foo` overrides one at a time until the override containing the implementation is found. diff --git a/_sips/sips/xistential-containers.md b/_sips/sips/xistential-containers.md new file mode 100644 index 0000000000..a3f4764c3e --- /dev/null +++ b/_sips/sips/xistential-containers.md @@ -0,0 +1,7 @@ +--- +title: 'SIP-69: Existential containers' +status: under-review +pull-request-number: 101 +stage: design + +--- diff --git a/_th/tour/tour-of-scala.md b/_th/tour/tour-of-scala.md index f10a88d77d..ab75a7d541 100644 --- a/_th/tour/tour-of-scala.md +++ b/_th/tour/tour-of-scala.md @@ -13,7 +13,7 @@ next-page: basics ## ยินดีต้อนรับสู่การเดินทาง การเดินทางครั้งนี้ประกอบด้วยการแนะนำแบบสั้นๆ สำหรับแต่ล่ะคุณสมบัติของ Scala ที่ใช้บ่อยที่สุด และมีมีความตั้งใจเพื่อสำหรับผู้ที่เรียนรู้ภาษา Scala ใหม่ -และนี่ก็เป็นเพียงบทความสั้นๆ ที่ไม่ใช้การสอนเต็มรูปแบบของภาษา Scala หากต้องการเรียนรู้มากขึ้นให้พิจารณา[หนังสือ](/books.html) หรือขอคำปรึกษาจาก[แหล่งอื่นๆ](/learn.html) +และนี่ก็เป็นเพียงบทความสั้นๆ ที่ไม่ใช้การสอนเต็มรูปแบบของภาษา Scala หากต้องการเรียนรู้มากขึ้นให้พิจารณา[หนังสือ](/books.html) หรือขอคำปรึกษาจาก[แหล่งอื่นๆ](/online-courses.html) ## อะไรคือ Scala? Scala เป็นภาษาเขียนโปรแกรมแบบหลากหลายกระบวนทัศน์ที่ทันสมัย ที่ออกแบบมาเพื่อแสดงรูปแบบการเขียนโปรแกรมโดยทั่วไปที่กระชับ สง่างาม และมีชนิดข้อมูลที่ปลอดภัย (type-safe) ซึ่งผสานคุณสมบัติของภาษาเชิงวัตถุและภาษาเชิงฟังก์ชัน diff --git a/_tour/pattern-matching.md b/_tour/pattern-matching.md index a89c16775f..f48682afea 100644 --- a/_tour/pattern-matching.md +++ b/_tour/pattern-matching.md @@ -92,7 +92,7 @@ case class VoiceRecording(contactName: String, link: String) extends Notificatio {% endtab %} {% endtabs %} -`Notification` is a sealed trait which has three concrete Notification types implemented with case classes `Email`, `SMS`, and `VoiceRecording`. Now we can do pattern matching on these case classes: +`Notification` is a sealed trait which has three concrete Notification types implemented with case classes `Email`, `SMS`, and `VoiceRecording`. (A [sealed trait](/tour/pattern-matching.html#sealed-types) can be extended only in the same file as its declaration.) Now we can do pattern matching on these case classes: {% tabs pattern-matching-4 class=tabs-scala-version %} {% tab 'Scala 2' for=pattern-matching-4 %} @@ -138,6 +138,69 @@ println(showNotification(someVoiceRecording)) // prints You received a Voice Re The function `showNotification` takes as a parameter the abstract type `Notification` and matches on the type of `Notification` (i.e. it figures out whether it's an `Email`, `SMS`, or `VoiceRecording`). In the `case Email(sender, title, _)` the fields `sender` and `title` are used in the return value but the `body` field is ignored with `_`. +## Matching on string + +The `s`-interpolator allows embedding variables in strings and is also useful for pattern matching. + +{% tabs s-interpolator-pattern-matching class=tabs-scala-version %} +{% tab 'Scala 2' for=s-interpolator-pattern-matching %} +```scala +val input: String = "Alice is 25 years old" + +input match { + case s"$name is $age years old" => s"$name's age is $age" + case _ => "No match" +} +// Result: "Alice's age is 25" +``` +{% endtab %} +{% tab 'Scala 3' for=s-interpolator-pattern-matching %} +```scala +val input: String = "Alice is 25 years old" + +input match + case s"$name is $age years old" => s"$name's age is $age" + case _ => "No match" +// Result: "Alice's age is 25" +``` +{% endtab %} +{% endtabs %} + +In this example, name and age extract parts of the string based on the pattern. This is helpful for parsing structured text. + +We can also use extractor objects for string pattern matching. + +{% tabs s-interpolator-pattern-matching-2 class=tabs-scala-version %} +{% tab 'Scala 2' for=s-interpolator-pattern-matching-2 %} +```scala +object Age { + def unapply(s: String): Option[Int] = s.toIntOption +} + +val input: String = "Alice is 25 years old" + +val (name, age) = input match { + case s"$name is ${Age(age)} years old" => (name, age) +} +// name: String = Alice +// age: Int = 25 +``` +{% endtab %} +{% tab 'Scala 3' for=s-interpolator-pattern-matching-2 %} +```scala +object Age: + def unapply(s: String): Option[Int] = s.toIntOption + +val input: String = "Alice is 25 years old" + +val (name, age) = input match + case s"$name is ${Age(age)} years old" => (name, age) +// name: String = Alice +// age: Int = 25 +``` +{% endtab %} +{% endtabs %} + ## Pattern guards Pattern guards are boolean expressions which are used to make cases more specific. Just add `if ` after the pattern. diff --git a/_tour/singleton-objects.md b/_tour/singleton-objects.md index 47a67ee175..828d49a38a 100644 --- a/_tour/singleton-objects.md +++ b/_tour/singleton-objects.md @@ -196,6 +196,14 @@ scalaCenterEmail match The `object Email` contains a factory `fromString` which creates an `Email` instance from a String. We return it as an `Option[Email]` in case of parsing errors. +A note about `Option`, `Some`, and `None` in the code above: +* `Option` is a data type which allows for optionality. It has two cases: `Some` and `None` + * `Some` above represents a match: the emailString, when split by a @, returns an array with two components. This allows creation of a valid instance of class Email. + * `None` above represents no match: the emailString, when split by a @, did not return an array with two components. It could not allow creation of a valid instance of class Email. +* The `Option` return type can then be used in a match/case: + * For a `Some` result, the match knows the returned value is an instance of `Email`, so it can access the inner `username` and `domainName`. + * For a `None` result, the match knows the returned value is not an instance of `Email`, so it prints an appropriate error message. + Note: If a class or object has a companion, both must be defined in the same file. To define companions in the REPL, either define them on the same line or enter `:paste` mode. ## Notes for Java programmers ## diff --git a/_tour/tour-of-scala.md b/_tour/tour-of-scala.md index 49f0d2b7e2..16052b51f8 100644 --- a/_tour/tour-of-scala.md +++ b/_tour/tour-of-scala.md @@ -18,8 +18,8 @@ This tour contains bite-sized introductions to the most frequently used features of Scala. It is intended for newcomers to the language. This is just a brief tour, not a full language tutorial. If -you want a more detailed guide, consider obtaining [a book](/books.html) or consulting -[other resources](/learn.html). +you want a more detailed guide, consider obtaining [a book](/books.html) or taking +[an online courses](/online-courses.html). ## What is Scala? Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It seamlessly integrates features of object-oriented and functional languages. @@ -30,8 +30,6 @@ Scala is a pure object-oriented language in the sense that [every value is an ob ## Scala is functional ## Scala is also a functional language in the sense that [every function is a value](unified-types.html). Scala provides a [lightweight syntax](basics.html#functions) for defining anonymous functions, supports [higher-order functions](higher-order-functions.html), allows functions to be [nested](nested-functions.html), and supports [currying](multiple-parameter-lists.html). Scala's [case classes](case-classes.html) and its built-in support for [pattern matching](pattern-matching.html) provide the functionality of algebraic types, which are used in many functional languages. [Singleton objects](singleton-objects.html) provide a convenient way to group functions that aren't members of a class. -Furthermore, Scala's notion of pattern matching naturally extends to the [processing of XML data](https://github.com/scala/scala-xml/wiki/XML-Processing) with the help of [right-ignoring sequence patterns](regular-expression-patterns.html), by way of general extension via [extractor objects](extractor-objects.html). In this context, [for comprehensions](for-comprehensions.html) are useful for formulating queries. These features make Scala ideal for developing applications like web services. - ## Scala is statically typed ## Scala's expressive type system enforces, at compile-time, that abstractions are used in a safe and coherent manner. In particular, the type system supports: diff --git a/_uk/getting-started/install-scala.md b/_uk/getting-started/install-scala.md index 9725b362e9..d8ae3efbd9 100644 --- a/_uk/getting-started/install-scala.md +++ b/_uk/getting-started/install-scala.md @@ -212,7 +212,7 @@ Scala version (default): {{site.scala-3-version}} * [Книга по Scala](/scala3/book/introduction.html) (версія по Scala 2 [тут](/overviews/scala-book/introduction.html)), яка містить коротких ознайомчих уроків з основних можливостей Scala. * [Тур по Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features. -* [Навчальні ресурси](/learn.html), що містять інтерактивні онлайн путівники та курси. +* [Навчальні ресурси](/online-courses.html), що містять інтерактивні онлайн путівники та курси. * [Наш список деяких популярних книжок по Scala](/books.html). * [Посібник з міграції](/scala3/guides/migration/compatibility-intro.html) допомагає перевести ваш наявний проєкт зі Scala 2 на Scala 3. diff --git a/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md b/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md index de7135cf1b..b2e1a9f801 100644 --- a/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md +++ b/_uk/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md @@ -18,7 +18,7 @@ previous-page: /uk/building-a-scala-project-with-intellij-and-sbt 1. Додайте залежність ScalaTest: 1. Додайте залежність ScalaTest у файл `build.sbt` вашого проєкту: ``` - libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test + libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.19" % Test ``` 1. Ви побачите сповіщення "build.sbt was changed", оберіть **auto-import**. 1. Ці дві дії призведуть до того, що `sbt` завантажить бібліотеку ScalaTest. diff --git a/_uk/scala3/talks.md b/_uk/scala3/talks.md index 9aa70a4835..01087ab671 100644 --- a/_uk/scala3/talks.md +++ b/_uk/scala3/talks.md @@ -17,18 +17,18 @@ versionSpecific: true Talks on Scala 3 ---------------- - (ScalaDays 2019, Lausanne) [Тур по Scala 3](https://www.youtube.com/watch?v=_Rnrx2lo9cw) - від [Martin Odersky](http://twitter.com/odersky) + від [Martin Odersky](http://x.com/odersky) - (ScalaDays 2016, Berlin) [Попереду дорога Scala](https://www.youtube.com/watch?v=GHzWqJKFCk4) - від [Martin Odersky](http://twitter.com/odersky) + від [Martin Odersky](http://x.com/odersky) [\[слайди\]](http://www.slideshare.net/Odersky/scala-days-nyc-2016) - (JVMLS 2015) [Compilers are Databases](https://www.youtube.com/watch?v=WxyyJyB_Ssc) - від [Martin Odersky](http://twitter.com/odersky) + від [Martin Odersky](http://x.com/odersky) [\[слайди\]](http://www.slideshare.net/Odersky/compilers-are-databases) - (Scala World 2015) [Dotty: Досліджуємо майбутнє Scala](https://www.youtube.com/watch?v=aftdOFuVU1o) - від [Dmitry Petrashko](http://twitter.com/darkdimius) + від [Dmitry Petrashko](http://x.com/darkdimius) [\[слайди\]](https://d-d.me/scalaworld2015/#/). Розповідь Дмітрія охоплює багато нових функцій, які приносить Dotty, наприклад типи Intersection та Union, покращена ініціалізація lazy val тощо. Дмітрій також розповідає внутрішню архітектуру Dotty і, зокрема, високий рівень контекстуальних абстракцій Dotty. Ви @@ -43,20 +43,20 @@ Deep Dive with Scala 3 від [[Guillaume Martres](http://guillaume.martres.me/)](http://guillaume.martres.me/). - (Mar 21, 2017) [Dotty Internals 1: Trees та Symbols](https://www.youtube.com/watch?v=yYd-zuDd3S8) - від [Dmitry Petrashko](http://twitter.com/darkdimius) + від [Dmitry Petrashko](http://x.com/darkdimius) [\[meeting notes\]](https://dotty.epfl.ch/docs/internals/dotty-internals-1-notes.html). Це запис зустрічі EPFL та Waterloo, де були представлені перші нотатки про Dotty: Trees та Symbols. - (Mar 21, 2017) [Dotty Internals 2: Types](https://www.youtube.com/watch?v=3gmLIYlGbKc) - від [Martin Odersky](http://twitter.com/odersky) та [Dmitry Petrashko](http://twitter.com/darkdimius). + від [Martin Odersky](http://x.com/odersky) та [Dmitry Petrashko](http://x.com/darkdimius). Це запис зустрічі EPFL та Waterloo, де були представлено як представлені типи всередині Dotty. - (Jun 15, 2017) [Dotty Internals 3: Denotations](https://youtu.be/9iPA7zMRGKY) - від [Martin Odersky](http://twitter.com/odersky) та [Dmitry Petrashko](http://twitter.com/darkdimius). + від [Martin Odersky](http://x.com/odersky) та [Dmitry Petrashko](http://x.com/darkdimius). Це запис зустрічі EPFL та Waterloo, де були представлена денотація в Dotty. - (JVM Language Summit) [Як зробити компілятор Dotty швидким](https://www.youtube.com/watch?v=9xYoSwnSPz0) - від [Dmitry Petrashko](http://twitter.com/darkdimius). + від [Dmitry Petrashko](http://x.com/darkdimius). Дмітрій дає високорівневий вступ до того, що було зроблено для створення Dotty . - (Typelevel Summit Oslo, May 2016) [Dotty та типи: поки що історія](https://www.youtube.com/watch?v=YIQjfCKDR5A) @@ -66,7 +66,7 @@ Deep Dive with Scala 3 який здатний робити висновки про безпеку типів для більшої кількості ситуацій ніж scalac. - (flatMap(Oslo) 2016) [AutoSpecialization в Dotty](https://vimeo.com/165928176) - від [Dmitry Petrashko](http://twitter.com/darkdimius) + від [Dmitry Petrashko](http://x.com/darkdimius) [\[слайди\]](https://d-d.me/talks/flatmap2016/#/). Компонувальник Dotty аналізує вашу програму та її залежності, щоб застосувати нову схему спеціалізації. Віна ґрунтується на нашому досвіді з Specialization, Miniboxing та Valhalla Project, @@ -84,7 +84,7 @@ Deep Dive with Scala 3 Гійом демонструє високорівневе представлення пайплайну компіляції в Dotty. - (ScalaDays 2015, Amsterdam) [Як зробити ваші програми на Scala меншими та швидшими за допомогою компонувальника Dotty](https://www.youtube.com/watch?v=xCeI1ArdXM4) - від [Dmitry Petrashko](http://twitter.com/darkdimius) + від [Dmitry Petrashko](http://x.com/darkdimius) [\[слайди\]](https://d-d.me/scaladays2015/#/). Дмитрій представляє алгоритм аналізу графу виклик у Dotty та переваги продуктивності, які ми можемо отримати з точки зору кількості методів, розміру байт-коду, розміру коду JVM і кількість об'єктів, виділених в кінці. diff --git a/_zh-cn/overviews/scala3-book/scala-features.md b/_zh-cn/overviews/scala3-book/scala-features.md index 946b8e819f..9c8d02f085 100644 --- a/_zh-cn/overviews/scala3-book/scala-features.md +++ b/_zh-cn/overviews/scala3-book/scala-features.md @@ -281,7 +281,7 @@ Scala 是一门面向对象编程(OOP)语言。 ### 支持 FP 与 OOP 融合 {% comment %} -NOTE: This text in the first line comes from this slide: https://twitter.com/alexelcu/status/996408359514525696 +NOTE: This text in the first line comes from this slide: https://x.com/alexelcu/status/996408359514525696 {% endcomment %} Scala 的本质是函数式编程和面向对象编程的融合: diff --git a/_zh-cn/overviews/scala3-book/tools-sbt.md b/_zh-cn/overviews/scala3-book/tools-sbt.md index d77b8d6286..0d9b5ab08d 100644 --- a/_zh-cn/overviews/scala3-book/tools-sbt.md +++ b/_zh-cn/overviews/scala3-book/tools-sbt.md @@ -361,7 +361,7 @@ version := "0.1" scalaVersion := "{{site.scala-3-version}}" libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.2.9" % Test + "org.scalatest" %% "scalatest" % "3.2.19" % Test ) ``` diff --git a/_zh-cn/tour/tour-of-scala.md b/_zh-cn/tour/tour-of-scala.md index df7288f109..78b70dd115 100644 --- a/_zh-cn/tour/tour-of-scala.md +++ b/_zh-cn/tour/tour-of-scala.md @@ -13,7 +13,7 @@ next-page: basics ## 欢迎来到Scala之旅 本次 Scala 之旅教程包含了对于大多数 Scala 特性的简单介绍。主要针对 Scala 这门语言的初学者。 -这是个简化的教程,如果希望得到完整的话,可以考虑购买[书籍](/books.html)或者参考[其他资源](/learn.html)。 +这是个简化的教程,如果希望得到完整的话,可以考虑购买[书籍](/books.html)或者参考[其他资源](/online-courses.html)。 ## Scala是什么? Scala是一门现代的多范式语言,志在以简洁、优雅及类型安全的方式来表达常用的编程模型。它平滑地集成了面向对象和函数式语言的特性。 diff --git a/api/all.md b/api/all.md index db37824fc7..4ef460e114 100644 --- a/api/all.md +++ b/api/all.md @@ -10,12 +10,12 @@ redirect_from: * Scala {{site.scala-3-version}} * [Library API](https://www.scala-lang.org/api/{{site.scala-3-version}}/) -* Scala 3.3.4 LTS - * [Library API](https://www.scala-lang.org/api/3.3.4/) -* Scala 2.13.15 - * [Library API](https://www.scala-lang.org/api/2.13.15/) - * [Compiler API](https://www.scala-lang.org/api/2.13.15/scala-compiler/scala/) - * [Reflection API](https://www.scala-lang.org/api/2.13.15/scala-reflect/scala/reflect/) +* Scala 3.3.5 LTS + * [Library API](https://www.scala-lang.org/api/3.3.5/) +* Scala 2.13.16 + * [Library API](https://www.scala-lang.org/api/2.13.16/) + * [Compiler API](https://www.scala-lang.org/api/2.13.16/scala-compiler/scala/) + * [Reflection API](https://www.scala-lang.org/api/2.13.16/scala-reflect/scala/reflect/) * Scala 2.12.20 * [Library API](https://www.scala-lang.org/api/2.12.20/) * [Compiler API](https://www.scala-lang.org/api/2.12.20/scala-compiler/scala/) @@ -64,6 +64,10 @@ https://scala-ci.typesafe.com/artifactory/scala-integration/org/scala-lang/ ## Previous releases +* Scala 3.6.2 + * [Library API](https://www.scala-lang.org/api/3.6.2/) +* Scala 3.5.2 + * [Library API](https://www.scala-lang.org/api/3.5.2/) * Scala 3.5.1 * [Library API](https://www.scala-lang.org/api/3.5.1/) * Scala 3.5.0 @@ -76,6 +80,8 @@ https://scala-ci.typesafe.com/artifactory/scala-integration/org/scala-lang/ * [Library API](https://www.scala-lang.org/api/3.4.1/) * Scala 3.4.0 * [Library API](https://www.scala-lang.org/api/3.4.0/) +* Scala 3.3.4 LTS + * [Library API](https://www.scala-lang.org/api/3.3.4/) * Scala 3.3.3 LTS * [Library API](https://www.scala-lang.org/api/3.3.3/) * Scala 3.3.1 LTS @@ -102,6 +108,10 @@ https://scala-ci.typesafe.com/artifactory/scala-integration/org/scala-lang/ * [Library API](https://www.scala-lang.org/api/3.0.1/) * Scala 3.0.0 * [Library API](https://www.scala-lang.org/api/3.0.0/) +* Scala 2.13.15 + * [Library API](https://www.scala-lang.org/api/2.13.15/) + * [Compiler API](https://www.scala-lang.org/api/2.13.15/scala-compiler/scala/) + * [Reflection API](https://www.scala-lang.org/api/2.13.15/scala-reflect/scala/reflect/) * Scala 2.13.14 * [Library API](https://www.scala-lang.org/api/2.13.14/) * [Compiler API](https://www.scala-lang.org/api/2.13.14/scala-compiler/scala/) diff --git a/learn.md b/learn.md deleted file mode 100644 index baf01b8488..0000000000 --- a/learn.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Online Resources -layout: singlepage-overview -languages: [ru] -redirect_from: - - /documentation/books.html ---- - -## Try Scala in your browser! - -There are a handful of websites where you can interactively run Scala code in your browser! Have a look at [Scastie](https://scastie.scala-lang.org/). - -## Online courses from the Scala Center - -The [Scala Center](https://scala.epfl.ch) is committed to creating high-quality -and freely available online courses for learning Scala and functional -programming. The course levels range from beginner to advanced. -More details on [this page]({% link online-courses.md %}). - -## Scala Exercises - -[Scala Exercises](https://www.scala-exercises.org/) is a series of lessons and exercises created by [47 Degrees](https://www.47deg.com/). It's a great way to get a brief introduction to Scala while testing your knowledge along the way. - -[Tour of Scala](https://tourofscala.com) gives you an introduction to Scala, step by step, from beginner to expert. - -## Dr. Mark C Lewis's lectures from Trinity University - -[Dr. Mark C Lewis](https://www.cs.trinity.edu/~mlewis/) from Trinity University, San Antonio, TX, teaches programming courses using the Scala language. Course videos are available in YouTube for free. Some courses below. - - * [Introduction to Programming and Problem Solving Using Scala](https://www.youtube.com/playlist?list=PLLMXbkbDbVt9MIJ9DV4ps-_trOzWtphYO) - * [Object-Orientation, Abstraction, and Data Structures Using Scala](https://www.youtube.com/playlist?list=PLLMXbkbDbVt8JLumqKj-3BlHmEXPIfR42) - -You can visit his [YouTube channel](https://www.youtube.com/user/DrMarkCLewis/featured) for more videos. - -## Scala Learning Community -[Scala Learning Community on Discord](http://sca.la/learning-community), a growing online community connecting learners with online resources to learn Scala together. - -## allaboutscala -[allaboutscala](https://allaboutscala.com/) provides detailed tutorials for beginners. - -## DevInsideYou -[DevInsideYou](https://youtube.com/devinsideyou) is a YouTube channel with hundreds of hours of free Scala content. - -## Rock the JVM -[Rock the JVM](https://rockthejvm.com) is a learning platform with free and premium courses on the Scala language, Akka, Cats Effect, ZIO, Apache Spark and other tools in the Scala ecosystem. It also has hundreds of [free video tutorials](https://youtube.com/rockthejvm) and [articles](https://blog.rockthejvm.com) on a variety of Scala-related topics. - -## Visual Scala Reference -[Visual Scala Reference](https://superruzafa.github.io/visual-scala-reference/), a guide to visually learn about Scala concepts and functions. diff --git a/online-courses.md b/online-courses.md index d31159ef6a..6b65a5115f 100644 --- a/online-courses.md +++ b/online-courses.md @@ -1,169 +1,43 @@ --- -title: Online Courses (MOOCs) from The Scala Center -layout: singlepage-overview -languages: [ru] -testimonials: - - /resources/images/online-courses/testimonial000.jpg - - /resources/images/online-courses/testimonial001.jpg - - /resources/images/online-courses/testimonial002.jpg - - /resources/images/online-courses/testimonial003.jpg - - /resources/images/online-courses/testimonial004.jpg - - /resources/images/online-courses/testimonial005.jpg - - /resources/images/online-courses/testimonial006.jpg - - /resources/images/online-courses/testimonial007.jpg - - /resources/images/online-courses/testimonial008.jpg - - /resources/images/online-courses/testimonial009.jpg - - /resources/images/online-courses/testimonial010.jpg - - /resources/images/online-courses/testimonial011.jpg - - /resources/images/online-courses/testimonial012.jpg - - /resources/images/online-courses/testimonial013.jpg - - /resources/images/online-courses/testimonial014.jpg +title: Online Courses +layout: online-courses +redirect_from: + - /documentation/books.html + - /learn --- -The [Scala Center] produces online courses (a.k.a. MOOCs) of various levels, from beginner -to advanced. - -**If you are a programmer and want to learn Scala**, there are two recommended -approaches. The fast path consists of taking the course [Effective Programming -in Scala](#effective-programming-in-scala). -Otherwise, you can take the full [Scala Specialization], which is made of -four courses (covering advanced topics such as big data analysis and -parallel programming) and a capstone project. - -You can learn more about the courses in the following video: - -
- -
- -## Scala Learning Path - -The diagram below summarizes the possible learning paths with our courses: - -![](/resources/images/learning-path.png) - -The “foundational” courses target programmers with no prior experience in Scala, whereas the “deepening” -courses aim at strengthening Scala programmers skills in a specific domain (such as parallel programming). - -We recommend starting with either Effective Programming in Scala, or Functional Programming Principles in -Scala followed by Functional Program Design. Then, you can complement your Scala skills by taking any -of the courses Programming Reactive Systems, Parallel Programming, or Big Data Analysis with Scala and Spark. -In case you take the Scala Specialization, you will end with the Scala Capstone Project. - -## Learning Platforms - -Currently, all our MOOCs are available on the platform [Coursera](https://coursera.org), -and some of them are available on [edX](https://edx.org) or the [Extension School](https://extensionschool.ch). -This section explains the differences between these learning platforms. - -On all the platforms the full material is always available online. It includes -video lectures, text articles, quizzes, and auto-graded homeworks. All the -platforms also provide discussion forums where you can exchange with the -other learners. - -The difference between the Extension School and the other platforms is that it -provides live meetings with instructors, and code reviews by Scala experts. - -On the other hand, on Coursera or edX it is possible to take -our courses for free (a.k.a. “audit” mode). Optionally, a subscription gives -you access to a certificate of completion that attests your accomplishments. - -Learn more about -[Coursera certificates](https://learners.coursera.help/hc/en-us/articles/209819053-Get-a-Course-Certificate), -[edX certificates](https://support.edx.org/hc/en-us/categories/115002269627-Certificates), -or [Extension School certificates](https://www.extensionschool.ch/faqs#certifying-coursework). -Note that your subscriptions also supports the work of the [Scala Center], -whose mission is to create high-quality educational material. - -If you prefer learning in autonomy, we recommend -you to choose the Coursera or edX platform, but if you are looking for more -support, we recommend you to choose the Extension School. Here is a table -below that compares the learning platforms: - -| | Coursera / edX (audit) | Coursera / edX (subscription) | Extension School | -|--------------------------------------------------|------------------------|-------------------------------|------------------| -| Video lectures, quizzes | Yes | Yes | Yes | -| Auto-graded homeworks | Yes | Yes | Yes | -| Discussion forums | Yes | Yes | Yes | -| Self-paced | Yes | Yes | Yes | -| Price | $0 | $50 to $100 per course | $420 per month | -| Certificate of completion | No | Yes | Yes | -| Supports the Scala Center | No | Yes | Yes | -| 30 min of live session with instructors per week | No | No | Yes | -| Code reviews by Scala experts | No | No | Yes | +## Other Online Resources -## Effective Programming in Scala +### Tour of Scala -This course is available on [Coursera](https://coursera.org/learn/effective-scala) -and the [Extension School](https://extensionschool.ch/learn/effective-programming-in-scala). -Please refer to [this section](#learning-platforms) to know the differences -between both learning platforms. +[Tour of Scala](https://tourofscala.com) is an interactive website that introduces the basics of Scala programming through a series of hands-on lessons. +Each lesson provides code examples and exercises that compiles and runs directly in the browser, making it a quick and accessible way to get started with Scala. -[Effective Programming in Scala] teaches non-Scala programmers everything -they need to be ready to work in Scala. At the end of this hands-on course, -you will know how to achieve common programming tasks in Scala (e.g., -modeling business domains, implementing business logic, designing large -systems made of components, handling errors, manipulating data, running -concurrent tasks in parallel, testing your code). You can learn more about -this course in the following video: +In the [Scala Learning Discord](http://sca.la/learning-community), you can connect with fellow Scala learners and engage with the Tour of Scala community. -
- -
+### Scala Exercises -This course is also a good way to upgrade your Scala 2 knowledge to Scala 3. +[Scala Exercises](https://www.scala-exercises.org/) is a series of lessons and exercises created by [47 Degrees](https://www.47deg.com/). +It's a great way to get a brief introduction to Scala while testing your knowledge along the way. +It also covers some libraries of the ecosystem such as cats, doobie, scalacheck etc. -After taking this course, you might be interested in improving your -skills in specific areas by taking the courses [Parallel Programming], -[Big Data Analysis with Scala and Spark], or [Programming Reactive Systems]. +### DevInsideYou -## Scala Specialization +[DevInsideYou](https://youtube.com/devinsideyou) is a YouTube channel with hundreds of hours of free Scala content. -The [Scala Specialization] provides a hands-on introduction to functional programming using Scala. You can access the courses -material and exercises by either signing up for the specialization or auditing the courses individually. The -specialization has the following courses. -* [Functional Programming Principles in Scala], -* [Functional Program Design in Scala], -* [Parallel programming], -* [Big Data Analysis with Scala and Spark], -* [Functional Programming in Scala Capstone]. +### Visual Scala Reference -These courses provide a deep understanding of the Scala language itself, -and they also dive into more specific topics such as parallel programming, -and Spark. +[Visual Scala Reference](https://superruzafa.github.io/visual-scala-reference/) is a visual guide to the most common methods of the Scala collections. -## Programming Reactive Systems +### allaboutscala -[Programming Reactive Systems] (also available on [edX](https://www.edx.org/course/scala-akka-reactive)) -teaches how to write responsive, scalable, and resilient systems with the -library Akka. +[allaboutscala](https://allaboutscala.com/) provides detailed tutorials for beginners. -## Scala 2 Courses +### Dr. Mark C Lewis's lectures from Trinity University -The above courses all use Scala 3. If needed, you can find -the (legacy) Scala 2 version of our courses here: - -- [Functional Programming Principles in Scala (Scala 2 version)](https://www.coursera.org/learn/scala2-functional-programming) -- [Functional Program Design (Scala 2 version)](https://www.coursera.org/learn/scala2-functional-program-design) -- [Parallel Programming (Scala 2 version)](https://www.coursera.org/learn/scala2-parallel-programming) -- [Big Data Analysis with Scala and Spark (Scala 2 version)](https://www.coursera.org/learn/scala2-spark-big-data) -- [Programming Reactive Systems (Scala 2 version)](https://www.coursera.org/learn/scala2-akka-reactive) - -## Testimonials - -{% include carousel.html images=page.testimonials number=0 height="50" unit="%" duration="10" %} +[Dr. Mark C Lewis](https://www.cs.trinity.edu/~mlewis/) from Trinity University, San Antonio, TX, teaches programming courses using the Scala language. Course videos are available in YouTube for free. Some courses below. -## Other Online Resources +- [Introduction to Programming and Problem Solving Using Scala](https://www.youtube.com/playlist?list=PLLMXbkbDbVt9MIJ9DV4ps-_trOzWtphYO) +- [Object-Orientation, Abstraction, and Data Structures Using Scala](https://www.youtube.com/playlist?list=PLLMXbkbDbVt8JLumqKj-3BlHmEXPIfR42) -You can find other online resources contributed by the community on -[this page]({% link learn.md %}). - -[Scala Center]: https://scala.epfl.ch -[Scala Specialization]: https://www.coursera.org/specializations/scala -[Effective Programming in Scala]: https://www.coursera.org/learn/effective-scala -[Functional Programming Principles in Scala]: https://www.coursera.org/learn/scala-functional-programming -[Functional Program Design in Scala]: https://www.coursera.org/learn/scala-functional-program-design -[Parallel programming]: https://www.coursera.org/learn/scala-parallel-programming -[Big Data Analysis with Scala and Spark]: https://www.coursera.org/learn/scala-spark-big-data -[Functional Programming in Scala Capstone]: https://www.coursera.org/learn/scala-capstone -[Programming Reactive Systems]: https://www.coursera.org/learn/scala-akka-reactive +You can visit his [YouTube channel](https://www.youtube.com/user/DrMarkCLewis/featured) for more videos. diff --git a/resources/css/style.scss b/resources/css/style.scss index 938b0974e8..5f30379a90 100755 --- a/resources/css/style.scss +++ b/resources/css/style.scss @@ -55,6 +55,7 @@ @import 'layout/training-events'; @import 'layout/blog'; @import 'layout/download'; +@import 'layout/online-courses'; @import 'layout/content-contributors'; // COMPONENTS @import 'layout/details-summary'; //------------------------------------------------ diff --git a/resources/images/online-courses/coursera.png b/resources/images/online-courses/coursera.png new file mode 100644 index 0000000000..a329139aa0 Binary files /dev/null and b/resources/images/online-courses/coursera.png differ diff --git a/resources/images/online-courses/extension-school.png b/resources/images/online-courses/extension-school.png new file mode 100644 index 0000000000..94da532d8c Binary files /dev/null and b/resources/images/online-courses/extension-school.png differ diff --git a/resources/images/online-courses/rock-the-jvm.png b/resources/images/online-courses/rock-the-jvm.png new file mode 100644 index 0000000000..86b6512c0b Binary files /dev/null and b/resources/images/online-courses/rock-the-jvm.png differ diff --git a/resources/images/online-courses/testimonial000.jpg b/resources/images/scalacenter-courses/testimonial000.jpg similarity index 100% rename from resources/images/online-courses/testimonial000.jpg rename to resources/images/scalacenter-courses/testimonial000.jpg diff --git a/resources/images/online-courses/testimonial001.jpg b/resources/images/scalacenter-courses/testimonial001.jpg similarity index 100% rename from resources/images/online-courses/testimonial001.jpg rename to resources/images/scalacenter-courses/testimonial001.jpg diff --git a/resources/images/online-courses/testimonial002.jpg b/resources/images/scalacenter-courses/testimonial002.jpg similarity index 100% rename from resources/images/online-courses/testimonial002.jpg rename to resources/images/scalacenter-courses/testimonial002.jpg diff --git a/resources/images/online-courses/testimonial003.jpg b/resources/images/scalacenter-courses/testimonial003.jpg similarity index 100% rename from resources/images/online-courses/testimonial003.jpg rename to resources/images/scalacenter-courses/testimonial003.jpg diff --git a/resources/images/online-courses/testimonial004.jpg b/resources/images/scalacenter-courses/testimonial004.jpg similarity index 100% rename from resources/images/online-courses/testimonial004.jpg rename to resources/images/scalacenter-courses/testimonial004.jpg diff --git a/resources/images/online-courses/testimonial005.jpg b/resources/images/scalacenter-courses/testimonial005.jpg similarity index 100% rename from resources/images/online-courses/testimonial005.jpg rename to resources/images/scalacenter-courses/testimonial005.jpg diff --git a/resources/images/online-courses/testimonial006.jpg b/resources/images/scalacenter-courses/testimonial006.jpg similarity index 100% rename from resources/images/online-courses/testimonial006.jpg rename to resources/images/scalacenter-courses/testimonial006.jpg diff --git a/resources/images/online-courses/testimonial007.jpg b/resources/images/scalacenter-courses/testimonial007.jpg similarity index 100% rename from resources/images/online-courses/testimonial007.jpg rename to resources/images/scalacenter-courses/testimonial007.jpg diff --git a/resources/images/online-courses/testimonial008.jpg b/resources/images/scalacenter-courses/testimonial008.jpg similarity index 100% rename from resources/images/online-courses/testimonial008.jpg rename to resources/images/scalacenter-courses/testimonial008.jpg diff --git a/resources/images/online-courses/testimonial009.jpg b/resources/images/scalacenter-courses/testimonial009.jpg similarity index 100% rename from resources/images/online-courses/testimonial009.jpg rename to resources/images/scalacenter-courses/testimonial009.jpg diff --git a/resources/images/online-courses/testimonial010.jpg b/resources/images/scalacenter-courses/testimonial010.jpg similarity index 100% rename from resources/images/online-courses/testimonial010.jpg rename to resources/images/scalacenter-courses/testimonial010.jpg diff --git a/resources/images/online-courses/testimonial011.jpg b/resources/images/scalacenter-courses/testimonial011.jpg similarity index 100% rename from resources/images/online-courses/testimonial011.jpg rename to resources/images/scalacenter-courses/testimonial011.jpg diff --git a/resources/images/online-courses/testimonial012.jpg b/resources/images/scalacenter-courses/testimonial012.jpg similarity index 100% rename from resources/images/online-courses/testimonial012.jpg rename to resources/images/scalacenter-courses/testimonial012.jpg diff --git a/resources/images/online-courses/testimonial013.jpg b/resources/images/scalacenter-courses/testimonial013.jpg similarity index 100% rename from resources/images/online-courses/testimonial013.jpg rename to resources/images/scalacenter-courses/testimonial013.jpg diff --git a/resources/images/online-courses/testimonial014.jpg b/resources/images/scalacenter-courses/testimonial014.jpg similarity index 100% rename from resources/images/online-courses/testimonial014.jpg rename to resources/images/scalacenter-courses/testimonial014.jpg diff --git a/resources/js/tweetMachine-update.js b/resources/js/tweetMachine-update.js index a7604d2ba7..0addd1b951 100755 --- a/resources/js/tweetMachine-update.js +++ b/resources/js/tweetMachine-update.js @@ -133,11 +133,11 @@ }); // Usernames text = text.replace(/@[A-Za-z0-9_]+/g, function (u) { - return '' + u + ''; + return '' + u + ''; }); // Hashtags text = text.replace(/#[A-Za-z0-9_\-]+/g, function (u) { - return '' + u + ''; + return '' + u + ''; }); return text; }, @@ -160,7 +160,7 @@ // Set the user screen name var usernameLink = "" + "@" @@ -170,7 +170,7 @@ // Set the username: var userLink = "" + actualTweet.user.name @@ -178,7 +178,7 @@ tweetObj.find('.user').html("" + userLink); // Set the timestamp - var dateLink = "" + tweetMachine.relativeTime(actualTweet.created_at) @@ -411,4 +411,4 @@ } }); }; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/scala3/talks.md b/scala3/talks.md index 19539ba13d..0cdba8b2d0 100644 --- a/scala3/talks.md +++ b/scala3/talks.md @@ -16,13 +16,13 @@ advantage of the new language features, or how to migrate from Scala 2. Talks on Scala 3 ---------------- -- (ScalaDays 2019, Lausanne) [A Tour of Scala 3](https://www.youtube.com/watch?v=_Rnrx2lo9cw) by [Martin Odersky](http://twitter.com/odersky) +- (ScalaDays 2019, Lausanne) [A Tour of Scala 3](https://www.youtube.com/watch?v=_Rnrx2lo9cw) by [Martin Odersky](http://x.com/odersky) -- (ScalaDays 2016, Berlin) [Scala's Road Ahead](https://www.youtube.com/watch?v=GHzWqJKFCk4) by [Martin Odersky](http://twitter.com/odersky) [\[slides\]](http://www.slideshare.net/Odersky/scala-days-nyc-2016) +- (ScalaDays 2016, Berlin) [Scala's Road Ahead](https://www.youtube.com/watch?v=GHzWqJKFCk4) by [Martin Odersky](http://x.com/odersky) [\[slides\]](http://www.slideshare.net/Odersky/scala-days-nyc-2016) -- (JVMLS 2015) [Compilers are Databases](https://www.youtube.com/watch?v=WxyyJyB_Ssc) by [Martin Odersky](http://twitter.com/odersky) [\[slides\]](http://www.slideshare.net/Odersky/compilers-are-databases) +- (JVMLS 2015) [Compilers are Databases](https://www.youtube.com/watch?v=WxyyJyB_Ssc) by [Martin Odersky](http://x.com/odersky) [\[slides\]](http://www.slideshare.net/Odersky/compilers-are-databases) -- (Scala World 2015) [Dotty: Exploring the future of Scala](https://www.youtube.com/watch?v=aftdOFuVU1o) by [Dmitry Petrashko](http://twitter.com/darkdimius) [\[slides\]](https://d-d.me/scalaworld2015/#/). +- (Scala World 2015) [Dotty: Exploring the future of Scala](https://www.youtube.com/watch?v=aftdOFuVU1o) by [Dmitry Petrashko](http://x.com/darkdimius) [\[slides\]](https://d-d.me/scalaworld2015/#/). Dmitry covers many of the new features that Dotty brings on the table such as Intersection and Union types, improved lazy val initialization and more. Dmitry also covers dotty internals and in particular the high-level of contextual abstractions of Dotty. You will get to become familiar with many core concepts such as `Denotations`, their evolution through (compilation) time, their @@ -34,17 +34,17 @@ Deep Dive with Scala 3 - (ScalaDays 2019, Lausanne) [Future-proofing Scala: the TASTY intermediate representation](https://www.youtube.com/watch?v=zQFjC3zLYwo) by [Guillaume Martres](http://guillaume.martres.me/). -- (Mar 21, 2017) [Dotty Internals 1: Trees & Symbols](https://www.youtube.com/watch?v=yYd-zuDd3S8) by [Dmitry Petrashko](http://twitter.com/darkdimius) [\[meeting notes\]](https://dotty.epfl.ch/docs/internals/dotty-internals-1-notes.html). +- (Mar 21, 2017) [Dotty Internals 1: Trees & Symbols](https://www.youtube.com/watch?v=yYd-zuDd3S8) by [Dmitry Petrashko](http://x.com/darkdimius) [\[meeting notes\]](https://dotty.epfl.ch/docs/internals/dotty-internals-1-notes.html). This is a recorded meeting between EPFL and Waterloo, where we introduce first notions inside Dotty: Trees and Symbols. -- (Mar 21, 2017) [Dotty Internals 2: Types](https://www.youtube.com/watch?v=3gmLIYlGbKc) by [Martin Odersky](http://twitter.com/odersky) and [Dmitry Petrashko](http://twitter.com/darkdimius). +- (Mar 21, 2017) [Dotty Internals 2: Types](https://www.youtube.com/watch?v=3gmLIYlGbKc) by [Martin Odersky](http://x.com/odersky) and [Dmitry Petrashko](http://x.com/darkdimius). This is a recorded meeting between EPFL and Waterloo, where we introduce how types are represented inside Dotty. -- (Jun 15, 2017) [Dotty Internals 3: Denotations](https://youtu.be/9iPA7zMRGKY) by [Martin Odersky](http://twitter.com/odersky) and [Dmitry Petrashko](http://twitter.com/darkdimius). +- (Jun 15, 2017) [Dotty Internals 3: Denotations](https://youtu.be/9iPA7zMRGKY) by [Martin Odersky](http://x.com/odersky) and [Dmitry Petrashko](http://x.com/darkdimius). This is a recorded meeting between EPFL and Waterloo, where we introduce denotations in Dotty. -- (JVM Language Summit) [How do we make the Dotty compiler fast](https://www.youtube.com/watch?v=9xYoSwnSPz0) by [Dmitry Petrashko](http://twitter.com/darkdimius). - [Dmitry Petrashko](http://twitter.com/darkdimius) gives a high-level introduction on what was done to make Dotty . +- (JVM Language Summit) [How do we make the Dotty compiler fast](https://www.youtube.com/watch?v=9xYoSwnSPz0) by [Dmitry Petrashko](http://x.com/darkdimius). + [Dmitry Petrashko](http://x.com/darkdimius) gives a high-level introduction on what was done to make Dotty . - (Typelevel Summit Oslo, May 2016) [Dotty and types: the story so far](https://www.youtube.com/watch?v=YIQjfCKDR5A) by @@ -52,7 +52,7 @@ Deep Dive with Scala 3 Guillaume focused on some practical improvements to the type system that Dotty makes, like the new type parameter inference algorithm that is able to reason about the type safety of more situations than scalac. -- (flatMap(Oslo) 2016) [AutoSpecialization in Dotty](https://vimeo.com/165928176) by [Dmitry Petrashko](http://twitter.com/darkdimius) [\[slides\]](https://d-d.me/talks/flatmap2016/#/). +- (flatMap(Oslo) 2016) [AutoSpecialization in Dotty](https://vimeo.com/165928176) by [Dmitry Petrashko](http://x.com/darkdimius) [\[slides\]](https://d-d.me/talks/flatmap2016/#/). The Dotty Linker analyses your program and its dependencies to apply a new specialization scheme. It builds on our experience from Specialization, Miniboxing and the Valhalla Project, and drastically reduces the size of the emitted bytecode. And, best of all, it's always enabled, happens behind the diff --git a/scalacenter-courses.md b/scalacenter-courses.md new file mode 100644 index 0000000000..b242e6f5fe --- /dev/null +++ b/scalacenter-courses.md @@ -0,0 +1,169 @@ +--- +title: Online Courses (MOOCs) from The Scala Center +layout: singlepage-overview +languages: [ru] +testimonials: + - /resources/images/scalacenter-courses/testimonial000.jpg + - /resources/images/scalacenter-courses/testimonial001.jpg + - /resources/images/scalacenter-courses/testimonial002.jpg + - /resources/images/scalacenter-courses/testimonial003.jpg + - /resources/images/scalacenter-courses/testimonial004.jpg + - /resources/images/scalacenter-courses/testimonial005.jpg + - /resources/images/scalacenter-courses/testimonial006.jpg + - /resources/images/scalacenter-courses/testimonial007.jpg + - /resources/images/scalacenter-courses/testimonial008.jpg + - /resources/images/scalacenter-courses/testimonial009.jpg + - /resources/images/scalacenter-courses/testimonial010.jpg + - /resources/images/scalacenter-courses/testimonial011.jpg + - /resources/images/scalacenter-courses/testimonial012.jpg + - /resources/images/scalacenter-courses/testimonial013.jpg + - /resources/images/scalacenter-courses/testimonial014.jpg +--- + +The [Scala Center] produces online courses (a.k.a. MOOCs) of various levels, from beginner +to advanced. + +**If you are a programmer and want to learn Scala**, there are two recommended +approaches. The fast path consists of taking the course [Effective Programming +in Scala](#effective-programming-in-scala). +Otherwise, you can take the full [Scala Specialization], which is made of +four courses (covering advanced topics such as big data analysis and +parallel programming) and a capstone project. + +You can learn more about the courses in the following video: + +
+ +
+ +## Scala Learning Path + +The diagram below summarizes the possible learning paths with our courses: + +![](/resources/images/learning-path.png) + +The “foundational” courses target programmers with no prior experience in Scala, whereas the “deepening” +courses aim at strengthening Scala programmers skills in a specific domain (such as parallel programming). + +We recommend starting with either Effective Programming in Scala, or Functional Programming Principles in +Scala followed by Functional Program Design. Then, you can complement your Scala skills by taking any +of the courses Programming Reactive Systems, Parallel Programming, or Big Data Analysis with Scala and Spark. +In case you take the Scala Specialization, you will end with the Scala Capstone Project. + +## Learning Platforms + +Currently, all our MOOCs are available on the platform [Coursera](https://coursera.org), +and some of them are available on [edX](https://edx.org) or the [Extension School](https://extensionschool.ch). +This section explains the differences between these learning platforms. + +On all the platforms the full material is always available online. It includes +video lectures, text articles, quizzes, and auto-graded homeworks. All the +platforms also provide discussion forums where you can exchange with the +other learners. + +The difference between the Extension School and the other platforms is that it +provides live meetings with instructors, and code reviews by Scala experts. + +On the other hand, on Coursera or edX it is possible to take +our courses for free (a.k.a. “audit” mode). Optionally, a subscription gives +you access to a certificate of completion that attests your accomplishments. + +Learn more about +[Coursera certificates](https://learners.coursera.help/hc/en-us/articles/209819053-Get-a-Course-Certificate), +[edX certificates](https://support.edx.org/hc/en-us/categories/115002269627-Certificates), +or [Extension School certificates](https://www.extensionschool.ch/faqs#certifying-coursework). +Note that your subscriptions also supports the work of the [Scala Center], +whose mission is to create high-quality educational material. + +If you prefer learning in autonomy, we recommend +you to choose the Coursera or edX platform, but if you are looking for more +support, we recommend you to choose the Extension School. Here is a table +below that compares the learning platforms: + +| | Coursera / edX (audit) | Coursera / edX (subscription) | Extension School | +|--------------------------------------------------|------------------------|-------------------------------|------------------| +| Video lectures, quizzes | Yes | Yes | Yes | +| Auto-graded homeworks | Yes | Yes | Yes | +| Discussion forums | Yes | Yes | Yes | +| Self-paced | Yes | Yes | Yes | +| Price | $0 | $50 to $100 per course | $420 per month | +| Certificate of completion | No | Yes | Yes | +| Supports the Scala Center | No | Yes | Yes | +| 30 min of live session with instructors per week | No | No | Yes | +| Code reviews by Scala experts | No | No | Yes | + +## Effective Programming in Scala + +This course is available on [Coursera](https://coursera.org/learn/effective-scala) +and the [Extension School](https://extensionschool.ch/learn/effective-programming-in-scala). +Please refer to [this section](#learning-platforms) to know the differences +between both learning platforms. + +[Effective Programming in Scala] teaches non-Scala programmers everything +they need to be ready to work in Scala. At the end of this hands-on course, +you will know how to achieve common programming tasks in Scala (e.g., +modeling business domains, implementing business logic, designing large +systems made of components, handling errors, manipulating data, running +concurrent tasks in parallel, testing your code). You can learn more about +this course in the following video: + +
+ +
+ +This course is also a good way to upgrade your Scala 2 knowledge to Scala 3. + +After taking this course, you might be interested in improving your +skills in specific areas by taking the courses [Parallel Programming], +[Big Data Analysis with Scala and Spark], or [Programming Reactive Systems]. + +## Scala Specialization + +The [Scala Specialization] provides a hands-on introduction to functional programming using Scala. You can access the courses +material and exercises by either signing up for the specialization or auditing the courses individually. The +specialization has the following courses. +* [Functional Programming Principles in Scala], +* [Functional Program Design in Scala], +* [Parallel programming], +* [Big Data Analysis with Scala and Spark], +* [Functional Programming in Scala Capstone]. + +These courses provide a deep understanding of the Scala language itself, +and they also dive into more specific topics such as parallel programming, +and Spark. + +## Programming Reactive Systems + +[Programming Reactive Systems] (also available on [edX](https://www.edx.org/course/scala-akka-reactive)) +teaches how to write responsive, scalable, and resilient systems with the +library Akka. + +## Scala 2 Courses + +The above courses all use Scala 3. If needed, you can find +the (legacy) Scala 2 version of our courses here: + +- [Functional Programming Principles in Scala (Scala 2 version)](https://www.coursera.org/learn/scala2-functional-programming) +- [Functional Program Design (Scala 2 version)](https://www.coursera.org/learn/scala2-functional-program-design) +- [Parallel Programming (Scala 2 version)](https://www.coursera.org/learn/scala2-parallel-programming) +- [Big Data Analysis with Scala and Spark (Scala 2 version)](https://www.coursera.org/learn/scala2-spark-big-data) +- [Programming Reactive Systems (Scala 2 version)](https://www.coursera.org/learn/scala2-akka-reactive) + +## Testimonials + +{% include carousel.html images=page.testimonials number=0 height="50" unit="%" duration="10" %} + +## Other Online Resources + +You can find other online resources contributed by the community on +[this page]({% link online-courses.md %}). + +[Scala Center]: https://scala.epfl.ch +[Scala Specialization]: https://www.coursera.org/specializations/scala +[Effective Programming in Scala]: https://www.coursera.org/learn/effective-scala +[Functional Programming Principles in Scala]: https://www.coursera.org/learn/scala-functional-programming +[Functional Program Design in Scala]: https://www.coursera.org/learn/scala-functional-program-design +[Parallel programming]: https://www.coursera.org/learn/scala-parallel-programming +[Big Data Analysis with Scala and Spark]: https://www.coursera.org/learn/scala-spark-big-data +[Functional Programming in Scala Capstone]: https://www.coursera.org/learn/scala-capstone +[Programming Reactive Systems]: https://www.coursera.org/learn/scala-akka-reactive diff --git a/scripts/run-mdoc.sh b/scripts/run-mdoc.sh index 6d729df4f1..fc478f83d5 100755 --- a/scripts/run-mdoc.sh +++ b/scripts/run-mdoc.sh @@ -1,11 +1,11 @@ #!/bin/bash set -eux -cs launch --scala-version 2.13.15 org.scalameta::mdoc:2.3.3 -- \ +cs launch --scala-version 2.13.16 org.scalameta::mdoc:2.3.3 -- \ --in . \ --out /tmp/mdoc-out/ \ --classpath \ - $(cs fetch --scala-version 2.13.15 -p \ + $(cs fetch --scala-version 2.13.16 -p \ com.chuusai::shapeless:2.3.10 \ org.scala-lang::toolkit:0.1.7 \ org.scala-lang::toolkit-test:0.1.7 \