Skip to content

Commit b808a4b

Browse files
committed
Improve the getting started page
* making the page self contained: users can have a working "hello-world" without visiting other pages * introducing couriser-cli a recommended way to install jvm requirements * adding Vscode/metals as a possible IDE * advertising only two ways of starting with Scala: interactive with Scastie or with and IDE + sbt
1 parent f7b1cc2 commit b808a4b

File tree

2 files changed

+109
-42
lines changed

2 files changed

+109
-42
lines changed

_getting-started/index.md

Lines changed: 107 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,121 @@ includeTOC: true
77

88
redirect_from: "/getting-started.html"
99
---
10+
## Try Scala without installing anything
11+
You can [try Scala in your browser](https://scastie.scala-lang.org/MHc7C9iiTbGfeSAvg8CKAA), with access to all Scala compilers and
12+
all published libraries.
13+
14+
## Installing Scala
15+
### Using the Scala Installer (recommended way)
16+
The Scala installer is a tool named `cs` that ensures that a JVM and standard Scala tools are installed on your system.
17+
18+
* Download the `cs` tool and execute the `setup` command
19+
20+
<div class="main-download">
21+
<div id="download-step-one">
22+
<p>Follow <a href="https://get-coursier.io/docs/cli-overview.html#install-native-launcher" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
23+
<p><code>$ ./cs setup</code></p>
24+
</div>
25+
</div>
26+
27+
28+
Along with managing JVMs, it also install useful command-line tools:
29+
ammonite, coursier, scala, scalac, sbt-launcher, scalafmt.
30+
31+
For more information, read [couriser-cli documentation](https://get-coursier.io/docs/cli-overview)
32+
33+
### ...Or manually
34+
1. if you don't have java 1.8 or 11 installed, download
35+
Java from [Oracle Java 8](https://www.oracle.com/java/technologies/javase-jdk8-downloads.html), [
36+
Oracle Java 11](https://www.oracle.com/java/technologies/javase-jdk11-downloads.html),
37+
or [AdoptOpenJDK 8/11](https://adoptopenjdk.net/). Refer [JDK Compatibility](/overviews/jdk-compatibility/overview.html) for Scala/Java compatibility detail.
38+
1. Install [sbt](https://www.scala-sbt.org/download.html)
39+
40+
41+
## Create a Hello-world project with sbt
42+
### Using command-line
43+
sbt is a build tool for Scala. sbt compiles, runs,
44+
and tests your projects among other related tasks.
45+
46+
1. `cd` to an empty folder.
47+
1. Run the following command `sbt new scala/hello-world.g8`.
48+
This pulls the 'hello-world' template from GitHub.
49+
It will also create a `target` folder, which you can ignore.
50+
1. When prompted, name the application `hello-world`. This will
51+
create a project called "hello-world".
52+
1. Let's take a look at what just got generated:
53+
54+
```
55+
- hello-world
56+
- project (sbt uses this to install and manage plugins and dependencies)
57+
- build.properties
58+
- src
59+
- main
60+
- scala (All of your scala code goes here)
61+
- Main.scala (Entry point of program) <-- this is all we need for now
62+
- build.sbt (sbt's build definition file)
63+
```
64+
65+
More documentation about sbt can be found in the [Scala Book](/overviews/scala-book/scala-build-tool-sbt.html)
66+
or in the official sbt [documentation](https://www.scala-sbt.org/1.x/docs/index.html)
67+
68+
### Without using command-line
69+
You can skip the rest of this page and go directly to [Building a Scala Project with IntelliJ and sbt](/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html#next-steps)
70+
71+
72+
## Open hello-world project
73+
### Using Intellij
74+
1. Download and install [IntelliJ Community Edition](https://www.jetbrains.com/idea/download/)
75+
1. Install Scala plugin by following [the instructions on how to install IntelliJ plugins](https://www.jetbrains.com/help/idea/managing-plugins.html)
76+
1. Open the `build.sbt` file then choose *Open as a project*
77+
78+
### Using VSCode with metals
79+
1. Download [VSCode](https://code.visualstudio.com/Download)
80+
1. Install the Metals extension from [the Marketplace](https://marketplace.visualstudio.com/items?itemName=scalameta.metals)
81+
1. Next, open the directory containing a `build.sbt` file. When prompted to do so, select *Import build*.
82+
83+
## Run Hello World
84+
Open a terminal
85+
1. `cd` into `hello-world`.
86+
1. Run `sbt`. This will open up the sbt console.
87+
1. Type `~run`. The `~` is optional and causes sbt to re-run on every file save,
88+
allowing for a fast edit/run/debug cycle. sbt will also generate a `target` directory
89+
which you can ignore.
1090

11-
There are __two__ main ways people prefer to work in Scala:
12-
13-
* Using an IDE.
14-
* Using the command line.
15-
16-
The following tutorials will walk you through the setup process for whichever way
17-
you prefer.
18-
19-
However, if you just want to jump directly into Scala without installing anything, skip the guides on this page and check out:
20-
21-
* [Our interactive introduction to Scala on scala-exercises.com](https://www.scala-exercises.org/scala_tutorial/terms_and_types), or
22-
* [Scastie](https://scastie.scala-lang.org/), Scala in the browser, with access to all Scala compilers and all published libraries!
23-
24-
## Setting up and getting started with Scala
25-
26-
### If you prefer working in an IDE...
27-
28-
IntelliJ is the most commonly-used IDE by Scala developers. In this tutorial,
29-
we'll walk you through downloading and setting up IntelliJ with the Scala
30-
plugin, and we'll get you started with your first Scala project, complete with
31-
unit tests!
32-
33-
* [Getting Started with Scala in IntelliJ](/getting-started/intellij-track/getting-started-with-scala-in-intellij.html)
34-
* [Building a Scala Project with IntelliJ and sbt](/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html)
35-
* [Testing Scala in IntelliJ with ScalaTest](/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.html)
36-
37-
38-
### If you prefer working on the command line...
39-
40-
If you prefer using a text editor like emacs, Vim, Atom, or Sublime Text, then
41-
the best way to compile, test, and run Scala code is by using _sbt_, Scala's build
42-
tool.
43-
44-
* [Getting Started with Scala and sbt on the Command Line](/getting-started/sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html)
45-
* [Testing Scala with sbt and ScalaTest on the Command Line](/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.html)
46-
47-
<!-- sbt is the easiest way to ensure that your Scala project is reproducible;
48-
you specify a Scala version, any libraries you depend on, and sbt takes care of
49-
the rest, so it's as easy as possible for someone else to compile and run your
50-
Scala project. -->
5191

5292
## Next Steps
5393
Once you've finished these tutorials, check out:
5494

55-
* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
5695
* [The Scala Book](/overviews/scala-book/introduction.html), which provides a set of short lessons introducing Scala’s main features.
96+
* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
5797
* [Learning Resources](/learn.html), which includes online interactive tutorials and courses.
5898
* [Our list of some popular Scala books](/books.html).
5999

60100
## Getting Help
61101
There are a multitude of mailing lists and real-time chat channels in case you want to quickly connect with other Scala users. Check out our [community](https://scala-lang.org/community/) page for a list of these resources, and for where to reach out for help.
102+
103+
<!-- Hidden elements whose content are used to provide OS-specific download instructions.
104+
-- This is handled in `resources/js/functions.js`.
105+
-->
106+
<div style="display:none" id="stepOne-linux">
107+
<code class="hljs">$ curl -Lo cs https://git.io/coursier-cli-linux && chmod +x cs && ./cs setup </code> <br>
108+
</div>
109+
110+
<div style="display:none" id="stepOne-unix">
111+
<p>Follow <a href="https://get-coursier.io/docs/cli-overview.html#install-native-launcher" target="_blank">the instructions to install the <code>cs</code> launcher</a> then run:</p>
112+
<p><code>$ ./cs setup</code></p>
113+
</div>
114+
115+
<div style="display:none" id="stepOne-osx">
116+
<div class="highlight">
117+
<code class="hljs">$ brew install coursier/formulas/coursier && cs setup </code> <br>
118+
</div>
119+
<p>Alternatively, if you don't use Homebrew</p>
120+
<div class="highlight">
121+
<code class="hljs">$ curl -Lo cs https://git.io/coursier-cli-macos && chmod +x cs && (xattr -d com.apple.quarantine cs || true) && ./cs setup </code> <br>
122+
</div>
123+
</div>
124+
125+
<div style="display:none" id="stepOne-windows">
126+
<p>Download and execute <a href="https://git.io/coursier-cli-windows-exe">the Scala installer for Windows</a> based on coursier</p>
127+
</div>

_getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Continue to the next tutorial in the _getting started with IntelliJ_ series, and
105105

106106
**or**
107107

108+
* [The Scala Book](/overviews/scala-book/introduction.html), which provides a set of short lessons introducing Scala’s main features.
109+
* [The Tour of Scala](/tour/tour-of-scala.html) for bite-sized introductions to Scala's features.
108110
- Continue learning Scala interactively online on
109111
[Scala Exercises](https://www.scala-exercises.org/scala_tutorial).
110-
- Learn about Scala's features in bite-sized pieces by stepping through our [Tour of Scala]({{ site.baseurl }}/tour/tour-of-scala.html).

0 commit comments

Comments
 (0)