|
| 1 | +--- |
| 2 | +layout: doc-page |
| 3 | +title: Getting Started: Users |
| 4 | +--- |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +Basics |
| 9 | +------------ |
| 10 | +Make sure that you are using Java 8 or later. The output of `java -version` |
| 11 | +should contain `1.8`. |
| 12 | + |
| 13 | + |
| 14 | +Option 1: Install Dotty |
| 15 | +------------- |
| 16 | +If you're a Mac user, you can install dotty with [brew](https://brew.sh/) |
| 17 | + |
| 18 | +```bash |
| 19 | +brew install lampepfl/brew/dotty |
| 20 | +``` |
| 21 | + |
| 22 | +If you're a Linux or Windows user, download the [latest release](https://github.com/lampepfl/dotty/releases). Optionally add path of the folder `bin/` to the system environment variable `PATH`. |
| 23 | + |
| 24 | +Option 2: Using Dotty directly from source |
| 25 | +------------- |
| 26 | +```bash |
| 27 | +$ git clone --recursive https://github.com/lampepfl/dotty.git |
| 28 | +$ cd dotty |
| 29 | +$ sbt managedSources # Needed for IDE import to succeed |
| 30 | +``` |
| 31 | + |
| 32 | +Dotty provides a standard sbt build: compiling, running and starting a repl can |
| 33 | +all be done from within sbt: |
| 34 | + |
| 35 | +```bash |
| 36 | +$ sbt |
| 37 | +> dotc tests/pos/HelloWorld.scala |
| 38 | +> dotr HelloWorld |
| 39 | +hello world |
| 40 | +``` |
| 41 | + |
| 42 | +Try Dotty |
| 43 | +---------- |
| 44 | +Try it in your browser with [Scastie](https://scastie.scala-lang.org/?target=dotty) |
| 45 | + |
| 46 | + |
| 47 | +Create a Dotty Project |
| 48 | +----------------------- |
| 49 | +The fastest way to create a new project in dotty is using [sbt (0.13.5+)](http://www.scala-sbt.org/) |
| 50 | + |
| 51 | +Create a dotty project: |
| 52 | +```bash |
| 53 | +$ sbt new lampepfl/dotty.g8 |
| 54 | +``` |
| 55 | + |
| 56 | +Or a Dotty project that cross compiles with Scala 2: |
| 57 | +```bash |
| 58 | +$ sbt new lampepfl/dotty-cross.g8 |
| 59 | +``` |
| 60 | + |
| 61 | +For an example project, see the [Dotty Example Proejct](https://github.com/lampepfl/dotty-example-project) |
| 62 | + |
| 63 | + |
| 64 | +Bash Scripts |
| 65 | +------------- |
| 66 | +Assuming that you have cloned the Dotty repo locally, append the following line on your `.bash_profile`: |
| 67 | + |
| 68 | +```shell |
| 69 | +$ export PATH=$HOME/dotty/bin:$PATH |
| 70 | +``` |
| 71 | + |
| 72 | +and you will be able to run the corresponding commands directly from your console: |
| 73 | + |
| 74 | +```shell |
| 75 | +# Compile code using Dotty |
| 76 | +$ dotc tests/pos/HelloWorld.scala |
| 77 | + |
| 78 | +# Run it with the proper classpath |
| 79 | +$ dotr HelloWorld |
| 80 | +``` |
| 81 | + |
| 82 | + |
| 83 | +Starting a REPL |
| 84 | +---------------- |
| 85 | +```bash |
| 86 | +$ sbt |
| 87 | +> repl |
| 88 | +Welcome to Scala.next (pre-alpha) (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_101). |
| 89 | +Type in expressions to have them evaluated. |
| 90 | +Type :help for more information. |
| 91 | +scala> |
| 92 | +``` |
| 93 | + |
| 94 | +or via bash: |
| 95 | + |
| 96 | +```bash |
| 97 | +$ dotr |
| 98 | +``` |
0 commit comments