Skip to content

Commit d8cd455

Browse files
committed
rework documentation page
1 parent 1d917f3 commit d8cd455

File tree

7 files changed

+261
-206
lines changed

7 files changed

+261
-206
lines changed

_includes/navbar.html

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
<ul class="nav">
22
<li>
33
<div class="dropdown">
4-
<a class="dropdown-toggle" role="button" data-toggle="dropdown" data-target="#"
5-
href="{{ site.baseurl }}/documentation/">
4+
<a href="{{ site.baseurl }}/documentation/">
65
Documentation
7-
<b class="caret"></b>
86
</a>
9-
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
10-
<li><a href="{{ site.baseurl }}/documentation/">Learning Scala</a>
11-
<li><a href="{{ site.baseurl }}/documentation/books.html">Books</a></li>
12-
<li class="dropdown-submenu">
13-
<a tabindex="-1" href="#">API</a>
14-
<ul class="dropdown-menu">
15-
<li><a href="{{ site.baseurl }}/files/archive/api/2.10-latest">2.10</a></li>
16-
<li><a href="{{ site.baseurl }}/files/archive/api/2.9-latest">2.9</a></li>
17-
<li><a href="{{ site.baseurl }}/files/archive/nightly/docs/library">2.11 Nightly</a></li>
18-
</ul>
19-
</li>
20-
<li><a href="{{ site.baseurl }}/files/archive/nightly/pdfs/ScalaReference.pdf">Language Spec</a></li>
21-
</ul>
227
</div>
238
</li>
249
<li>

