Scala: Difference between revisions
m (add chinese translate) |
Spacebanana (talk | contribs) (Added Scala CLI section, since it's a great tool for Scala projects, as an alternative to build tools. Scala CLI will also become the default official "scala" command in the near future.) |
||
(11 intermediate revisions by 6 users not shown) | |||
Line 9: | Line 9: | ||
From [[wikipedia:Scala_(programming_language)|Wikipedia]]: | From [[wikipedia:Scala_(programming_language)|Wikipedia]]: | ||
: | :Scala is an object-functional programming and scripting language for general software applications. Scala has full support for functional programming (including currying, pattern matching, algebraic data types, lazy evaluation, tail recursion, immutability, etc.) and a very strong static type system. This allows programs written in Scala to be very concise and thus smaller in size than most general purpose programming languages. Many of Scala's design decisions were inspired by criticism over the shortcomings of Java. | ||
== Installation == | == Installation == | ||
[[Install]] the {{ | [[Install]] the {{AUR|scala}} package. Additionally you can install the packages {{AUR|scala-docs}} and/or {{AUR|scala-sources}} for further reference. | ||
Since Scala runs on the [[wikipedia:JVM|JVM]] (Java Virtual Machine), you will need a fully functional [[Java#Installation|Java Runtime Environment]] (JRE) in order to execute or compile your programs. | Since Scala runs on the [[wikipedia:JVM|JVM]] (Java Virtual Machine), you will need a fully functional [[Java#Installation|Java Runtime Environment]] (JRE) in order to execute or compile your programs. | ||
For scala3 (which is also known as [https://dotty.epfl.ch dotty]), you can install {{AUR|scala3}} or {{AUR|scala-dotty}} | For scala3 (which is also known as [https://dotty.epfl.ch dotty]), you can install {{AUR|scala3}} or {{AUR|scala-dotty}}. Note that scala3 is '''incompatible''' with scala 2.13 or older. | ||
=== Build tools === | === Build tools === | ||
Most build tools are available | Most build tools are available: | ||
* {{pkg|sbt}} | * {{pkg|sbt}} | ||
* {{pkg|mill}} | |||
* {{pkg|maven}} | * {{pkg|maven}} | ||
* {{pkg|gradle}} | * {{pkg|gradle}} | ||
=== Scala CLI === | |||
As an alternative to using build tools or the compiler directly, you can use [https://scala-cli.virtuslab.org/ Scala CLI] for building and distributing your software. | |||
Install the {{AUR|scala-cli}} package. | |||
== Usage and IDEs == | == Usage and IDEs == | ||
{{Expansion|Redirect to IDE pages, a lot of IDEs provide scala as a plugin, so list how to install said plugin}} | |||
Just as in other programming languages like [[Python]], you can interact with an interpreter | Just as in other programming languages like [[Python]], you can interact with an interpreter | ||
Line 44: | Line 53: | ||
$ scala HelloWorld | $ scala HelloWorld | ||
Many different [[IDE]]s such as [[Eclipse]] or [[Netbeans]] offer support for Scala. | Many different [[IDE]]s such as [[Eclipse]] or [[Netbeans]] offer support for Scala. Alternatively, consider {{AUR|scala-ide}} or {{pkg|ammonite}}. You can also download an IDE that is optimized for Scala and also based on Eclipse directly from [https://scala-lang.org the official Scala Website]. | ||
== See also == | == See also == |
Latest revision as of 14:35, 20 April 2024
From Wikipedia:
- Scala is an object-functional programming and scripting language for general software applications. Scala has full support for functional programming (including currying, pattern matching, algebraic data types, lazy evaluation, tail recursion, immutability, etc.) and a very strong static type system. This allows programs written in Scala to be very concise and thus smaller in size than most general purpose programming languages. Many of Scala's design decisions were inspired by criticism over the shortcomings of Java.
Installation
Install the scalaAUR package. Additionally you can install the packages scala-docsAUR and/or scala-sourcesAUR for further reference.
Since Scala runs on the JVM (Java Virtual Machine), you will need a fully functional Java Runtime Environment (JRE) in order to execute or compile your programs.
For scala3 (which is also known as dotty), you can install scala3AUR or scala-dottyAUR. Note that scala3 is incompatible with scala 2.13 or older.
Build tools
Most build tools are available:
Scala CLI
As an alternative to using build tools or the compiler directly, you can use Scala CLI for building and distributing your software.
Install the scala-cliAUR package.
Usage and IDEs
Just as in other programming languages like Python, you can interact with an interpreter
$ scala Welcome to Scala version 2.*.* (OpenJDK Server VM, Java 1.*.*). Type in expressions to have them evaluated. Type :help for more information. scala>
as well as simply compile and run your programs from the command line.
$ scalac HelloWorld.scala $ scala HelloWorld
Many different IDEs such as Eclipse or Netbeans offer support for Scala. Alternatively, consider scala-ideAUR or ammonite. You can also download an IDE that is optimized for Scala and also based on Eclipse directly from the official Scala Website.
See also
- Scala Lang - official website
- Scala Tutorial - a series of small Scala tutorials
- Learn X=Scala in Y minutes