Mar*_*lic 12 development-environment scala build-tools incremental-build scala-metals
生态系统中有无数的开发工具和术语,例如语言服务器、构建服务器、Metals、BSP、LSP、Bloop、Zinc、Coursier、增量编译器、演示编译器等。
我想知道是否有人可以演示它们如何组合在一起并简要解释关系和差异。具体来说,我希望按照“理解 Scala FP 库”的思路给出图表和答案。例如,这是我的尝试
(Concept) (Example implementation)
--------------------------------------------------------------------
IDE Visual Studio Code
| |
Scala IDE plugin Metals Visual Studio Extension
| |
Language Server Protocol Microsoft LSP
| |
Scala language server Metals
| |
Build Server Protocol BSP from JetBrains and Scala Center
| |
Scala build server Bloop
| |
Build tool sbt
| |
Dependency resolution Coursier
| |
Incremental compiler Zinc
| |
Presentation compiler parser and typer phases of scalac
| |
Bytecode generation remaining compiler phases
Run Code Online (Sandbox Code Playgroud)
Mat*_*zok 18
Intellij 或(曾经)Scala IDE 之类的 IDE 旨在用于“智能”开发,其中编辑器会告诉您代码是否正确、建议修复、自动生成一些代码、提供代码导航、重构——换句话说,许多扩展方式的功能超越简单的文本版本,也许只有语法高亮。
Intellij 有一个 Scala 扩展,它利用他们自己重新实现的 Scala 编译器——他们需要它来更好地部分编译和智能感知,即使部分代码被破坏。来自其他构建工具(例如 sbt 或 bloop)的导入构建定义,然后 Intellij 不会回复任何外部内容(除非您使用诸如“使用 sbt 构建”之类的选项)。
Scala IDE relied on Scala presentation compiler for intellisense. As you can read on scala-ide.org:
The Scala IDE for Eclipse uses the Scala Presentation Compiler, a faster asynchronous version of the Scala Compiler. The presentation compiler only runs the phases up until and including the typer phase, that is, the first 4 of the 27 scala compilation phases. The IDE uses the presentation compiler to provide semantic features such as live error markers, inferred type hovers, and semantic highlighting. This document describes the key classes you need to know in order to understand how the Scala IDE uses the presentation compiler and provides some examples of interactions between the IDE and the presentation compiler.
Every other editor/IDE is intended to use Language Server Protocol - LSP is Microsoft's invention in order to standardize a way of supporting languages within different editors (though they invented it for the sake of VS Code) that would allow them to provide IDE features. Metals (from ScalaMeta Language Server) is LSP implementation for Scala. As you can read here:
Code completions, type at point and parameter hints are implemented using the Scala presentation compiler, which is maintained by the Scala compiler team at Lightbend.
You can add it to VS Code using Scala Metals extension.
sbt, gradle, mill, fury, cbt, etc are build tools which use something like ivy2 or coursier to resolve and download dependencies, and then use Zinc incremental compiler in order to provide ability to (re)build things incrementally to normal compiler. Build tools can run tests, generate artifacts and deploy them to repository.
bloop is a solution to problem that compiletion is fast if JVM is hot, and JVM gets cold every time you kill your build tool/IDE. For that reason you use nailgun to keep some JVM warm, running build tasks in background. On its own bloop cannot generate configuration and in general it is something that should be generated by other build tool to speed up compilation during development. Protocol used to communicate with bloop server running in background is build server protocol (bsp).
Coursier, while is used primarily for dependency resolution, can also be used to install scala programs. Some of the noteworthy programs that you can install are:
scala
which provides a lot of nice featuresI gave up on describing thing in table, as it would much better be shown on a graph, but since SO doesn't support that visuals I just resorted to a plain text.