You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
Copy file name to clipboardExpand all lines: documentation/index.md
+55-54Lines changed: 55 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -5,56 +5,59 @@ title: Learn
5
5
6
6
# Learning Scala
7
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](#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.
<p>Dispel your doubts about common Scala features.</p>
51
+
</div>
52
+
</div>
53
+
</div>
54
+
55
+
56
+
<!-- Keep this text here for now
23
57
## The Scala Documentation Site
24
58
25
59
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:
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
+
-->
58
61
59
62
60
63
## Online Learning
@@ -66,17 +69,15 @@ There are a few interactive resources for trying out Scala, to get a look and fe
66
69
signing up for the course. (The course will be given again soon..)
67
70
*[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.
68
71
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
73
73
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.
75
75
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.
77
76
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
79
78
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/).
0 commit comments