documentation/getting-started.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
layout: page
3+
title: Getting Started
4+
---
5+
6+
# Getting started
7+
8+
The best way to learn Scala depends on what you know already and the way you prefer to learn things. There is a variety of resources available including [books]({{ site.baseurl }}/documentation/books.html), tutorials, training courses, presentations, and of course the Scala compiler for practice. Many people find a good combination is to have one of the Scala books at hand and to start right away trying the examples with the Scala Compiler. On the other hand, you may want to get started with a Scala training course or using the material available online.
9+
10+
As your knowledge of Scala grows, you will find there is more advanced material and a very friendly [Scala community]({{ site.baseurl }}/community/) at hand to help you. They all share a passion for Scala and welcome newcomers warmly. Many have written helpful material for programmers new to Scala, will respond to emails asking for help or are sharing neat new techniques, advanced concepts or tools in one of several Scala forums or personal blogs.
11+
12+
13+
## Scala for Programming Beginners
14+
15+
If you are just starting to learn how to code, you will find that a large portion of the material about Scala assumes that you already have some programming experience. There are two valuable resources which we can recommend to programming beginners that will take you directly into the world of Scala:
16+
17+
* The online class [Functional Programming Principles in Scala](https://www.coursera.org/course/progfun), available on coursera. Taught by the creator of Scala, Martin Odersky, this online class takes a somewhat academic approach to teach the fundamentals of functional programming. You will learn a lot of Scala by solving the programming assignments.
18+
* [Kojo](http://www.kogics.net/sf:kojo) is an interactive learning environment that uses Scala programming to explore and play with math, art, music, animations and games.
19+
20+
## Getting Scala Up and Running
21+
22+
There are multiple ways to get Scala code compiling and running on your machine. The most widely used tools are:
23+
24+
* Your favorite text editor and the command-line [Scala compiler]({{ site.baseurl }}/download/), see the [Getting Started]({{ site.baseurl }}/download/getting-started.html) guide
25+
* IDEs for Scala: The [Scala IDE](http://scala-ide.org/), [IntelliJ IDEA](http://www.jetbrains.com/idea/) with the Scala plugin, and [NetBeans IDE](http://netbeans.org/) with the Scala plugin
26+
* Build tools for Scala: [sbt](http://www.scala-sbt.org/), maven with the [Scala plugin](http://davidb.github.com/scala-maven-plugin/index.html) or the [Scala plugin for gradle](http://www.gradle.org/docs/current/userguide/scala_plugin.html)
27+
28+
The **Scala interpreter** (also called the REPL) is a very valuable tool for experimenting with Scala. It is installed together with the command-line compiler and allows you to interactively write and evaluate Scala expressions.
29+
30+
The Scala IDE and IntelliJ IDEA both support **[Scala worksheets](https://github.com/scala-ide/scala-worksheet/wiki/Getting-Started)**, interactive Scala documents that are continuously evaluated line-by-line. Worksheets are an excellent way to experiment with Scala while still being able to save your code as in file and reuse it later on.
31+
32+
##Your first lines of code
33+
34+
### The "Hello, world!" Program
35+
36+
As a first example, we use the standard "Hello, world" program to demonstrate the use of the Scala tools without knowing too much about the language.
37+
38+
object HelloWorld {
39+
def main(args: Array[String]) {
40+
println("Hello, world!")
41+
}
42+
}
43+
44+
The structure of this program should be familiar to Java programmers: it consists of the method `main` which prints out a friendly greeting to the standard output.
45+
46+
We assume that both the [Scala software]({{ site.baseurl }}/download) and the user environment are set up correctly. For example:
47+
48+
| Environment | Variable | Value (example)
49+
|:------------|:-----------------|:---------------
50+
| Unix | `$SCALA_HOME` | `/usr/local/share/scala`
51+
| | `$PATH` | `$PATH:$SCALA_HOME/bin`
52+
| Windows | `%SCALA_HOME%` | `c:\Progra~1\Scala`
53+
| | `%PATH%` | `%PATH%;%SCALA_HOME%\bin`
54+
55+
56+
### Run it interactively!
57+
58+
The `scala` command starts an interactive shell where Scala expressions are interpreted interactively.
59+
60+
> scala
61+
This is a Scala shell.
62+
Type in expressions to have them evaluated.
63+
Type :help for more information.
64+
65+
scala> object HelloWorld {
66+
| def main(args: Array[String]) {
67+
| println("Hello, world!")
68+
| }
69+
| }
70+
defined module HelloWorld
71+
72+
scala> HelloWorld.main(null)
73+
Hello, world!
74+
75+
scala>:q
76+
>
77+
78+
The shortcut `:q` stands for the internal shell command `:quit` used to exit the interpreter.
79+
80+
### Compile it!
81+
82+
The `scalac` command compiles one (or more) Scala source file(s) and generates Java bytecode which can be executed on any [standard JVM](http://java.sun.com/docs/books/jvms/). The Scala compiler works similarly to `javac`, the Java compiler of the [Java SDK](http://java.sun.com/javase/).
83+
84+
> scalac HelloWorld.scala
85+
86+
By default `scalac` generates the class files into the current working directory. You may specify a different output directory using the `-d` option.
87+
88+
> scalac -d classes HelloWorld.scala
89+
90+
91+
### Execute it!
92+
93+
The `scala` command executes the generated bytecode with the appropriate options:
94+
95+
> scala HelloWorld
96+
97+
`scala` allows us to specify command options, such as the `-classpath` (alias `-cp`) option:
98+
99+
> scala -cp classes HelloWorld
100+
101+
The argument of the `scala` command has to be a top-level object. If that object extends trait [`App`]({{page.docpath}}#scala.App), then all statements contained in that object will be executed; otherwise you have to add a method `main` which will act as the entry point of your program.
102+
103+
Here is how the "Hello, world" example looks like using the `App` trait:
104+
105+
object HelloWorld extends App {
106+
println("Hello, world!")
107+
}
108+
109+
### Script it!
110+
111+
We may also run our example as a shell script or batch command (see the examples in the man pages of the `scala` command).
112+
113+
The [bash](http://www.gnu.org/software/bash/) shell script `script.sh` containing the following Scala code (and shell preamble)
114+
115+
#!/bin/sh
116+
exec scala "$0" "$@"
117+
!#
118+
object HelloWorld extends App {
119+
println("Hello, world!")
120+
}
121+
HelloWorld.main(args)
122+
123+
can be run directly from the command shell:
124+
125+
> ./script.sh
126+
127+
**Note**: We assume here that the file `script.sh` has execute access and the search path for the `scala` command is specified in the `PATH` environment variable.

documentation/index.md

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,59 @@ title: Learn
55

66
# Learning Scala
77

8-
The best way to learn Scala depends on what you know already and the way you prefer to learn things. There is a variety of resources available including [books]({{ site.baseurl }}/documentation/books.html), tutorials, training courses, presentations, and of course the Scala compiler for practice. Many people find a good combination is to have one of the Scala books at hand and to start right away trying the examples with the Scala Compiler. On the other hand, you may want to get started with a Scala [training course](#training) or using the material available online.
9-
10-
As your knowledge of Scala grows, you will find there is more advanced material and a very friendly [Scala community]({{ site.baseurl }}/community/) at hand to help you. They all share a passion for Scala and welcome newcomers warmly. Many have written helpful material for programmers new to Scala, will respond to emails asking for help or are sharing neat new techniques, advanced concepts or tools in one of several Scala forums or personal blogs.
11-
12-
13-
## Scala for Programming Beginners
14-
15-
16-
If you are just starting to learn how to code, you will find that a large portion of the material about Scala assumes that you already have some programming experience. There are two valuable resources which we can recommend to programming beginners that will take you directly into the world of Scala:
17-
18-
* The online class [Functional Programming Principles in Scala](https://www.coursera.org/course/progfun), available on coursera. Taught by the creator of Scala, Martin Odersky, this online class takes a somewhat academic approach to teach the fundamentals of functional programming. You will learn a lot of Scala by solving the programming assignments.
19-
* [Kojo](http://www.kogics.net/sf:kojo) is an interactive learning environment that uses Scala programming to explore and play with math, art, music, animations and games.
20-
21-
22-
8+
<div class="container">
9+
<div class="row">
10+
<div class="span4 doc-block">
11+
<h3><a href="{{ site.baseurl }}/documentation/getting-started.html">Getting Started</a></h3>
12+
<p>Install Scala on your computer and start writing some Scala code!</p>
13+
</div>
14+
<div class="span4 doc-block">
15+
<h3><a href="http://docs.scala-lang.org/overviews/">Overviews/Guides</a></h3>
16+
<p>Access detailed documentation on important language features.</p>
17+
</div>
18+
<div class="span4 doc-block">
19+
<h3><a href="http://docs.scala-lang.org/tutorials/">Tutorials</a></h3>
20+
<p>Digest bite-size pieces of the essentials.</p>
21+
</div>
22+
</div>
23+
24+
<div class="row">
25+
<div class="span4 doc-block">
26+
<h3><a href="http://www.scala-lang.org/api/current/index.html#package">API</a></h3>
27+
<p>Dive straight into the API.</p>
28+
</div>
29+
<div class="span4 doc-block">
30+
<h3><a href="{{ site.baseurl }}/files/archive/nightly/pdfs/ScalaReference.pdf">Specification [PDF]</a></h3>
31+
<p>Get an in-depth overview of the language.</p>
32+
</div>
33+
<div class="span4 doc-block">
34+
<h3><a href="http://docs.scala-lang.org/glossary/">Glossary</a></h3>
35+
<p>Understand Scala's vocabulary.</p>
36+
</div>
37+
</div>
38+
39+
<div class="row">
40+
<div class="span4 doc-block">
41+
<h3><a href="http://docs.scala-lang.org/cheatsheets/">Cheatsheets</a></h3>
42+
<p>Access language constructs quickly.</p>
43+
</div>
44+
<div class="span4 doc-block">
45+
<h3><a href="http://docs.scala-lang.org/style/">Style Guide</a></h3>
46+
<p>Learn how to code elegantly.</p>
47+
</div>
48+
<div class="span4 doc-block">
49+
<h3><a href="{{ site.baseurl }}/documentation/getting_started.html">Common Scala Questions</a></h3>
50+
<p>Dispel your doubts about common Scala features.</p>
51+
</div>
52+
</div>
53+
</div>
54+
55+
56+
<!-- Keep this text here for now
2357
## The Scala Documentation Site
2458
2559
Your main entry point into online documentation on Scala is the official documentation site, [docs.scala-lang.org](http://docs.scala-lang.org/). It contains a growing number of articles, guides and tutorials. The following list highlights some of the most important documents, but the doc site contains much more than that!
26-
27-
### Scala Tutorial for Java Programmers
28-
29-
Many things you already know from your Java experience directly carry over to the Scala environment. The [Scala Tutorial for Java Programmers](http://docs.scala-lang.org/tutorials/scala-for-java-programmers.html) is intended for people who already have some programming experience and want an overview of what they can do with Scala.
30-
31-
32-
### Guides for Libraries and Language Features
33-
34-
The section [Guides and Overviews](http://docs.scala-lang.org/overviews/) contains many useful guides about core libraries and features of Scala, for instance about:
35-
36-
* [Scala's Collection Library](http://docs.scala-lang.org/overviews/collections/introduction.html),
37-
* [Futures and Promises](http://docs.scala-lang.org/overviews/core/futures.html), or
38-
* [String Interpolation](http://docs.scala-lang.org/overviews/core/string-interpolation.html)
39-
40-
41-
### A Tour of Scala
42-
43-
If you want to learn what Scala is all about and what are its most important and distincitve language features, the [Tour of Scala](http://docs.scala-lang.org/tutorials/tour/tour-of-scala.html) is a highly informative document. Note however that a the tour also shows you some of the more advanced features that can be found in Scala, so if you're just beginning, don't worry if you don't understand everything!
44-
45-
46-
47-
## Getting Scala Up and Running
48-
49-
There are multiple ways to get Scala code compiling and running on your machine. The most widely used tools are:
50-
51-
* Your favorite text editor and the command-line [Scala compiler]({{ site.baseurl }}/download/), see the [Getting Started]({{ site.baseurl }}/download/getting-started.html) guide
52-
* IDEs for Scala: The [Scala IDE](http://scala-ide.org/), [IntelliJ IDEA](http://www.jetbrains.com/idea/) with the Scala plugin, and [NetBeans IDE](http://netbeans.org/) with the Scala plugin
53-
* Build tools for Scala: [sbt](http://www.scala-sbt.org/), maven with the [Scala plugin](http://davidb.github.com/scala-maven-plugin/index.html) or the [Scala plugin for gradle](http://www.gradle.org/docs/current/userguide/scala_plugin.html)
54-
55-
The **Scala interpreter** (also called the REPL) is a very valuable tool for experimenting with Scala. It is installed together with the command-line compiler and allows you to interactively write and evaluate Scala expressions.
56-
57-
The Scala IDE and IntelliJ IDEA both support **[Scala worksheets](https://github.com/scala-ide/scala-worksheet/wiki/Getting-Started)**, interactive Scala documents that are continuously evaluated line-by-line. Worksheets are an excellent way to experiment with Scala while still being able to save your code as in file and reuse it later on.
60+
-->
5861

5962

6063
## Online Learning
@@ -66,17 +69,15 @@ There are a few interactive resources for trying out Scala, to get a look and fe
6669
signing up for the course. (The course will be given again soon..)
6770
* [Try Simply Scala](http://www.simplyscala.com/): [Simply Scala](http://www.simplyscala.com/) is a web site where you can interactively try Scala. There you will find a tutorial that gives a rapid overview of the basic language features, the syntax, examples you can run and the ability to try your own code with an interactive interpreter.
6871

69-
## Training
70-
71-
If you want to learn Scala in a more official setting, you can always sign up for some quality training. Here below
72-
are some schools you can register to:
72+
## Books
7373

74-
* [Training from Typesafe](http://www.typesafe.com/products/training): [Typesafe](http://www.typesafe.com/) and its partners provide regular Scala training courses and Scala consulting in many locations world-wide. They provide expert teachers, including Iulian Dragos, Heiko Seeberger and other certified Scala trainers, to take you through the Scala language in a systematic way either in group classes at their facilities or on your own site.
74+
There are more and more books being published about Scala. [Here]({{ site.baseurl }}/documentation/books.html), you can find some of the titles. We only list books here which give an introduction to the Scala Language. Books which require knowledge of Scala, in particular books on frameworks like Lift, Play! or Akka are notlisted here.
7575

76-
* [Underscore Training](http://underscoreconsulting.com/training/): [Underscore Consulting](http://underscoreconsulting.com/) is a provider of professional services relating to the Scala programming language. Centered around London, UK, they provide a full range of services including consulting on architecture and design, training for all levels of Scala developers, and a complete software development service.
7776

78-
* [Escalate Training](http://www.escalatesoft.com/training): [Escalate Software](http://www.escalatesoft.com/) provides professional training and consulting services for teams using the Scala programming language around the Bay Area.
77+
## Bleeding edge
7978

79+
If you are interested in finding out about the hottest, most pressing issues of tomorrow in the Scala world, have a look at the
80+
[Scala Improvement Process (SIP) page](http://docs.scala-lang.org/sips/).
8081

8182
## Older Documentation
8283

0 commit comments

Comments
 (0)